eslint-config-vylda-typescript 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +12 -0
- package/.gitlab-ci.yml +13 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +6 -0
- package/Changelog.md +114 -0
- package/LICENSE +24 -0
- package/README.md +372 -0
- package/directory.mjs +3 -0
- package/empty.ts +0 -0
- package/eslint.config.mjs +81 -0
- package/index.d.ts +55 -0
- package/index.js +176 -0
- package/package.json +44 -0
- package/rules/defaultTs.mjs +654 -0
- package/rules/imports.mjs +119 -0
- package/rules/index.mjs +10 -0
- package/rules/off.mjs +64 -0
- package/rules/plus.mjs +22 -0
- package/rules/strictTs.mjs +115 -0
- package/rules/stylisticTs.mjs +495 -0
- package/rules/typescriptConfig.mjs +16 -0
- package/rules/vanillaConfig.mjs +26 -0
- package/rules/variablesTs.mjs +129 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { bestPractices } from 'eslint-config-vylda-vanilla';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} noMagicNumbersRuleOptions
|
|
6
|
+
* @property {number[]} [ignore]
|
|
7
|
+
* @property {boolean} [ignoreArrayIndexes]
|
|
8
|
+
* @property {boolean} [ignoreDefaultValues]
|
|
9
|
+
* @property {boolean} [ignoreClassFieldInitialValues]
|
|
10
|
+
* @property {boolean} [ignoreEnums]
|
|
11
|
+
* @property {boolean} [ignoreNumericLiteralTypes]
|
|
12
|
+
* @property {boolean} [ignoreReadonlyClassProperties]
|
|
13
|
+
* @property {boolean} [enforceConst]
|
|
14
|
+
* @property {boolean} [detectObjects]
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import('eslint').Linter.RuleSeverity} RuleSeverity
|
|
19
|
+
* @typedef {[RuleSeverity, noMagicNumbersRuleOptions]} noMagicNumbersRule
|
|
20
|
+
* @typedef {RuleSeverity | [RuleSeverity, ...any[]]} GenericRule
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const vanillaNoMagicNumbersRuleOptions = {
|
|
24
|
+
detectObjects: true,
|
|
25
|
+
enforceConst: true,
|
|
26
|
+
ignore: [-1, 0, 1],
|
|
27
|
+
ignoreArrayIndexes: true,
|
|
28
|
+
ignoreClassFieldInitialValues: false,
|
|
29
|
+
ignoreDefaultValues: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const tsNoMagicNumbersRuleOptions = {
|
|
33
|
+
ignoreEnums: true,
|
|
34
|
+
ignoreNumericLiteralTypes: true,
|
|
35
|
+
ignoreReadonlyClassProperties: true,
|
|
36
|
+
ignoreTypeIndexes: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Update no-magic-numbers rule to TS version
|
|
41
|
+
* @param {GenericRule} rule vanilla no-magic-numbers rule
|
|
42
|
+
* @returns {noMagicNumbersRule} typescript no-magic-numbers rule
|
|
43
|
+
*/
|
|
44
|
+
const updateNoMagicalNumbersRule = (rule) => {
|
|
45
|
+
if (!Array.isArray(rule)) {
|
|
46
|
+
return [
|
|
47
|
+
'error',
|
|
48
|
+
{
|
|
49
|
+
...vanillaNoMagicNumbersRuleOptions,
|
|
50
|
+
...tsNoMagicNumbersRuleOptions,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const [severity, options] = rule;
|
|
56
|
+
|
|
57
|
+
if (typeof options === 'string') {
|
|
58
|
+
return [
|
|
59
|
+
severity,
|
|
60
|
+
{
|
|
61
|
+
...vanillaNoMagicNumbersRuleOptions,
|
|
62
|
+
...tsNoMagicNumbersRuleOptions,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return [
|
|
68
|
+
severity,
|
|
69
|
+
{
|
|
70
|
+
...vanillaNoMagicNumbersRuleOptions,
|
|
71
|
+
...tsNoMagicNumbersRuleOptions,
|
|
72
|
+
...options,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {import('eslint').Linter.RuleEntry} acc
|
|
80
|
+
* @param {any} config
|
|
81
|
+
* @returns {import('eslint').Linter.RuleEntry}
|
|
82
|
+
*/
|
|
83
|
+
const noMagicNumbersRuleReducer = (acc, config) => {
|
|
84
|
+
const { rules } = config;
|
|
85
|
+
|
|
86
|
+
if (!rules) {
|
|
87
|
+
return acc;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const noMagicNumbersRule = rules['no-magic-numbers'];
|
|
91
|
+
|
|
92
|
+
if (!noMagicNumbersRule) {
|
|
93
|
+
return acc;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const updatedNoMagicalNumbersRule = updateNoMagicalNumbersRule(noMagicNumbersRule);
|
|
97
|
+
|
|
98
|
+
return updatedNoMagicalNumbersRule;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns typescript no-magical-numbers rule value;
|
|
103
|
+
* @returns {import('eslint').Linter.RuleEntry}
|
|
104
|
+
*/
|
|
105
|
+
const getUpdatedNoMagicalNumbersRule = () => {
|
|
106
|
+
/** @type {import('eslint').Linter.RuleEntry} */
|
|
107
|
+
const updatedRule = bestPractices.reduce(noMagicNumbersRuleReducer, 'off');
|
|
108
|
+
|
|
109
|
+
return updatedRule;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
113
|
+
const config = [
|
|
114
|
+
{
|
|
115
|
+
name: 'typescript-eslint/default-ts-rules',
|
|
116
|
+
|
|
117
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
118
|
+
rules: {
|
|
119
|
+
// Require that function overload signatures be consecutive.
|
|
120
|
+
// https://typescript-eslint.io/rules/adjacent-overload-signatures/
|
|
121
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
122
|
+
|
|
123
|
+
// Enforce consistent usage of array type notation.
|
|
124
|
+
// https://typescript-eslint.io/rules/array-type/
|
|
125
|
+
'@typescript-eslint/array-type': [
|
|
126
|
+
'error',
|
|
127
|
+
{
|
|
128
|
+
'default': 'generic',
|
|
129
|
+
readonly: 'generic',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
|
|
133
|
+
// Disallow `@ts-<directive>` comments or require descriptions after directives.
|
|
134
|
+
// https://typescript-eslint.io/rules/ban-ts-comment/
|
|
135
|
+
'@typescript-eslint/ban-ts-comment': 'error',
|
|
136
|
+
|
|
137
|
+
// Disallow `// tslint:<rule-flag>` comments.
|
|
138
|
+
// https://typescript-eslint.io/rules/ban-tslint-comment/
|
|
139
|
+
'@typescript-eslint/ban-tslint-comment': 'error',
|
|
140
|
+
|
|
141
|
+
// Enforce that literals on classes are exposed in a consistent style.
|
|
142
|
+
// https://typescript-eslint.io/rules/class-literal-property-style/
|
|
143
|
+
'@typescript-eslint/class-literal-property-style': ['error', 'fields'],
|
|
144
|
+
|
|
145
|
+
// Enforce that class methods utilize `this`.
|
|
146
|
+
// https://typescript-eslint.io/rules/class-methods-use-this/
|
|
147
|
+
'@typescript-eslint/class-methods-use-this': 'error',
|
|
148
|
+
|
|
149
|
+
// Enforce specifying generic type arguments on type annotation or constructor name of a constructor call.
|
|
150
|
+
// https://typescript-eslint.io/rules/consistent-generic-constructors/
|
|
151
|
+
'@typescript-eslint/consistent-generic-constructors': ['error', 'constructor'],
|
|
152
|
+
|
|
153
|
+
// Enforce consistent usage of index signature or `Record` type for indexed object types.
|
|
154
|
+
// https://typescript-eslint.io/rules/consistent-indexed-object-style/
|
|
155
|
+
'@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
|
|
156
|
+
|
|
157
|
+
// Require `return` statements to either always or never specify values.
|
|
158
|
+
// https://typescript-eslint.io/rules/consistent-return/
|
|
159
|
+
'@typescript-eslint/consistent-return': 'error',
|
|
160
|
+
|
|
161
|
+
// Enforce consistent usage of type assertions.
|
|
162
|
+
// https://typescript-eslint.io/rules/consistent-type-assertions/
|
|
163
|
+
'@typescript-eslint/consistent-type-assertions': 'error',
|
|
164
|
+
|
|
165
|
+
// Enforce type definitions to consistently use either `interface` or `type`.
|
|
166
|
+
// https://typescript-eslint.io/rules/consistent-type-definitions/
|
|
167
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
168
|
+
|
|
169
|
+
// Enforce consistent usage of type exports.
|
|
170
|
+
// https://typescript-eslint.io/rules/consistent-type-exports/
|
|
171
|
+
'@typescript-eslint/consistent-type-exports': 'error',
|
|
172
|
+
|
|
173
|
+
// Enforce consistent usage of type imports.
|
|
174
|
+
// https://typescript-eslint.io/rules/consistent-type-imports/
|
|
175
|
+
'@typescript-eslint/consistent-type-imports': ['error', {
|
|
176
|
+
disallowTypeAnnotations: true,
|
|
177
|
+
fixStyle: 'separate-type-imports',
|
|
178
|
+
prefer: 'type-imports',
|
|
179
|
+
}],
|
|
180
|
+
|
|
181
|
+
// Enforce default parameters to be last.
|
|
182
|
+
// https://typescript-eslint.io/rules/default-param-last/
|
|
183
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
184
|
+
|
|
185
|
+
// Enforce dot notation whenever possible.
|
|
186
|
+
// https://typescript-eslint.io/rules/dot-notation/
|
|
187
|
+
'@typescript-eslint/dot-notation': [
|
|
188
|
+
'error',
|
|
189
|
+
{
|
|
190
|
+
allowIndexSignaturePropertyAccess: false,
|
|
191
|
+
allowPrivateClassPropertyAccess: false,
|
|
192
|
+
allowProtectedClassPropertyAccess: false,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
|
|
196
|
+
// Require explicit return types on functions and class methods.
|
|
197
|
+
// https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
198
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
199
|
+
|
|
200
|
+
// Require explicit accessibility modifiers on class properties and methods.
|
|
201
|
+
// https://typescript-eslint.io/rules/explicit-member-accessibility/
|
|
202
|
+
'@typescript-eslint/explicit-member-accessibility': 'error',
|
|
203
|
+
|
|
204
|
+
// Require explicit return and argument types on exported functions' and classes' public class methods.
|
|
205
|
+
// https://typescript-eslint.io/rules/explicit-module-boundary-types/
|
|
206
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
207
|
+
|
|
208
|
+
// Require or disallow initialization in variable declarations.
|
|
209
|
+
// https://typescript-eslint.io/rules/init-declarations/
|
|
210
|
+
'@typescript-eslint/init-declarations': 'off',
|
|
211
|
+
|
|
212
|
+
// Enforce a maximum number of parameters in function definitions.
|
|
213
|
+
// https://typescript-eslint.io/rules/max-params/
|
|
214
|
+
'@typescript-eslint/max-params': 'off',
|
|
215
|
+
|
|
216
|
+
// Require a consistent member declaration order.
|
|
217
|
+
// https://typescript-eslint.io/rules/member-ordering/
|
|
218
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
219
|
+
|
|
220
|
+
// Enforce using a particular method signature syntax.
|
|
221
|
+
// https://typescript-eslint.io/rules/method-signature-style/
|
|
222
|
+
'@typescript-eslint/method-signature-style': ['error', 'property'],
|
|
223
|
+
|
|
224
|
+
// Enforce naming conventions for everything across a codebase.
|
|
225
|
+
// https://typescript-eslint.io/rules/naming-convention/
|
|
226
|
+
'@typescript-eslint/naming-convention': [
|
|
227
|
+
'error',
|
|
228
|
+
{
|
|
229
|
+
format: ['PascalCase'],
|
|
230
|
+
leadingUnderscore: 'forbid',
|
|
231
|
+
prefix: ['E'],
|
|
232
|
+
selector: 'enum',
|
|
233
|
+
trailingUnderscore: 'forbid',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
format: ['UPPER_CASE'],
|
|
237
|
+
leadingUnderscore: 'forbid',
|
|
238
|
+
selector: 'enumMember',
|
|
239
|
+
trailingUnderscore: 'forbid',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
format: ['PascalCase'],
|
|
243
|
+
leadingUnderscore: 'forbid',
|
|
244
|
+
prefix: ['I'],
|
|
245
|
+
selector: 'interface',
|
|
246
|
+
trailingUnderscore: 'forbid',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
format: ['PascalCase'],
|
|
250
|
+
leadingUnderscore: 'forbid',
|
|
251
|
+
prefix: ['T'],
|
|
252
|
+
selector: 'typeAlias',
|
|
253
|
+
trailingUnderscore: 'forbid',
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
format: ['PascalCase'],
|
|
257
|
+
leadingUnderscore: 'forbid',
|
|
258
|
+
selector: 'typeParameter',
|
|
259
|
+
trailingUnderscore: 'forbid',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
263
|
+
leadingUnderscore: 'forbid',
|
|
264
|
+
selector: 'variable',
|
|
265
|
+
trailingUnderscore: 'forbid',
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
|
|
269
|
+
// Disallow generic `Array` constructors.
|
|
270
|
+
// https://typescript-eslint.io/rules/no-array-constructor/
|
|
271
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
272
|
+
|
|
273
|
+
// Disallow non-null assertions using the `!` postfix operator in locations that may be confusing.
|
|
274
|
+
// https://typescript-eslint.io/rules/no-confusing-non-null-assertion/
|
|
275
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
|
276
|
+
|
|
277
|
+
// Require expressions of type void to appear in statement position.
|
|
278
|
+
// https://typescript-eslint.io/rules/no-confusing-void-expression/
|
|
279
|
+
'@typescript-eslint/no-confusing-void-expression': 'error',
|
|
280
|
+
|
|
281
|
+
// Disallow usage of deprecated APIs.
|
|
282
|
+
// https://typescript-eslint.io/rules/no-deprecated/
|
|
283
|
+
'@typescript-eslint/no-deprecated': 'warn',
|
|
284
|
+
|
|
285
|
+
// Disallow duplicate class members.
|
|
286
|
+
// https://typescript-eslint.io/rules/no-dupe-class-members/
|
|
287
|
+
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
288
|
+
|
|
289
|
+
// Disallow duplicate enum member values.
|
|
290
|
+
// https://typescript-eslint.io/rules/no-duplicate-enum-values/
|
|
291
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
292
|
+
|
|
293
|
+
// Disallow the use of the `delete` operator on computed key expressions.
|
|
294
|
+
// https://typescript-eslint.io/rules/no-dynamic-delete/
|
|
295
|
+
'@typescript-eslint/no-dynamic-delete': 'error',
|
|
296
|
+
|
|
297
|
+
// Disallow empty functions.
|
|
298
|
+
// https://typescript-eslint.io/rules/no-empty-function/
|
|
299
|
+
'@typescript-eslint/no-empty-function': [
|
|
300
|
+
'error',
|
|
301
|
+
{
|
|
302
|
+
allow: [],
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
|
|
306
|
+
// Disallow usage of the {} type (empty interfaces or object type literals)
|
|
307
|
+
// https://typescript-eslint.io/rules/no-empty-object-type
|
|
308
|
+
'@typescript-eslint/no-empty-object-type': [
|
|
309
|
+
'error',
|
|
310
|
+
{
|
|
311
|
+
allowInterfaces: 'never',
|
|
312
|
+
allowObjectTypes: 'never',
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
|
|
316
|
+
// Disallow the `any` type.
|
|
317
|
+
// https://typescript-eslint.io/rules/no-explicit-any/
|
|
318
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
319
|
+
|
|
320
|
+
// Disallow extra non-null assertions (e.g., using !!)
|
|
321
|
+
// https://typescript-eslint.io/rules/no-extra-non-null-assertion
|
|
322
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
323
|
+
|
|
324
|
+
// Disallow classes that are empty or only contain static members
|
|
325
|
+
// https://typescript-eslint.io/rules/no-extraneous-class
|
|
326
|
+
'@typescript-eslint/no-extraneous-class': [
|
|
327
|
+
'error',
|
|
328
|
+
{
|
|
329
|
+
allowConstructorOnly: false,
|
|
330
|
+
allowEmpty: false,
|
|
331
|
+
allowStaticOnly: false,
|
|
332
|
+
allowWithDecorator: false,
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
|
|
336
|
+
// Enforce using top-level type imports to avoid potential side effects
|
|
337
|
+
// https://typescript-eslint.io/rules/no-import-type-side-effects
|
|
338
|
+
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
339
|
+
|
|
340
|
+
// Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean
|
|
341
|
+
// https://typescript-eslint.io/rules/no-inferrable-types
|
|
342
|
+
'@typescript-eslint/no-inferrable-types': 'error',
|
|
343
|
+
|
|
344
|
+
// Disallow this keywords outside of classes or class-like objects
|
|
345
|
+
// https://typescript-eslint.io/rules/no-invalid-this
|
|
346
|
+
'@typescript-eslint/no-invalid-this': 'error',
|
|
347
|
+
|
|
348
|
+
// Disallow usage of void type outside of return types
|
|
349
|
+
// https://typescript-eslint.io/rules/no-invalid-void-type
|
|
350
|
+
'@typescript-eslint/no-invalid-void-type': [
|
|
351
|
+
'error',
|
|
352
|
+
{
|
|
353
|
+
allowAsThisParameter: false,
|
|
354
|
+
allowInGenericTypeArguments: true,
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
|
|
358
|
+
// Disallow function declarations that contain unsafe references inside loop statements
|
|
359
|
+
// https://typescript-eslint.io/rules/no-loop-func
|
|
360
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
361
|
+
|
|
362
|
+
// Disallow magic numbers
|
|
363
|
+
// https://typescript-eslint.io/rules/no-magic-numbers
|
|
364
|
+
'@typescript-eslint/no-magic-numbers': getUpdatedNoMagicalNumbersRule(),
|
|
365
|
+
|
|
366
|
+
// Disallow the void operator except when used to discard a value.
|
|
367
|
+
// https://typescript-eslint.io/rules/no-meaningless-void-operator/
|
|
368
|
+
'@typescript-eslint/no-meaningless-void-operator': [
|
|
369
|
+
'error',
|
|
370
|
+
{
|
|
371
|
+
checkNever: false,
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
|
|
375
|
+
// Enforce valid definition of `new` and `constructor`.
|
|
376
|
+
// https://typescript-eslint.io/rules/no-misused-new/
|
|
377
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
378
|
+
|
|
379
|
+
// Disallow using the spread operator when it might cause unexpected behavior.
|
|
380
|
+
// https://typescript-eslint.io/rules/no-misused-spread/
|
|
381
|
+
'@typescript-eslint/no-misused-spread': 'error',
|
|
382
|
+
|
|
383
|
+
// Disallow enums with mixed string and numeric members.
|
|
384
|
+
// https://typescript-eslint.io/rules/no-mixed-enums/
|
|
385
|
+
'@typescript-eslint/no-mixed-enums': 'error',
|
|
386
|
+
|
|
387
|
+
// Disallow TypeScript namespaces.
|
|
388
|
+
// https://typescript-eslint.io/rules/no-namespace/
|
|
389
|
+
'@typescript-eslint/no-namespace': [
|
|
390
|
+
'error',
|
|
391
|
+
{
|
|
392
|
+
allowDeclarations: false,
|
|
393
|
+
allowDefinitionFiles: true,
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
|
|
397
|
+
// Disallow non-null assertions in the left operand of a nullish coalescing operator.
|
|
398
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing/
|
|
399
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
|
400
|
+
|
|
401
|
+
// Disallow non-null assertions after an optional chain expression.
|
|
402
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain/
|
|
403
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
404
|
+
|
|
405
|
+
// Disallow non-null assertions using the `!` postfix operator.
|
|
406
|
+
// https://typescript-eslint.io/rules/no-non-null-assertion/
|
|
407
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
408
|
+
|
|
409
|
+
// Disallow variable redeclaration.
|
|
410
|
+
// https://eslint.org/docs/latest/rules/no-redeclare
|
|
411
|
+
'@typescript-eslint/no-redeclare': ['error', { builtinGlobals: true }],
|
|
412
|
+
|
|
413
|
+
// Disallow invocation of require().
|
|
414
|
+
// https://typescript-eslint.io/rules/no-require-imports
|
|
415
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
416
|
+
|
|
417
|
+
// Disallow specified modules when loaded by import.
|
|
418
|
+
// https://typescript-eslint.io/rules/no-restricted-imports
|
|
419
|
+
'@typescript-eslint/no-restricted-imports': 'error',
|
|
420
|
+
|
|
421
|
+
// Disallow specific types from being used.
|
|
422
|
+
// https://typescript-eslint.io/rules/no-restricted-types
|
|
423
|
+
'@typescript-eslint/no-restricted-types': 'error',
|
|
424
|
+
|
|
425
|
+
// Disallow variable declarations from shadowing variables declared in the outer scope.
|
|
426
|
+
// https://eslint.org/docs/latest/rules/no-shadow
|
|
427
|
+
'@typescript-eslint/no-shadow': ['error', { builtinGlobals: false }],
|
|
428
|
+
|
|
429
|
+
// Disallow aliasing this.
|
|
430
|
+
// https://typescript-eslint.io/rules/no-this-alias
|
|
431
|
+
'@typescript-eslint/no-this-alias': ['error', { allowedNames: [] }],
|
|
432
|
+
|
|
433
|
+
// Disallow unnecessary boolean literal comparisons.
|
|
434
|
+
// https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
435
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
|
436
|
+
|
|
437
|
+
// Disallow conditionals where the type is always truthy or always falsy.
|
|
438
|
+
// https://typescript-eslint.io/rules/no-unnecessary-condition
|
|
439
|
+
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
440
|
+
|
|
441
|
+
// Disallow unnecessary assignment of constructor property parameter.
|
|
442
|
+
// https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment/
|
|
443
|
+
'@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error',
|
|
444
|
+
|
|
445
|
+
// Disallow unnecessary namespace qualifiers.
|
|
446
|
+
// https://typescript-eslint.io/rules/no-unnecessary-qualifier
|
|
447
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
|
448
|
+
|
|
449
|
+
// Disallow unnecessary template expressions.
|
|
450
|
+
// https://typescript-eslint.io/rules/no-unnecessary-template-expression/
|
|
451
|
+
'@typescript-eslint/no-unnecessary-template-expression': 'error',
|
|
452
|
+
|
|
453
|
+
// Disallow type arguments that are equal to the default.
|
|
454
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-arguments/
|
|
455
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
|
456
|
+
|
|
457
|
+
// Disallow unnecessary constraints on generic types.
|
|
458
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-constraint/
|
|
459
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
460
|
+
|
|
461
|
+
// Disallow conversion idioms when they do not change the type or value of the expression.
|
|
462
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-conversion/
|
|
463
|
+
'@typescript-eslint/no-unnecessary-type-conversion': 'error',
|
|
464
|
+
|
|
465
|
+
// Disallow type parameters that aren't used multiple times.
|
|
466
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-parameters/
|
|
467
|
+
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
|
|
468
|
+
|
|
469
|
+
// Disallow unsafe declaration merging between classes and interfaces.
|
|
470
|
+
// https://typescript-eslint.io/rules/no-unsafe-declaration-merging/
|
|
471
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
472
|
+
|
|
473
|
+
// Disallow using the unsafe built-in Function type.
|
|
474
|
+
// https://typescript-eslint.io/rules/no-unsafe-function-type/
|
|
475
|
+
'@typescript-eslint/no-unsafe-function-type': 'error',
|
|
476
|
+
// Disallow type assertions that narrow a type.
|
|
477
|
+
// https://typescript-eslint.io/rules/no-unsafe-type-assertion/
|
|
478
|
+
'@typescript-eslint/no-unsafe-type-assertion': 'error',
|
|
479
|
+
|
|
480
|
+
// Disallow unused expressions which have no effect on the state of the program.
|
|
481
|
+
// https://typescript-eslint.io/rules/no-unused-expressions/
|
|
482
|
+
'@typescript-eslint/no-unused-expressions': 'error',
|
|
483
|
+
|
|
484
|
+
// Disallow unused variables.
|
|
485
|
+
// https://typescript-eslint.io/rules/no-unused-vars/
|
|
486
|
+
'@typescript-eslint/no-unused-vars': [
|
|
487
|
+
'error',
|
|
488
|
+
{
|
|
489
|
+
args: 'after-used',
|
|
490
|
+
ignoreRestSiblings: true,
|
|
491
|
+
vars: 'all',
|
|
492
|
+
},
|
|
493
|
+
],
|
|
494
|
+
|
|
495
|
+
// Disallow the use of variables before they are defined.
|
|
496
|
+
// https://typescript-eslint.io/rules/no-use-before-define/
|
|
497
|
+
'@typescript-eslint/no-use-before-define': [
|
|
498
|
+
'error',
|
|
499
|
+
{
|
|
500
|
+
classes: true,
|
|
501
|
+
enums: true,
|
|
502
|
+
functions: true,
|
|
503
|
+
ignoreTypeReferences: true,
|
|
504
|
+
typedefs: true,
|
|
505
|
+
variables: true,
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
|
|
509
|
+
// Disallow unnecessary constructors.
|
|
510
|
+
// https://typescript-eslint.io/rules/no-useless-constructor/
|
|
511
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
512
|
+
|
|
513
|
+
// Disallow empty exports that don't change anything in a module file.
|
|
514
|
+
// https://typescript-eslint.io/rules/no-useless-empty-export/
|
|
515
|
+
'@typescript-eslint/no-useless-empty-export': 'error',
|
|
516
|
+
|
|
517
|
+
// Disallow using confusing built-in primitive class wrappers.
|
|
518
|
+
// https://typescript-eslint.io/rules/no-wrapper-object-types/
|
|
519
|
+
'@typescript-eslint/no-wrapper-object-types': 'error',
|
|
520
|
+
|
|
521
|
+
// Enforce using `!` non-null assertion instead of `as` when asserting non-nullability.
|
|
522
|
+
// https://typescript-eslint.io/rules/non-nullable-type-assertion-style/
|
|
523
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
|
|
524
|
+
|
|
525
|
+
// Require or disallow parameter properties in class constructors.
|
|
526
|
+
// https://typescript-eslint.io/rules/parameter-properties/
|
|
527
|
+
'@typescript-eslint/parameter-properties': ['error', { prefer: 'class-property' }],
|
|
528
|
+
|
|
529
|
+
// Enforce the use of `as const` over literal type.
|
|
530
|
+
// https://typescript-eslint.io/rules/prefer-as-const/
|
|
531
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
532
|
+
|
|
533
|
+
// Require destructuring from arrays and/or objects.
|
|
534
|
+
// https://typescript-eslint.io/rules/prefer-destructuring/
|
|
535
|
+
'@typescript-eslint/prefer-destructuring': 'error',
|
|
536
|
+
|
|
537
|
+
// Require each enum member value to be explicitly initialized.
|
|
538
|
+
// https://typescript-eslint.io/rules/prefer-enum-initializers/
|
|
539
|
+
'@typescript-eslint/prefer-enum-initializers': 'error',
|
|
540
|
+
|
|
541
|
+
// Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result.
|
|
542
|
+
// https://typescript-eslint.io/rules/prefer-find/
|
|
543
|
+
'@typescript-eslint/prefer-find': 'error',
|
|
544
|
+
|
|
545
|
+
// Enforce the use of `for-of` loop over the standard `for` loop where possible.
|
|
546
|
+
// https://typescript-eslint.io/rules/prefer-for-of/
|
|
547
|
+
'@typescript-eslint/prefer-for-of': 'error',
|
|
548
|
+
// Enforce using function types instead of interfaces with call signatures.
|
|
549
|
+
// https://typescript-eslint.io/rules/prefer-function-type/
|
|
550
|
+
'@typescript-eslint/prefer-function-type': 'error',
|
|
551
|
+
|
|
552
|
+
// Enforce using `includes` method over `indexOf` comparisons.
|
|
553
|
+
// https://typescript-eslint.io/rules/prefer-includes/
|
|
554
|
+
'@typescript-eslint/prefer-includes': 'error',
|
|
555
|
+
|
|
556
|
+
// Require all enum members to be literal values.
|
|
557
|
+
// https://typescript-eslint.io/rules/prefer-literal-enum-member/
|
|
558
|
+
'@typescript-eslint/prefer-literal-enum-member': [
|
|
559
|
+
'error',
|
|
560
|
+
{
|
|
561
|
+
allowBitwiseExpressions: true,
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
|
|
565
|
+
// Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules.
|
|
566
|
+
// https://typescript-eslint.io/rules/prefer-namespace-keyword/
|
|
567
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
568
|
+
|
|
569
|
+
// Enforce using the nullish coalescing operator (`??`) instead of logical assignments or chaining.
|
|
570
|
+
// https://typescript-eslint.io/rules/prefer-nullish-coalescing/
|
|
571
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
572
|
+
|
|
573
|
+
// Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.
|
|
574
|
+
// https://typescript-eslint.io/rules/prefer-optional-chain/
|
|
575
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
576
|
+
|
|
577
|
+
// Enforces that private members are marked as readonly if they're never modified outside of the constructor.
|
|
578
|
+
// https://typescript-eslint.io/rules/prefer-readonly/
|
|
579
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
580
|
+
|
|
581
|
+
// Enforces that function parameters are typed as readonly to prevent unintended mutations.
|
|
582
|
+
// https://typescript-eslint.io/rules/prefer-readonly-parameter-types/
|
|
583
|
+
// Disabled due to unsuported Typescript type aliases and bad destructuralization detected
|
|
584
|
+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
585
|
+
|
|
586
|
+
// Enforce using type parameter when calling `Array#reduce` instead of using a type assertion.
|
|
587
|
+
// https://typescript-eslint.io/rules/prefer-reduce-type-parameter/
|
|
588
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
|
589
|
+
|
|
590
|
+
// Suggests using RegExp#exec over String#match when the global flag is not used.
|
|
591
|
+
// https://typescript-eslint.io/rules/prefer-regexp-exec/
|
|
592
|
+
'@typescript-eslint/prefer-regexp-exec': 'error',
|
|
593
|
+
|
|
594
|
+
// Enforces that class methods returning 'this' are correctly typed using 'this' instead of the class name.
|
|
595
|
+
// https://typescript-eslint.io/rules/prefer-return-this-type/
|
|
596
|
+
'@typescript-eslint/prefer-return-this-type': 'error',
|
|
597
|
+
|
|
598
|
+
// Suggests using String#startsWith and String#endsWith over other methods for readability.
|
|
599
|
+
// https://typescript-eslint.io/rules/prefer-string-starts-ends-with/
|
|
600
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
|
601
|
+
|
|
602
|
+
// Requires that functions returning a Promise are marked as async.
|
|
603
|
+
// https://typescript-eslint.io/rules/promise-function-async/
|
|
604
|
+
'@typescript-eslint/promise-function-async': 'error',
|
|
605
|
+
|
|
606
|
+
// Ensures that getter and setter pairs have compatible types.
|
|
607
|
+
// https://typescript-eslint.io/rules/related-getter-setter-pairs/
|
|
608
|
+
'@typescript-eslint/related-getter-setter-pairs': 'error',
|
|
609
|
+
|
|
610
|
+
// Requires that Array#sort calls provide a compareFunction.
|
|
611
|
+
// https://typescript-eslint.io/rules/require-array-sort-compare/
|
|
612
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
613
|
+
|
|
614
|
+
// Enforces consistent use of return await in functions.
|
|
615
|
+
// https://typescript-eslint.io/rules/return-await/
|
|
616
|
+
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
|
|
617
|
+
|
|
618
|
+
// Restricts the types allowed in boolean expressions to avoid unintended behavior.
|
|
619
|
+
// https://typescript-eslint.io/rules/strict-boolean-expressions/
|
|
620
|
+
'@typescript-eslint/strict-boolean-expressions': [
|
|
621
|
+
'error',
|
|
622
|
+
{
|
|
623
|
+
allowAny: false,
|
|
624
|
+
allowNullableBoolean: true,
|
|
625
|
+
allowNullableEnum: true,
|
|
626
|
+
allowNullableNumber: true,
|
|
627
|
+
allowNullableObject: true,
|
|
628
|
+
allowNullableString: true,
|
|
629
|
+
allowNumber: false,
|
|
630
|
+
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
631
|
+
allowString: true,
|
|
632
|
+
},
|
|
633
|
+
],
|
|
634
|
+
|
|
635
|
+
// Ensures that switch statements are exhaustive.
|
|
636
|
+
// https://typescript-eslint.io/rules/switch-exhaustiveness-check/
|
|
637
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
638
|
+
|
|
639
|
+
// Disallows triple-slash reference directives.
|
|
640
|
+
// https://typescript-eslint.io/rules/triple-slash-reference/
|
|
641
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
642
|
+
|
|
643
|
+
// Enforces that function overloads be unified into a single signature when possible.
|
|
644
|
+
// https://typescript-eslint.io/rules/unified-signatures/
|
|
645
|
+
'@typescript-eslint/unified-signatures': 'error',
|
|
646
|
+
|
|
647
|
+
// Enforces the use of `unknown` instead of `any` in catch clause variables.
|
|
648
|
+
// https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable/
|
|
649
|
+
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
];
|
|
653
|
+
|
|
654
|
+
export default config;
|