-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
182 lines (180 loc) · 7.14 KB
/
eslint.config.mjs
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
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import angular from 'angular-eslint';
function tsFiles(files, extraRules = {}) {
return {
files: [files],
extends: [
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
...angular.configs.tsAll,
],
processor: angular.processInlineTemplates,
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@angular-eslint/component-max-inline-declarations': 'off', // We use that mostly for testing, so it's fine
'@angular-eslint/no-forward-ref': 'off', // We sometimes need it
'@angular-eslint/prefer-on-push-component-change-detection': 'off',
'@angular-eslint/use-component-selector': 'off', // Some components are not template-able and thus do not need selector
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/no-confusing-void-expression': 'off', // Don't create unncessary closure and we prefer code tersity anyway
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extraneous-class': 'off', // We have component without any logic in TS
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off', // This is very unfortunate, but there are too many dangerous false-positive, see https://github.com/typescript-eslint/typescript-eslint/issues/1798
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off', // Usually a good idea, but sometimes dangerous false-positive
'@typescript-eslint/unbound-method': 'off',
'@angular-eslint/prefer-signals': [
'error',
{
preferInputSignals: false, // Only when our code will be entirely migrated to `input()`
},
],
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'app',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'app',
style: 'kebab-case',
},
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{
allowArgumentsExplicitlyTypedAsAny: true,
},
],
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
// We want to use promise in Rxjs subscribes without caring about the promise result
arguments: false,
properties: false,
},
},
],
'@typescript-eslint/restrict-plus-operands': [
'error',
{
// Allow some flexibility
allowAny: true,
allowBoolean: true,
allowNullish: true,
allowNumberAndString: true,
},
],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
// Allow some flexibility
allowAny: true,
allowBoolean: true,
allowNullish: true,
allowNumber: true,
},
],
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowTernary: true,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
},
],
'no-restricted-globals': [
'error',
'atob',
'bota',
'document',
'event',
'history',
'length',
'localStorage',
'location',
'name',
'navigator',
'sessionStorage',
'window',
],
...extraRules,
},
};
}
export default tseslint.config(
tsFiles('**/*.ts'),
tsFiles('projects/angular-natural-gallery/src/**/*.ts', {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'natural',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'natural',
style: 'kebab-case',
},
],
}),
{
files: ['**/*.html'],
extends: [...angular.configs.templateAll],
rules: {
'@angular-eslint/template/alt-text': 'off', // We don't care as much as we should about a11y
'@angular-eslint/template/button-has-type': 'off',
'@angular-eslint/template/click-events-have-key-events': 'off', // We don't care as much as we should about a11y
'@angular-eslint/template/i18n': 'off',
'@angular-eslint/template/interactive-supports-focus': 'off', // We don't care as much as we should about a11y
'@angular-eslint/template/label-has-associated-control': 'off', // We don't care as much as we should about a11y
'@angular-eslint/template/no-any': 'off', // Unfortunately, some libs force us to use this
'@angular-eslint/template/no-autofocus': 'off',
'@angular-eslint/template/no-call-expression': 'off',
'@angular-eslint/template/no-inline-styles': 'off', // We sometimes use short inline styles
'@angular-eslint/template/prefer-ngsrc': 'off', // TODO: experiment with ngsrc and see if we need to use it or not
'@angular-eslint/template/eqeqeq': [
'error',
{
allowNullOrUndefined: true,
},
],
},
},
);