Skip to content

Commit 35bcf09

Browse files
committed
feat: update eslint to v9
1 parent 3213de9 commit 35bcf09

File tree

7 files changed

+321
-281
lines changed

7 files changed

+321
-281
lines changed

.eslintrc.json

Lines changed: 0 additions & 89 deletions
This file was deleted.

angular.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,26 @@
3333
"zone.js/testing"
3434
]
3535
}
36+
},
37+
"lint": {
38+
"builder": "@angular-eslint/builder:lint",
39+
"options": {
40+
"lintFilePatterns": [
41+
"projects/code-editor/**/*.ts",
42+
"projects/code-editor/**/*.html"
43+
],
44+
"eslintConfig": "projects/code-editor/eslint.config.js"
45+
}
3646
}
3747
}
3848
},
3949
"dev-app": {
4050
"projectType": "application",
51+
"schematics": {
52+
"@schematics/angular:component": {
53+
"style": "scss"
54+
}
55+
},
4156
"root": "projects/dev-app",
4257
"sourceRoot": "projects/dev-app/src",
4358
"prefix": "app",
@@ -125,9 +140,10 @@
125140
"builder": "@angular-eslint/builder:lint",
126141
"options": {
127142
"lintFilePatterns": [
128-
"projects/dev-app/src/**/*.ts",
129-
"projects/dev-app/src/**/*.html"
130-
]
143+
"projects/dev-app/**/*.ts",
144+
"projects/dev-app/**/*.html"
145+
],
146+
"eslintConfig": "projects/dev-app/eslint.config.js"
131147
}
132148
},
133149
"deploy": {
@@ -140,12 +156,6 @@
140156
}
141157
}
142158
},
143-
"schematics": {
144-
"@schematics/angular:component": {
145-
"style": "scss",
146-
"skipTests": true
147-
}
148-
},
149159
"cli": {
150160
"analytics": false
151161
}

eslint.config.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// @ts-check
2+
const eslint = require('@eslint/js');
3+
const tseslint = require('typescript-eslint');
4+
const angular = require('angular-eslint');
5+
6+
module.exports = tseslint.config(
7+
{
8+
files: ['**/*.ts'],
9+
extends: [
10+
eslint.configs.recommended,
11+
...tseslint.configs.recommended,
12+
...tseslint.configs.stylistic,
13+
...angular.configs.tsRecommended,
14+
],
15+
processor: angular.processInlineTemplates,
16+
rules: {
17+
'max-len': [
18+
'warn',
19+
{
20+
code: 100,
21+
ignoreComments: true,
22+
ignoreStrings: true,
23+
ignoreTemplateLiterals: true,
24+
},
25+
],
26+
'object-shorthand': ['warn', 'always', { avoidQuotes: true }],
27+
'quote-props': ['warn', 'consistent-as-needed'],
28+
'quotes': ['warn', 'single', { allowTemplateLiterals: true }],
29+
'semi': ['warn', 'always'],
30+
'@typescript-eslint/no-explicit-any': 'off',
31+
'@typescript-eslint/no-empty-function': 'off',
32+
'@typescript-eslint/no-inferrable-types': 'off',
33+
'@typescript-eslint/no-unused-vars': 'off',
34+
'@angular-eslint/no-empty-lifecycle-method': 'off',
35+
'@angular-eslint/no-output-native': 'off',
36+
},
37+
},
38+
{
39+
files: ['**/*.html'],
40+
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
41+
rules: {
42+
'@angular-eslint/template/prefer-self-closing-tags': 'warn',
43+
},
44+
}
45+
);

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"build": "ng build dev-app --base-href=/code-editor/",
1212
"watch": "ng build dev-app --watch --configuration development",
1313
"test": "ng test dev-app",
14-
"lint": "npm run lint:ts && npm run lint:scss",
15-
"lint:ts": "eslint \"**/*.ts\" --fix",
14+
"lint": "ng lint --fix && npm run lint:scss",
1615
"lint:scss": "stylelint \"**/*.scss\" --fix",
1716
"build:lib": "ng build code-editor",
1817
"postbuild:lib": "cp README.md dist/code-editor",
@@ -46,22 +45,16 @@
4645
},
4746
"devDependencies": {
4847
"@angular-devkit/build-angular": "^18.2.8",
49-
"@angular-eslint/builder": "^18.3.1",
50-
"@angular-eslint/eslint-plugin": "^18.3.1",
51-
"@angular-eslint/eslint-plugin-template": "^18.3.1",
52-
"@angular-eslint/schematics": "^18.3.1",
53-
"@angular-eslint/template-parser": "^18.3.1",
5448
"@angular/cli": "^18.2.8",
5549
"@angular/compiler-cli": "^18.2.8",
5650
"@commitlint/cli": "^19.3.0",
5751
"@commitlint/config-conventional": "^19.2.0",
5852
"@types/jasmine": "~5.1.0",
5953
"@types/lodash-es": "^4.17.10",
6054
"@types/node": "^20.12.0",
61-
"@typescript-eslint/eslint-plugin": "^7.8.0",
62-
"@typescript-eslint/parser": "^7.8.0",
6355
"angular-cli-ghpages": "^2.0.0",
64-
"eslint": "^8.57.0",
56+
"angular-eslint": "^18.3.1",
57+
"eslint": "^9.12.0",
6558
"husky": "^8.0.3",
6659
"jasmine-core": "~5.1.0",
6760
"karma": "~6.4.0",
@@ -75,6 +68,7 @@
7568
"stylelint": "^16.5.0",
7669
"stylelint-config-recommended-scss": "^14.0.0",
7770
"stylelint-config-standard": "^36.0.0",
78-
"typescript": "~5.4.5"
71+
"typescript": "~5.4.5",
72+
"typescript-eslint": "^8.8.1"
7973
}
8074
}

projects/code-editor/eslint.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// @ts-check
2+
const tseslint = require('typescript-eslint');
3+
const rootConfig = require('../../eslint.config.js');
4+
5+
module.exports = tseslint.config(
6+
...rootConfig,
7+
{
8+
files: ['**/*.ts'],
9+
rules: {
10+
'@angular-eslint/directive-selector': [
11+
'error',
12+
{
13+
type: 'attribute',
14+
prefix: '',
15+
style: 'camelCase',
16+
},
17+
],
18+
'@angular-eslint/component-selector': [
19+
'error',
20+
{
21+
type: 'element',
22+
prefix: '',
23+
style: 'kebab-case',
24+
},
25+
],
26+
'@angular-eslint/directive-class-suffix': 'off',
27+
'@angular-eslint/component-class-suffix': 'off',
28+
},
29+
},
30+
{
31+
files: ['**/*.html'],
32+
rules: {},
33+
}
34+
);

projects/dev-app/eslint.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @ts-check
2+
const tseslint = require("typescript-eslint");
3+
const rootConfig = require("../../eslint.config.js");
4+
5+
module.exports = tseslint.config(
6+
...rootConfig,
7+
{
8+
files: ["**/*.ts"],
9+
rules: {
10+
"@angular-eslint/directive-selector": [
11+
"error",
12+
{
13+
type: "attribute",
14+
prefix: "app",
15+
style: "camelCase",
16+
},
17+
],
18+
"@angular-eslint/component-selector": [
19+
"error",
20+
{
21+
type: "element",
22+
prefix: "app",
23+
style: "kebab-case",
24+
},
25+
],
26+
},
27+
},
28+
{
29+
files: ["**/*.html"],
30+
rules: {},
31+
}
32+
);

0 commit comments

Comments
 (0)