Skip to content

Commit

Permalink
Update to ESLint 9 (#549)
Browse files Browse the repository at this point in the history
* Update to ESLint 9
* Fix unit tests
* Fix checkstyle formater
  • Loading branch information
jfcere authored Oct 12, 2024
1 parent f14639d commit 72851b0
Show file tree
Hide file tree
Showing 18 changed files with 646 additions and 730 deletions.
106 changes: 0 additions & 106 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ chrome-profiler-events*.json

# Miscellaneous
/.angular/cache
.nx/cache
.nx/workspace-data
.sass-cache/
/connect.lock
/coverage
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"source.fixAll": "explicit"
},

"eslint.useFlatConfig": true,

"files.associations": {
"*.json": "jsonc",
"package.json": "json"
Expand Down
9 changes: 6 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": "demo/.eslintrc.json",
"eslintConfig": "demo/eslint.config.js",
"lintFilePatterns": [
"demo/**/*.ts",
"demo/**/*.html"
Expand Down Expand Up @@ -156,7 +156,7 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": "lib/.eslintrc.json",
"eslintConfig": "lib/eslint.config.js",
"lintFilePatterns": [
"lib/**/*.ts",
"lib/**/*.html"
Expand All @@ -167,6 +167,9 @@
}
},
"cli": {
"analytics": false
"analytics": false,
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}
55 changes: 0 additions & 55 deletions demo/.eslintrc.json

This file was deleted.

58 changes: 58 additions & 0 deletions demo/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// @ts-check
const tseslint = require("typescript-eslint");
const angular = require("angular-eslint");

const baseConfig = require("../eslint.config.js");

module.exports = tseslint.config(
{
extends: [...baseConfig],
},
{
ignores: ["!**/*"],
},
{
files: ["**/*.ts"],

languageOptions: {
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
project: "tsconfig.app.json",
tsconfigRootDir: __dirname,
createDefaultProgram: true,
},
},

processor: angular.processInlineTemplates,

rules: {
"@angular-eslint/component-selector": ["error", {
"type": "element",
"prefix": "app",
"style": "kebab-case",
}],

"@angular-eslint/directive-selector": ["error", {
"type": "attribute",
"prefix": "app",
"style": "camelCase",
}],

"@angular-eslint/no-output-native": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-var-requires": "off",
"comma-dangle": ["error", "always-multiline"],
"import/order": "error",
"object-shorthand": "off",
},
},
{
files: ["**/*.html"],
rules: {},
},
);
118 changes: 118 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// @ts-check
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const importPlugin = require("eslint-plugin-import");
const angular = require("angular-eslint");

module.exports = tseslint.config(
{
ignores: ["projects/**/*"],
},
{
files: ["**/*.ts"],

extends: [
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended,
],

plugins: {
"import": importPlugin,
},

settings: {
"import/resolver": {
node: true,
typescript: "eslint-import-resolver-typescript"
}
},

languageOptions: {
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
createDefaultProgram: true,
},
},

processor: angular.processInlineTemplates,

rules: {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase",
},
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case",
},
],

"@angular-eslint/no-output-native": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-wrapper-object-types": "off",
"comma-dangle": ["error", "always-multiline"],

"comma-spacing": ["error", {
"before": false,
"after": true,
}],

"import/order": ["error", {
"alphabetize": {
"order": "asc",
"caseInsensitive": true,
},

"newlines-between": "never",

"pathGroups": [{
"pattern": "@*/**",
"group": "parent",
}, {
"pattern": "ngx-markdown",
"group": "external",
}],
}],

"import/no-duplicates": "error",
"object-curly-spacing": ["error", "always"],
"object-shorthand": "off",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"semi-spacing": "error",

"sort-imports": ["error", {
"ignoreCase": true,
"ignoreDeclarationSort": true,
}],
},
},
{
files: ["**/*.html"],

extends: [
...angular.configs.templateRecommended,
],

rules: {},
}
);
Loading

0 comments on commit 72851b0

Please sign in to comment.