-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy patheslint.config.js
More file actions
233 lines (227 loc) · 6.85 KB
/
Copy patheslint.config.js
File metadata and controls
233 lines (227 loc) · 6.85 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
import path from 'path';
import { fileURLToPath } from 'url';
import angularTypescriptConfig from '@siemens/eslint-config-angular';
import angularTemplateConfig from '@siemens/eslint-config-angular/template';
import vitest from '@vitest/eslint-plugin';
import tsdocPlugin from 'eslint-plugin-tsdoc';
import eslintPluginHeaders from 'eslint-plugin-headers';
import { defineConfig } from 'eslint/config';
// mimic CommonJS variables
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const tsConfig = defineConfig({
extends: [...angularTypescriptConfig],
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
project: ['src/tsconfig.app.json'],
tsconfigRootDir: __dirname
}
},
plugins: {
'tsdoc': tsdocPlugin,
'headers': eslintPluginHeaders,
'vitest': vitest
},
rules: {
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
'vitest/expect-expect': ['off'],
'vitest/require-awaited-expect-poll': 'error',
'vitest/prefer-vi-mocked': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/prefer-to-have-been-called-times': 'error',
'vitest/prefer-to-contain': 'error',
'vitest/prefer-to-be-object': 'error',
'vitest/prefer-each': 'error',
'vitest/prefer-comparison-matcher': 'error',
'@typescript-eslint/no-unused-vars': ['off'],
'@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/prefer-signals': [
'error',
{ preferInputSignals: false, preferQuerySignals: false }
],
'@angular-eslint/no-experimental': ['off'],
'@angular-eslint/no-developer-preview': ['error'],
'@angular-eslint/prefer-host-metadata-property': ['off'],
'no-console': [
'error',
{
allow: ['warn', 'error']
}
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@angular/localize/init',
importNames: ['$localize'],
message: 'Please use $localize from the global scope. No import required'
},
{
name: '@angular/cdk/coercion',
message: 'Use the convert functions from @angular/core instead.'
},
{
name: '@siemens/element-ng',
message: 'Use the secondary entrypoints instead.'
},
{
name: '@ngx-translate/core',
importNames: ['TranslatePipe'],
message: 'Use `SiTranslatePipe` from `@siemens/element-translate-ng/translate` instead.'
},
{
name: '@siemens/element-translate-ng',
message:
'Always use a dedicated secondary entrypoint, e.g. `@siemens/element-translate-ng/translate`.'
}
]
}
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowDirectConstAssertionInArrowFunctions: true
}
],
'tsdoc/syntax': ['error'],
'@typescript-eslint/no-deprecated': ['error'],
'headers/header-format': [
'error',
{
'source': 'string',
'content': 'Copyright (c) Siemens 2016 - 2026\nSPDX-License-Identifier: MIT'
}
],
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration',
message: "Don't declare enums"
},
{
selector: 'TSTypeReference:not([typeArguments]) > Identifier[name="SimpleChanges"]',
message: 'Use SimpleChanges<this> instead of plain SimpleChanges'
}
]
}
});
export const templateConfig = defineConfig({
extends: [...angularTemplateConfig],
files: ['**/*.html'],
rules: {
'@angular-eslint/template/prefer-ngsrc': ['off'],
'@angular-eslint/template/no-duplicate-attributes': [
'error',
{
'ignore': ['class']
}
],
'@angular-eslint/template/no-inline-styles': ['off'],
'@angular-eslint/template/interactive-supports-focus': ['off'],
'@angular-eslint/template/prefer-template-literal': ['off'],
'@angular-eslint/template/no-non-null-assertion': ['off'],
'@angular-eslint/template/elements-content': [
'error',
{
allowList: [
'siHeaderLogo',
'aria-label',
'innerHtml',
'innerHTML',
'innerText',
'outerHTML',
'title',
'si-tab'
]
}
]
}
});
export const indexBarrelConfig = defineConfig({
files: ['**/index.ts'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'ExportNamedDeclaration[declaration]',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'VariableDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'FunctionDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'ClassDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'TSInterfaceDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'TSTypeAliasDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'TSEnumDeclaration',
message:
'index.ts files must only re-export from other modules. Move declarations to a dedicated file.'
},
{
selector: 'ExportDefaultDeclaration',
message:
'index.ts files must only use named re-exports. Default exports are not allowed in barrel files.'
},
{
selector: 'TSModuleDeclaration',
message:
'index.ts files must only re-export from other modules. Move namespace declarations to a dedicated file.'
},
{
selector: 'ExpressionStatement',
message:
'index.ts files must only re-export from other modules. Move expressions to a dedicated file.'
}
]
}
});
export const strictLinterOptions = defineConfig({
linterOptions: {
reportUnusedDisableDirectives: 'error'
}
});
export default defineConfig(
...tsConfig,
...templateConfig,
...indexBarrelConfig,
...strictLinterOptions
);