-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslint.config.js
132 lines (127 loc) · 4.76 KB
/
eslint.config.js
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
// @ts-check
// Allows us to bring in the recommended core rules from eslint itself
import eslint from '@eslint/js';
// Allows us to use the typed utility for our config, and to bring in the recommended rules for TypeScript projects from typescript-eslint
import tseslint from 'typescript-eslint';
// Allows us to bring in the recommended rules for Angular projects from angular-eslint
import angular from 'angular-eslint';
// Allows us to bring in the recommended rules for Prettier from eslint-plugin-prettier
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
// Export our config array, which is composed together thanks to the typed utility function from typescript-eslint
export default [
...tseslint.config(
{
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
files: ['**/*.ts'],
extends: [
// Apply the recommended core rules
eslint.configs.recommended,
// Apply the recommended TypeScript rules
...tseslint.configs.recommended,
// Optionally apply stylistic rules from typescript-eslint that improve code consistency
...tseslint.configs.stylistic,
// Apply the recommended Angular rules
...angular.configs.tsRecommended
],
// Set the custom processor which will allow us to have our inline Component templates extracted
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
processor: angular.processInlineTemplates,
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
rules: {
'@angular-eslint/prefer-on-push-component-change-detection': 'error',
'@angular-eslint/prefer-signals': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'generic',
readonly: 'generic'
}
],
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': [
'error',
{
allowForKnownSafeCalls: [
// Angular router navigate and navigateByUrl are safe to ignore
{ from: 'package', package: '@angular/router', name: ['navigate', 'navigateByUrl'] }
]
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-case-declarations': 'off',
'no-restricted-syntax': [
'error',
{
selector: "CallExpression[callee.name='fdescribe']",
message: "'Do not use focused test suites (fdescribe)"
},
{
selector: "CallExpression[callee.name='fit']",
message: "'Do not use focused tests (fit)"
}
],
'no-console': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'rxjs/operators'
}
]
}
]
}
},
{
// Everything in this config object targets our HTML files (external templates,
// and inline templates as long as we have the `processor` set on our TypeScript config above)
files: ['**/*.html'],
extends: [
// Apply the recommended Angular template rules
...angular.configs.templateRecommended
],
rules: {
'@angular-eslint/template/alt-text': 'error',
'@angular-eslint/template/prefer-control-flow': 'error',
'@angular-eslint/template/elements-content': 'error',
'@angular-eslint/template/eqeqeq': [
'error',
{
allowNullOrUndefined: true
}
],
'@angular-eslint/template/label-has-associated-control': 'error',
'@angular-eslint/template/no-positive-tabindex': 'error',
'@angular-eslint/template/table-scope': 'error',
'@angular-eslint/template/valid-aria': 'error',
'@angular-eslint/template/no-autofocus': 'error',
'@angular-eslint/template/no-distracting-elements': 'error',
'@angular-eslint/template/prefer-self-closing-tags': 'error'
}
}
),
eslintPluginPrettierRecommended,
// set the parse options for typed rules
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
}
}
];