1
- import { FlatCompat } from '@eslint/eslintrc' ;
2
- import js from '@eslint/js' ;
1
+ import eslint from '@eslint/js' ;
2
+ import angular from 'angular-eslint' ;
3
+ import depend from 'eslint-plugin-depend' ;
3
4
import perfectionist from 'eslint-plugin-perfectionist' ;
4
5
import { default as eslintPluginPrettierRecommended } from 'eslint-plugin-prettier/recommended' ;
5
6
import sonarjs from 'eslint-plugin-sonarjs' ;
6
- import path from 'node:path ' ;
7
- import { fileURLToPath } from 'node:url ' ;
7
+ import { defineConfig } from 'eslint/config ' ;
8
+ import tseslint from 'typescript-eslint ' ;
8
9
9
- const __filename = fileURLToPath ( import . meta. url ) ;
10
- const __dirname = path . dirname ( __filename ) ;
11
- const compat = new FlatCompat ( {
12
- allConfig : js . configs . all ,
13
- baseDirectory : __dirname ,
14
- recommendedConfig : js . configs . recommended ,
15
- } ) ;
16
-
17
- export default [
10
+ export default defineConfig ( [
11
+ {
12
+ extends : [
13
+ // Apply the recommended core rules
14
+ eslint . configs . recommended ,
15
+ // Apply the recommended TypeScript rules
16
+ ...tseslint . configs . recommended ,
17
+ // Optionally apply stylistic rules from typescript-eslint that improve code consistency
18
+ ...tseslint . configs . stylistic ,
19
+ // Apply the recommended Angular rules
20
+ ...angular . configs . tsRecommended ,
21
+ ] ,
22
+ // Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
23
+ files : [ '**/*.ts' ] ,
24
+ // Set the custom processor which will allow us to have our inline Component templates extracted
25
+ // and treated as if they are HTML files (and therefore have the .html config below applied to them)
26
+ processor : angular . processInlineTemplates ,
27
+ // Override specific rules for TypeScript files (these will take priority over the extended configs above)
28
+ rules : {
29
+ '@angular-eslint/component-selector' : [
30
+ 'error' ,
31
+ {
32
+ prefix : 'app' ,
33
+ style : 'kebab-case' ,
34
+ type : 'element' ,
35
+ } ,
36
+ ] ,
37
+ '@angular-eslint/directive-selector' : [
38
+ 'error' ,
39
+ {
40
+ prefix : 'app' ,
41
+ style : 'camelCase' ,
42
+ type : 'attribute' ,
43
+ } ,
44
+ ] ,
45
+ } ,
46
+ } ,
47
+ {
48
+ extends : [
49
+ // Apply the recommended Angular template rules
50
+ ...angular . configs . templateRecommended ,
51
+ // Apply the Angular template rules which focus on accessibility of our apps
52
+ ...angular . configs . templateAccessibility ,
53
+ ] ,
54
+ // Everything in this config object targets our HTML files (external templates,
55
+ // and inline templates as long as we have the `processor` set on our TypeScript config above)
56
+ files : [ '**/*.html' ] ,
57
+ rules : {
58
+ '@angular-eslint/template/elements-content' : 'off' ,
59
+ } ,
60
+ } ,
61
+ {
62
+ extends : [ 'depend/flat/recommended' ] ,
63
+ files : [ '**/*.ts' ] ,
64
+ plugins : {
65
+ depend,
66
+ } ,
67
+ } ,
18
68
{
19
69
...perfectionist . configs [ 'recommended-natural' ] ,
20
70
rules : {
@@ -30,18 +80,6 @@ export default [
30
80
{
31
81
ignores : [ 'src/grpc/**/*' ] ,
32
82
} ,
33
- ...compat
34
- . extends (
35
- 'eslint:recommended' ,
36
- 'plugin:@typescript-eslint/recommended' ,
37
- 'plugin:@angular-eslint/recommended' ,
38
- 'plugin:@angular-eslint/template/process-inline-templates' ,
39
- 'plugin:depend/recommended' ,
40
- )
41
- . map ( ( config ) => ( {
42
- ...config ,
43
- files : [ '**/*.ts' ] ,
44
- } ) ) ,
45
83
{
46
84
files : [ '**/*.ts' ] ,
47
85
languageOptions : {
@@ -71,19 +109,6 @@ export default [
71
109
] ,
72
110
} ,
73
111
} ,
74
- ...compat . extends ( 'plugin:@angular-eslint/template/recommended' ) . map ( ( config ) => ( {
75
- ...config ,
76
- files : [ '**/*.html' ] ,
77
- } ) ) ,
78
- {
79
- files : [ '**/*.html' ] ,
80
- rules : { } ,
81
- } ,
82
- ...compat . extends ( 'plugin:prettier/recommended' ) . map ( ( config ) => ( {
83
- ...config ,
84
- files : [ '**/*.html' ] ,
85
- ignores : [ '**/*inline-template-*.component.html' ] ,
86
- } ) ) ,
87
112
{
88
113
files : [ '**/*.html' ] ,
89
114
ignores : [ '**/*inline-template-*.component.html' ] ,
@@ -96,4 +121,4 @@ export default [
96
121
] ,
97
122
} ,
98
123
} ,
99
- ] ;
124
+ ] ) ;
0 commit comments