-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
267 lines (253 loc) · 8.36 KB
/
eslint.config.js
File metadata and controls
267 lines (253 loc) · 8.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import globals from 'globals';
import js from '@eslint/js';
import * as tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
import unusedImports from 'eslint-plugin-unused-imports';
export default [
// Baseline configurations
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
prettierConfig,
// TypeScript files
{
files: ['**/*.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
'unused-imports': unusedImports,
},
rules: {
'complexity': ['warn', 20],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': 'off', // We use @typescript-eslint/no-unused-vars
'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true
}],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}],
'no-unused-imports': 'off', // We use @typescript-eslint/no-unused-vars instead
'@typescript-eslint/unbound-method': ['warn', { ignoreStatic: true }],
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'no-console': ['warn', { allow: ['debug', 'info', 'warn', 'error'] }],
// Architecture validation rules
'no-restricted-imports': ['error', {
patterns: [
{
group: ['*.module'],
message: 'NgModules are deprecated. Use standalone components instead.'
}
],
paths: [
{
name: '@angular/material',
message: 'Import specific Material modules, not the entire library.'
}
]
}],
},
},
// Architecture validation for core services
{
files: ['src/app/core/**/*.ts'],
rules: {
'no-restricted-imports': ['error', {
patterns: [
{
group: ['../../pages/*', '../../auth/services/*', '../../auth/components/*', '../pages/*', '../auth/*'],
message: 'Core services cannot import from feature modules. Use interfaces in core/interfaces instead.'
}
]
}],
},
},
// Architecture validation for domain layer
{
files: ['src/app/**/domain/**/*.ts'],
rules: {
'no-restricted-imports': ['error', {
paths: [
{
name: '@angular/core',
message: 'Domain layer should be pure business logic without Angular dependencies.'
},
{
name: '@angular/common',
message: 'Domain layer should be pure business logic without Angular dependencies.'
},
{
name: '@angular/material',
message: 'Domain layer should be pure business logic without Angular Material dependencies.'
},
{
name: '@angular/material/*',
message: 'Domain layer should be pure business logic without Angular Material dependencies.'
},
{
name: 'rxjs',
message: 'Domain layer should be pure business logic without RxJS dependencies.'
},
{
name: 'rxjs/*',
message: 'Domain layer should be pure business logic without RxJS dependencies.'
}
],
patterns: [
{
group: ['../services/*', '../infrastructure/*', '../../infrastructure/*', '../application/*', '../../application/*'],
message: 'Domain layer should not depend on infrastructure, application, or service layers.'
},
{
group: ['@antv/*'],
message: 'Domain layer should not depend on X6 or other UI framework libraries.'
},
{
group: ['@jsverse/*'],
message: 'Domain layer should not depend on third-party framework libraries.'
}
]
}],
},
},
// Files exempt from certain import restrictions
{
files: ['src/app/shared/imports.ts', 'src/app/app.config.ts'],
rules: {
'no-restricted-imports': ['error', {
paths: [
{
name: '@angular/material',
message: 'Import specific Material modules, not the entire library.'
}
]
// Allow module imports in app.config.ts for third-party modules
}],
},
},
// E2E test files (Playwright)
{
files: ['e2e/**/*.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.e2e.json',
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
'unused-imports': unusedImports,
},
rules: {
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'no-console': 'off',
},
},
// Unit test files (Vitest)
{
files: ['**/*.spec.ts', '**/tests/**/*.ts', '**/testing/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
},
// ZZZ page - disable only unsafe assignment warnings
{
files: ['**/pages/zzz/**/*.ts'],
rules: {
// Disable unsafe assignment and member access warnings for zzz page
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
},
},
// DFD page - disable specific unsafe any warnings
{
files: ['**/pages/dfd/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
},
},
// ae-cvss-calculator library types don't resolve for ESLint's type checker
{
files: [
'**/cvss-calculator-dialog/*.ts',
'**/threat-page/threat-page.component.ts',
],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
},
},
// Angular services and components - relax member ordering
{
files: ['**/services/*.ts', '**/components/*.ts', '**/**.component.ts', '**/i18n/*.ts'],
rules: {
'@typescript-eslint/member-ordering': 'off',
},
},
// Ignore patterns
{
ignores: [
'dist/**/*',
'node_modules/**/*',
'.angular/**/*',
'src/testing/matchers/graph-matchers.d.ts',
'src/app/generated/**/*',
'vitest.config.ts'
],
},
];