-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
311 lines (304 loc) · 10.8 KB
/
.eslintrc.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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
const path = require('node:path');
const glob = require('fast-glob');
module.exports = {
env: {
es2021: true,
},
plugins: ['@shigen'],
rules: {
// https://eslint.org/docs/rules/#possible-problems
'array-callback-return': 'error',
'for-direction': 'error',
'no-async-promise-executor': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-constant-condition': 'error',
'no-constructor-return': 'error',
'no-debugger': 'error',
'no-dupe-else-if': 'error',
'no-duplicate-case': 'error',
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-ex-assign': 'error',
'no-fallthrough': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-misleading-character-class': 'error',
'no-prototype-builtins': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': ['error', { enforceForOrderingRelations: true }],
'no-useless-backreference': 'error',
'require-atomic-updates': 'error',
'use-isnan': 'error',
// https://eslint.org/docs/rules/#suggestions
'default-case-last': 'error',
'eqeqeq': 'error',
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
'no-alert': 'error',
'no-case-declarations': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-delete-var': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-empty': ['error', { allowEmptyCatch: true }],
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-boolean-cast': ['error', { enforceForLogicalOperands: true }],
'no-implicit-coercion': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-multi-assign': 'error',
'no-multi-str': 'error',
'no-negated-condition': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-wrappers': 'error',
'no-nonoctal-decimal-escape': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-regex-spaces': 'error',
'no-return-assign': ['error', 'always'],
'no-script-url': 'error',
'no-sequences': ['error', { allowInParentheses: false }],
'no-shadow-restricted-names': 'error',
'no-undef-init': 'error',
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
'no-useless-call': 'error',
'no-useless-catch': 'error',
'no-useless-computed-key': ['error', { enforceForClassMembers: true }],
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'no-void': 'error',
'no-warning-comments': ['error', { location: 'anywhere' }],
'operator-assignment': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-named-capture-group': 'error',
'prefer-numeric-literals': 'error',
'prefer-object-spread': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'require-unicode-regexp': 'error',
'require-yield': 'error',
'yoda': 'error',
'@shigen/group-imports': [
'error',
'@shigen/polyfill-symbol-dispose',
{ class: 'node' },
{ class: 'external' },
{ class: 'relative' },
],
'@shigen/sort-imports': ['error', { caseGroups: true, typesInGroup: 'top' }],
},
overrides: [
{
files: ['.*rc.js', '*.js'],
env: {
node: true,
},
},
{
files: ['*.mjs', 'vite.config.js'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2022,
},
},
{
files: '*.ts',
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
project: glob.sync('packages/**/tsconfig?(.test).json').filter((configPath, _, source) => {
if (configPath.endsWith('.test.json')) {
return true;
}
return !source.includes(path.posix.join(path.posix.dirname(configPath), 'tsconfig.test.json'));
}),
},
plugins: ['@typescript-eslint'],
rules: {
// https://github.com/typescript-eslint/typescript-eslint/tree/v4.33.0/packages/eslint-plugin#extension-rules
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/lines-between-class-members': [
'error',
'always',
{
exceptAfterSingleLine: true,
exceptAfterOverload: true,
},
],
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-empty-function': ['error', { allow: ['decoratedFunctions'] }],
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-shadow': ['error', { allow: ['Enum', 'Private'] }],
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_', caughtErrors: 'all' }],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
// extension rules with type information
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/return-await': 'error',
// https://github.com/typescript-eslint/typescript-eslint/tree/v4.33.0/packages/eslint-plugin#supported-rules
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/ban-tslint-comment': 'error',
'@typescript-eslint/class-literal-property-style': ['error', 'fields'],
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow-as-parameter',
},
],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', disallowTypeAnnotations: false }],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'@typescript-eslint/explicit-module-boundary-types': ['error'],
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'#private-static-field',
'private-static-field',
'protected-static-field',
'public-static-field',
'#private-static-method',
'private-static-method',
'protected-static-method',
'public-static-method',
'call-signature',
'signature',
'protected-abstract-field',
'public-abstract-field',
'private-decorated-field',
'#private-instance-field',
'private-instance-field',
'protected-decorated-field',
'protected-instance-field',
'public-decorated-field',
'public-instance-field',
'field',
'private-constructor',
'protected-constructor',
'public-constructor',
'constructor',
'protected-abstract-method',
'public-abstract-method',
'private-decorated-method',
'#private-instance-method',
'private-instance-method',
'protected-decorated-method',
'protected-instance-method',
'public-decorated-method',
'public-instance-method',
'method',
],
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['strictCamelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: ['typeLike', 'enumMember'],
format: ['StrictPascalCase'],
},
{
selector: 'parameter',
format: ['strictCamelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'classProperty',
modifiers: ['static', 'readonly'],
format: ['PascalCase'],
},
{
selector: 'typeProperty',
format: ['StrictPascalCase', 'strictCamelCase'],
},
],
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
// rules with type information
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': [
'error',
{
allowComparingNullableBooleansToTrue: false,
allowComparingNullableBooleansToFalse: false,
},
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': ['error'],
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
},
},
{
files: '*.test.ts',
rules: {
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-floating-promises': 'off',
},
},
],
};