@abinnovision/eslint-config-base 3.0.0 → 3.0.1
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/CHANGELOG.md +7 -0
- package/dist/index.cjs +886 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +846 -0
- package/package.json +2 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
// src/configs/base.ts
|
|
2
|
+
import jseslint from "@eslint/js";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
import eslintPluginImport from "eslint-plugin-import";
|
|
5
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
6
|
+
import tseslint from "typescript-eslint";
|
|
7
|
+
var config = defineConfig([
|
|
8
|
+
{
|
|
9
|
+
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: "latest"
|
|
12
|
+
},
|
|
13
|
+
plugins: {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
15
|
+
import: eslintPluginImport,
|
|
16
|
+
uimports: unusedImports
|
|
17
|
+
},
|
|
18
|
+
extends: [
|
|
19
|
+
/**
|
|
20
|
+
* ESLint Recommended Rules
|
|
21
|
+
*
|
|
22
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
23
|
+
*/
|
|
24
|
+
jseslint.configs.recommended
|
|
25
|
+
],
|
|
26
|
+
rules: {
|
|
27
|
+
/**
|
|
28
|
+
* Enforce getter/setter pairs in objects and classes.
|
|
29
|
+
*
|
|
30
|
+
* @see https://eslint.org/docs/latest/rules/accessor-pairs
|
|
31
|
+
*/
|
|
32
|
+
"accessor-pairs": [
|
|
33
|
+
"error",
|
|
34
|
+
{ setWithoutGet: true, getWithoutSet: false }
|
|
35
|
+
],
|
|
36
|
+
/**
|
|
37
|
+
* Enforce return statements in callbacks of array methods.
|
|
38
|
+
*
|
|
39
|
+
* @see https://eslint.org/docs/latest/rules/array-callback-return
|
|
40
|
+
*/
|
|
41
|
+
"array-callback-return": "error",
|
|
42
|
+
/**
|
|
43
|
+
* Disallow Array constructor.
|
|
44
|
+
*
|
|
45
|
+
* @see https://eslint.org/docs/latest/rules/no-array-constructor
|
|
46
|
+
*/
|
|
47
|
+
"no-array-constructor": "error",
|
|
48
|
+
/**
|
|
49
|
+
* Disallow use of arguments.caller or arguments.callee.
|
|
50
|
+
*
|
|
51
|
+
* @see https://eslint.org/docs/latest/rules/no-caller
|
|
52
|
+
*/
|
|
53
|
+
"no-caller": "error",
|
|
54
|
+
/**
|
|
55
|
+
* Enforce default clauses in switch statements to be last.
|
|
56
|
+
*
|
|
57
|
+
* @see https://eslint.org/docs/latest/rules/default-case-last
|
|
58
|
+
*/
|
|
59
|
+
"default-case-last": "error",
|
|
60
|
+
/**
|
|
61
|
+
* Require === and !==.
|
|
62
|
+
*
|
|
63
|
+
* @see https://eslint.org/docs/latest/rules/eqeqeq
|
|
64
|
+
*/
|
|
65
|
+
eqeqeq: ["error", "always"],
|
|
66
|
+
/**
|
|
67
|
+
* Disallow eval().
|
|
68
|
+
*
|
|
69
|
+
* @see https://eslint.org/docs/latest/rules/no-eval
|
|
70
|
+
*/
|
|
71
|
+
"no-eval": "error",
|
|
72
|
+
/**
|
|
73
|
+
* Disallow extending native types.
|
|
74
|
+
*
|
|
75
|
+
* @see https://eslint.org/docs/latest/rules/no-extend-native
|
|
76
|
+
*/
|
|
77
|
+
"no-extend-native": "error",
|
|
78
|
+
/**
|
|
79
|
+
* Disallow unnecessary function binding.
|
|
80
|
+
*
|
|
81
|
+
* @see https://eslint.org/docs/latest/rules/no-extra-bind
|
|
82
|
+
*/
|
|
83
|
+
"no-extra-bind": "error",
|
|
84
|
+
/**
|
|
85
|
+
* Disallow leading or trailing decimal points in numeric literals.
|
|
86
|
+
*
|
|
87
|
+
* @see https://eslint.org/docs/latest/rules/no-floating-decimal
|
|
88
|
+
*/
|
|
89
|
+
"no-floating-decimal": "error",
|
|
90
|
+
/**
|
|
91
|
+
* Disallow assignment operators in return statements.
|
|
92
|
+
*
|
|
93
|
+
* @see https://eslint.org/docs/latest/rules/no-return-assign
|
|
94
|
+
*/
|
|
95
|
+
"no-return-assign": "error",
|
|
96
|
+
/**
|
|
97
|
+
* Disallow new operators outside of assignments or comparisons.
|
|
98
|
+
*
|
|
99
|
+
* @see https://eslint.org/docs/latest/rules/no-new
|
|
100
|
+
*/
|
|
101
|
+
"no-new": "error",
|
|
102
|
+
/**
|
|
103
|
+
* Disallow new operators with Function object.
|
|
104
|
+
*
|
|
105
|
+
* @see https://eslint.org/docs/latest/rules/no-new-func
|
|
106
|
+
*/
|
|
107
|
+
"no-new-func": "error",
|
|
108
|
+
/**
|
|
109
|
+
* Disallow new operators with Symbol object.
|
|
110
|
+
*
|
|
111
|
+
* @see https://eslint.org/docs/latest/rules/no-new-symbol
|
|
112
|
+
*/
|
|
113
|
+
"no-new-symbol": "error",
|
|
114
|
+
/**
|
|
115
|
+
* Disallow new operators with String, Number, and Boolean objects.
|
|
116
|
+
*
|
|
117
|
+
* @see https://eslint.org/docs/latest/rules/no-new-wrappers
|
|
118
|
+
*/
|
|
119
|
+
"no-new-wrappers": "error",
|
|
120
|
+
/**
|
|
121
|
+
* Disallow octal escape sequences in string literals.
|
|
122
|
+
*
|
|
123
|
+
* @see https://eslint.org/docs/latest/rules/no-octal-escape
|
|
124
|
+
*/
|
|
125
|
+
"no-octal-escape": "error",
|
|
126
|
+
/**
|
|
127
|
+
* Disallow variable redeclaration.
|
|
128
|
+
*
|
|
129
|
+
* @see https://eslint.org/docs/latest/rules/no-redeclare
|
|
130
|
+
*/
|
|
131
|
+
"no-redeclare": "error",
|
|
132
|
+
/**
|
|
133
|
+
* Disallow comparisons where both sides are exactly the same.
|
|
134
|
+
*
|
|
135
|
+
* @see https://eslint.org/docs/latest/rules/no-self-compare
|
|
136
|
+
*/
|
|
137
|
+
"no-self-compare": "error",
|
|
138
|
+
/**
|
|
139
|
+
* Disallow comma operators.
|
|
140
|
+
*
|
|
141
|
+
* @see https://eslint.org/docs/latest/rules/no-sequences
|
|
142
|
+
*/
|
|
143
|
+
"no-sequences": "error",
|
|
144
|
+
/**
|
|
145
|
+
* Disallow throwing literals as exceptions.
|
|
146
|
+
*
|
|
147
|
+
* @see https://eslint.org/docs/latest/rules/no-throw-literal
|
|
148
|
+
*/
|
|
149
|
+
"no-throw-literal": "error",
|
|
150
|
+
/**
|
|
151
|
+
* Disallow loops with a body that allows only one iteration.
|
|
152
|
+
*
|
|
153
|
+
* @see https://eslint.org/docs/latest/rules/no-unreachable-loop
|
|
154
|
+
*/
|
|
155
|
+
"no-unreachable-loop": "error",
|
|
156
|
+
/**
|
|
157
|
+
* Disallow redundant return statements.
|
|
158
|
+
*
|
|
159
|
+
* @see https://eslint.org/docs/latest/rules/no-useless-return
|
|
160
|
+
*/
|
|
161
|
+
"no-useless-return": "error",
|
|
162
|
+
/**
|
|
163
|
+
* Require var declarations be placed at the top of their scope.
|
|
164
|
+
*
|
|
165
|
+
* @see https://eslint.org/docs/latest/rules/vars-on-top
|
|
166
|
+
*/
|
|
167
|
+
"vars-on-top": "error",
|
|
168
|
+
/**
|
|
169
|
+
* Require let or const instead of var.
|
|
170
|
+
*
|
|
171
|
+
* @see https://eslint.org/docs/latest/rules/no-var
|
|
172
|
+
*/
|
|
173
|
+
"no-var": "error",
|
|
174
|
+
/**
|
|
175
|
+
* Require const declarations for variables that are never reassigned.
|
|
176
|
+
*
|
|
177
|
+
* @see https://eslint.org/docs/latest/rules/prefer-const
|
|
178
|
+
*/
|
|
179
|
+
"prefer-const": "error",
|
|
180
|
+
/**
|
|
181
|
+
* Require object spread over Object.assign.
|
|
182
|
+
*
|
|
183
|
+
* @see https://eslint.org/docs/latest/rules/prefer-object-spread
|
|
184
|
+
*/
|
|
185
|
+
"prefer-object-spread": "error",
|
|
186
|
+
/**
|
|
187
|
+
* Require rest parameters instead of arguments.
|
|
188
|
+
*
|
|
189
|
+
* @see https://eslint.org/docs/latest/rules/prefer-rest-params
|
|
190
|
+
*/
|
|
191
|
+
"prefer-rest-params": "error",
|
|
192
|
+
/**
|
|
193
|
+
* Require spread operators instead of .apply().
|
|
194
|
+
*
|
|
195
|
+
* @see https://eslint.org/docs/latest/rules/prefer-spread
|
|
196
|
+
*/
|
|
197
|
+
"prefer-spread": "error",
|
|
198
|
+
/**
|
|
199
|
+
* Custom JS Rules: Code Quality & Complexity
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* Enforce a maximum cyclomatic complexity allowed in a program.
|
|
203
|
+
*
|
|
204
|
+
* @see https://eslint.org/docs/latest/rules/complexity
|
|
205
|
+
*/
|
|
206
|
+
complexity: ["error", { max: 25 }],
|
|
207
|
+
/**
|
|
208
|
+
* Enforce a maximum depth that blocks can be nested.
|
|
209
|
+
*
|
|
210
|
+
* @see https://eslint.org/docs/latest/rules/max-depth
|
|
211
|
+
*/
|
|
212
|
+
"max-depth": ["error", 5],
|
|
213
|
+
/**
|
|
214
|
+
* Enforce a maximum depth that callbacks can be nested.
|
|
215
|
+
*
|
|
216
|
+
* @see https://eslint.org/docs/latest/rules/max-nested-callbacks
|
|
217
|
+
*/
|
|
218
|
+
"max-nested-callbacks": ["error", 3],
|
|
219
|
+
/**
|
|
220
|
+
* Enforce a maximum number of parameters in function definitions.
|
|
221
|
+
*
|
|
222
|
+
* @see https://eslint.org/docs/latest/rules/max-params
|
|
223
|
+
*/
|
|
224
|
+
"max-params": ["error", 3],
|
|
225
|
+
/**
|
|
226
|
+
* Require for-in loops to include an if statement.
|
|
227
|
+
*
|
|
228
|
+
* @see https://eslint.org/docs/latest/rules/guard-for-in
|
|
229
|
+
*/
|
|
230
|
+
"guard-for-in": "error",
|
|
231
|
+
/**
|
|
232
|
+
* Require grouped accessor pairs in object literals and classes.
|
|
233
|
+
*
|
|
234
|
+
* @see https://eslint.org/docs/latest/rules/grouped-accessor-pairs
|
|
235
|
+
*/
|
|
236
|
+
"grouped-accessor-pairs": "error",
|
|
237
|
+
/**
|
|
238
|
+
* Require constructor names to begin with a capital letter.
|
|
239
|
+
*
|
|
240
|
+
* @see https://eslint.org/docs/latest/rules/new-cap
|
|
241
|
+
*/
|
|
242
|
+
"new-cap": [
|
|
243
|
+
"error",
|
|
244
|
+
{
|
|
245
|
+
newIsCap: true,
|
|
246
|
+
capIsNew: false,
|
|
247
|
+
properties: true
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
/**
|
|
251
|
+
* Disallow returning value from constructor.
|
|
252
|
+
*
|
|
253
|
+
* @see https://eslint.org/docs/latest/rules/no-constructor-return
|
|
254
|
+
*/
|
|
255
|
+
"no-constructor-return": "error",
|
|
256
|
+
/**
|
|
257
|
+
* Disallow variable or function declarations in nested blocks.
|
|
258
|
+
*
|
|
259
|
+
* @see https://eslint.org/docs/latest/rules/no-inner-declarations
|
|
260
|
+
*/
|
|
261
|
+
"no-inner-declarations": "error",
|
|
262
|
+
/**
|
|
263
|
+
* Disallow mixed binary operators without parentheses.
|
|
264
|
+
*
|
|
265
|
+
* @see https://eslint.org/docs/latest/rules/no-mixed-operators
|
|
266
|
+
*/
|
|
267
|
+
"no-mixed-operators": "error",
|
|
268
|
+
/**
|
|
269
|
+
* Disallow the use of console.
|
|
270
|
+
*
|
|
271
|
+
* @see https://eslint.org/docs/latest/rules/no-console
|
|
272
|
+
*/
|
|
273
|
+
"no-console": "warn",
|
|
274
|
+
/**
|
|
275
|
+
* Custom Configuration Adjustments
|
|
276
|
+
* Override ESLint recommended rules where we want different behavior
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* Disallow assignment operators in conditional expressions except when enclosed in parentheses.
|
|
280
|
+
*
|
|
281
|
+
* @see https://eslint.org/docs/latest/rules/no-cond-assign
|
|
282
|
+
*/
|
|
283
|
+
"no-cond-assign": ["error", "except-parens"],
|
|
284
|
+
/**
|
|
285
|
+
* Disallow constant expressions in conditions except loops.
|
|
286
|
+
*
|
|
287
|
+
* @see https://eslint.org/docs/latest/rules/no-constant-condition
|
|
288
|
+
*/
|
|
289
|
+
"no-constant-condition": ["error", { checkLoops: false }],
|
|
290
|
+
/**
|
|
291
|
+
* Disallow empty block statements except catch blocks.
|
|
292
|
+
*
|
|
293
|
+
* @see https://eslint.org/docs/latest/rules/no-empty
|
|
294
|
+
*/
|
|
295
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
296
|
+
/**
|
|
297
|
+
* Import Ordering and Organization
|
|
298
|
+
* Enforces consistent import structure
|
|
299
|
+
*/
|
|
300
|
+
/**
|
|
301
|
+
* Enforce a convention in module import order.
|
|
302
|
+
*
|
|
303
|
+
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
|
|
304
|
+
*/
|
|
305
|
+
"import/order": [
|
|
306
|
+
"error",
|
|
307
|
+
{
|
|
308
|
+
groups: [
|
|
309
|
+
// Externals
|
|
310
|
+
["builtin", "external"],
|
|
311
|
+
// Internals
|
|
312
|
+
["internal", "unknown", "parent", "sibling", "index"],
|
|
313
|
+
// Types
|
|
314
|
+
["object", "type"]
|
|
315
|
+
],
|
|
316
|
+
"newlines-between": "always",
|
|
317
|
+
alphabetize: { order: "asc", caseInsensitive: true },
|
|
318
|
+
warnOnUnassignedImports: true
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
/**
|
|
322
|
+
* Require exports to be placed at the end of the file.
|
|
323
|
+
*
|
|
324
|
+
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/exports-last.md
|
|
325
|
+
*/
|
|
326
|
+
"import/exports-last": "warn",
|
|
327
|
+
/**
|
|
328
|
+
* Require imports to be placed before other statements.
|
|
329
|
+
*
|
|
330
|
+
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
|
|
331
|
+
*/
|
|
332
|
+
"import/first": "error",
|
|
333
|
+
/**
|
|
334
|
+
* Require a newline after import statements.
|
|
335
|
+
*
|
|
336
|
+
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
|
|
337
|
+
*/
|
|
338
|
+
"import/newline-after-import": "error",
|
|
339
|
+
/**
|
|
340
|
+
* Unused Imports Handling
|
|
341
|
+
* Uses unused-imports plugin for better detection
|
|
342
|
+
*/
|
|
343
|
+
/**
|
|
344
|
+
* Disables base no-unused-vars (replaced by unused-imports).
|
|
345
|
+
*/
|
|
346
|
+
"no-unused-vars": "off",
|
|
347
|
+
/**
|
|
348
|
+
* Disallow unused imports.
|
|
349
|
+
*
|
|
350
|
+
* @see https://github.com/sweepline/eslint-plugin-unused-imports
|
|
351
|
+
*/
|
|
352
|
+
"uimports/no-unused-imports": "error",
|
|
353
|
+
/**
|
|
354
|
+
* Disallow unused variables.
|
|
355
|
+
*
|
|
356
|
+
* @see https://github.com/sweepline/eslint-plugin-unused-imports
|
|
357
|
+
*/
|
|
358
|
+
"uimports/no-unused-vars": [
|
|
359
|
+
"warn",
|
|
360
|
+
{
|
|
361
|
+
vars: "all",
|
|
362
|
+
varsIgnorePattern: "^_",
|
|
363
|
+
args: "after-used",
|
|
364
|
+
argsIgnorePattern: "^_"
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
/**
|
|
371
|
+
* TypeScript-Specific Configuration
|
|
372
|
+
*/
|
|
373
|
+
files: ["**/*.{ts,tsx}"],
|
|
374
|
+
plugins: {
|
|
375
|
+
"@typescript-eslint": tseslint.plugin
|
|
376
|
+
},
|
|
377
|
+
languageOptions: {
|
|
378
|
+
parser: tseslint.parser,
|
|
379
|
+
parserOptions: {
|
|
380
|
+
project: "./tsconfig.json"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
extends: [
|
|
384
|
+
/**
|
|
385
|
+
* TypeScript ESLint Recommended Rules
|
|
386
|
+
*
|
|
387
|
+
* @see https://typescript-eslint.io/rules
|
|
388
|
+
*/
|
|
389
|
+
tseslint.configs.strictTypeChecked
|
|
390
|
+
],
|
|
391
|
+
rules: {
|
|
392
|
+
/**
|
|
393
|
+
* Allow explicit any for flexibility.
|
|
394
|
+
*
|
|
395
|
+
* @see https://typescript-eslint.io/rules/no-explicit-any
|
|
396
|
+
*/
|
|
397
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
398
|
+
/**
|
|
399
|
+
* Allow non-null assertions.
|
|
400
|
+
*
|
|
401
|
+
* @see https://typescript-eslint.io/rules/no-non-null-assertion
|
|
402
|
+
*/
|
|
403
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
404
|
+
/**
|
|
405
|
+
* Require Promise-like statements to be handled appropriately.
|
|
406
|
+
*
|
|
407
|
+
* @see https://typescript-eslint.io/rules/no-floating-promises
|
|
408
|
+
*/
|
|
409
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
410
|
+
/**
|
|
411
|
+
* Require explicit accessibility modifiers on class properties and methods.
|
|
412
|
+
*
|
|
413
|
+
* @see https://typescript-eslint.io/rules/explicit-member-accessibility
|
|
414
|
+
*/
|
|
415
|
+
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
416
|
+
/**
|
|
417
|
+
* Require a consistent member declaration order.
|
|
418
|
+
*
|
|
419
|
+
* @see https://typescript-eslint.io/rules/member-ordering
|
|
420
|
+
*/
|
|
421
|
+
"@typescript-eslint/member-ordering": [
|
|
422
|
+
"error",
|
|
423
|
+
{
|
|
424
|
+
default: [
|
|
425
|
+
// Fields
|
|
426
|
+
"public-static-field",
|
|
427
|
+
"protected-static-field",
|
|
428
|
+
"private-static-field",
|
|
429
|
+
"public-instance-field",
|
|
430
|
+
"protected-instance-field",
|
|
431
|
+
"private-instance-field",
|
|
432
|
+
// Constructors
|
|
433
|
+
"public-constructor",
|
|
434
|
+
"protected-constructor",
|
|
435
|
+
"private-constructor",
|
|
436
|
+
// Methods
|
|
437
|
+
"public-static-method",
|
|
438
|
+
"protected-static-method",
|
|
439
|
+
"private-static-method",
|
|
440
|
+
"public-instance-method",
|
|
441
|
+
"protected-instance-method",
|
|
442
|
+
"private-instance-method"
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
],
|
|
446
|
+
/**
|
|
447
|
+
* Enforce using a particular method signature syntax.
|
|
448
|
+
*
|
|
449
|
+
* @see https://typescript-eslint.io/rules/method-signature-style
|
|
450
|
+
*/
|
|
451
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
452
|
+
/**
|
|
453
|
+
* Enforce consistent usage of type assertions.
|
|
454
|
+
*
|
|
455
|
+
* @see https://typescript-eslint.io/rules/consistent-type-assertions
|
|
456
|
+
*/
|
|
457
|
+
"@typescript-eslint/consistent-type-assertions": [
|
|
458
|
+
"error",
|
|
459
|
+
{
|
|
460
|
+
assertionStyle: "as",
|
|
461
|
+
objectLiteralTypeAssertions: "never"
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
/**
|
|
465
|
+
* Enforce type definitions to consistently use interface or type.
|
|
466
|
+
*
|
|
467
|
+
* @see https://typescript-eslint.io/rules/consistent-type-definitions
|
|
468
|
+
*/
|
|
469
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
470
|
+
/**
|
|
471
|
+
* Enforce consistent usage of type imports.
|
|
472
|
+
*
|
|
473
|
+
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
|
474
|
+
*/
|
|
475
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
476
|
+
/**
|
|
477
|
+
* Disallow type imports with side effects.
|
|
478
|
+
*
|
|
479
|
+
* @see https://typescript-eslint.io/rules/no-import-type-side-effects
|
|
480
|
+
*/
|
|
481
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
482
|
+
/**
|
|
483
|
+
* Require using for-of loops instead of standard for loops over arrays.
|
|
484
|
+
*
|
|
485
|
+
* @see https://typescript-eslint.io/rules/prefer-for-of
|
|
486
|
+
*/
|
|
487
|
+
"@typescript-eslint/prefer-for-of": "warn",
|
|
488
|
+
/**
|
|
489
|
+
* Require using function types instead of interfaces with call signatures.
|
|
490
|
+
*
|
|
491
|
+
* @see https://typescript-eslint.io/rules/prefer-function-type
|
|
492
|
+
*/
|
|
493
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
494
|
+
/**
|
|
495
|
+
* Custom Overrides for TypeScript Rules
|
|
496
|
+
*/
|
|
497
|
+
/**
|
|
498
|
+
* Disallow TypeScript namespaces except in declarations and definition files.
|
|
499
|
+
*
|
|
500
|
+
* @see https://typescript-eslint.io/rules/no-namespace
|
|
501
|
+
*/
|
|
502
|
+
"@typescript-eslint/no-namespace": [
|
|
503
|
+
"error",
|
|
504
|
+
{
|
|
505
|
+
allowDeclarations: true,
|
|
506
|
+
allowDefinitionFiles: true
|
|
507
|
+
}
|
|
508
|
+
],
|
|
509
|
+
/**
|
|
510
|
+
* Require awaiting a value before returning it from an async function.
|
|
511
|
+
*
|
|
512
|
+
* @see https://typescript-eslint.io/rules/return-await
|
|
513
|
+
*/
|
|
514
|
+
"@typescript-eslint/return-await": ["warn", "always"],
|
|
515
|
+
/**
|
|
516
|
+
* Disable TypeScript no-unused-vars (using unused-imports plugin).
|
|
517
|
+
*/
|
|
518
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
519
|
+
/**
|
|
520
|
+
* Disallow classes used as namespaces except when used with decorators.
|
|
521
|
+
*
|
|
522
|
+
* @see https://typescript-eslint.io/rules/no-extraneous-class
|
|
523
|
+
*/
|
|
524
|
+
"@typescript-eslint/no-extraneous-class": [
|
|
525
|
+
"error",
|
|
526
|
+
{
|
|
527
|
+
allowWithDecorator: true
|
|
528
|
+
}
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
]);
|
|
533
|
+
|
|
534
|
+
// src/configs/flavour-config-files.ts
|
|
535
|
+
import { defineConfig as defineConfig2 } from "eslint/config";
|
|
536
|
+
import globals from "globals";
|
|
537
|
+
var config2 = defineConfig2([
|
|
538
|
+
{
|
|
539
|
+
languageOptions: {
|
|
540
|
+
globals: {
|
|
541
|
+
...globals.node
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
rules: {
|
|
545
|
+
/**
|
|
546
|
+
* Disallow the use of console.
|
|
547
|
+
* Disabled for config files that often log build information.
|
|
548
|
+
*
|
|
549
|
+
* @see https://eslint.org/docs/latest/rules/no-console
|
|
550
|
+
*/
|
|
551
|
+
"no-console": "off",
|
|
552
|
+
/**
|
|
553
|
+
* Enforce a maximum number of lines per function.
|
|
554
|
+
* Disabled for complex build configurations.
|
|
555
|
+
*
|
|
556
|
+
* @see https://eslint.org/docs/latest/rules/max-lines-per-function
|
|
557
|
+
*/
|
|
558
|
+
"max-lines-per-function": "off",
|
|
559
|
+
/**
|
|
560
|
+
* Disallow require statements except in import statements.
|
|
561
|
+
* Disabled for CommonJS config files.
|
|
562
|
+
*
|
|
563
|
+
* @see https://typescript-eslint.io/rules/no-var-requires
|
|
564
|
+
*/
|
|
565
|
+
"@typescript-eslint/no-var-requires": "off"
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
]);
|
|
569
|
+
|
|
570
|
+
// src/configs/flavour-nestjs.ts
|
|
571
|
+
import { defineConfig as defineConfig3 } from "eslint/config";
|
|
572
|
+
var config3 = defineConfig3([
|
|
573
|
+
{
|
|
574
|
+
files: ["**/*.{ts,js}"],
|
|
575
|
+
rules: {
|
|
576
|
+
/**
|
|
577
|
+
* Enforce a maximum number of parameters in function definitions.
|
|
578
|
+
* Increased to 8 for NestJS dependency injection patterns.
|
|
579
|
+
*
|
|
580
|
+
* @see https://eslint.org/docs/latest/rules/max-params
|
|
581
|
+
*/
|
|
582
|
+
"max-params": ["error", 8],
|
|
583
|
+
/**
|
|
584
|
+
* Disallow useless constructors.
|
|
585
|
+
* Disabled for NestJS as DI decorators make constructors appear "useless".
|
|
586
|
+
*
|
|
587
|
+
* @see https://typescript-eslint.io/rules/no-useless-constructor
|
|
588
|
+
*/
|
|
589
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
590
|
+
/**
|
|
591
|
+
* Disallow empty functions.
|
|
592
|
+
* Allow empty constructors for NestJS DI parameter properties.
|
|
593
|
+
*
|
|
594
|
+
* @see https://typescript-eslint.io/rules/no-empty-function
|
|
595
|
+
*/
|
|
596
|
+
"@typescript-eslint/no-empty-function": [
|
|
597
|
+
"error",
|
|
598
|
+
{ allow: ["constructors"] }
|
|
599
|
+
],
|
|
600
|
+
/**
|
|
601
|
+
* Require or disallow parameter properties in class constructors.
|
|
602
|
+
* Enforces NestJS DI pattern using parameter properties.
|
|
603
|
+
*
|
|
604
|
+
* @see https://typescript-eslint.io/rules/parameter-properties
|
|
605
|
+
*/
|
|
606
|
+
"@typescript-eslint/parameter-properties": [
|
|
607
|
+
"error",
|
|
608
|
+
{
|
|
609
|
+
allow: [
|
|
610
|
+
"private readonly",
|
|
611
|
+
"protected readonly",
|
|
612
|
+
"public readonly",
|
|
613
|
+
"private",
|
|
614
|
+
"protected",
|
|
615
|
+
"public"
|
|
616
|
+
],
|
|
617
|
+
prefer: "parameter-property"
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
]);
|
|
623
|
+
|
|
624
|
+
// src/configs/flavour-vitest.ts
|
|
625
|
+
import vitest from "@vitest/eslint-plugin";
|
|
626
|
+
import { defineConfig as defineConfig4 } from "eslint/config";
|
|
627
|
+
var config4 = defineConfig4([
|
|
628
|
+
{
|
|
629
|
+
files: [
|
|
630
|
+
"**/*.test.{ts,tsx,js,jsx}",
|
|
631
|
+
"**/*.spec.{ts,tsx,js,jsx}",
|
|
632
|
+
"**/__tests__/**/*.{ts,tsx,js,jsx}"
|
|
633
|
+
],
|
|
634
|
+
plugins: {
|
|
635
|
+
vitest
|
|
636
|
+
},
|
|
637
|
+
languageOptions: {
|
|
638
|
+
globals: {
|
|
639
|
+
...vitest.environments.env.globals
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
settings: {
|
|
643
|
+
vitest: {
|
|
644
|
+
typecheck: true
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
rules: {
|
|
648
|
+
/**
|
|
649
|
+
* Enable Vitest recommended rules.
|
|
650
|
+
*/
|
|
651
|
+
...vitest.configs.recommended.rules,
|
|
652
|
+
/**
|
|
653
|
+
* Enforce a maximum number of parameters in function definitions.
|
|
654
|
+
* Increased to 5 for test setup functions that receive fixtures and mocks.
|
|
655
|
+
*
|
|
656
|
+
* @see https://eslint.org/docs/latest/rules/max-params
|
|
657
|
+
*/
|
|
658
|
+
"max-params": ["error", 5],
|
|
659
|
+
/**
|
|
660
|
+
* Enforce a maximum depth that callbacks can be nested.
|
|
661
|
+
* Increased to 5 for describe/it/beforeEach nesting patterns.
|
|
662
|
+
*
|
|
663
|
+
* @see https://eslint.org/docs/latest/rules/max-nested-callbacks
|
|
664
|
+
*/
|
|
665
|
+
"max-nested-callbacks": ["error", 5],
|
|
666
|
+
/**
|
|
667
|
+
* Enforce a maximum cyclomatic complexity allowed in a program.
|
|
668
|
+
* Increased to 30 and downgraded to warn for complex test scenarios.
|
|
669
|
+
*
|
|
670
|
+
* @see https://eslint.org/docs/latest/rules/complexity
|
|
671
|
+
*/
|
|
672
|
+
complexity: ["warn", 30],
|
|
673
|
+
/**
|
|
674
|
+
* Enforce a maximum number of lines per function.
|
|
675
|
+
* Disabled for test cases with comprehensive setup and assertions.
|
|
676
|
+
*
|
|
677
|
+
* @see https://eslint.org/docs/latest/rules/max-lines-per-function
|
|
678
|
+
*/
|
|
679
|
+
"max-lines-per-function": "off",
|
|
680
|
+
/**
|
|
681
|
+
* Enforce a maximum number of statements allowed in function blocks.
|
|
682
|
+
* Disabled for tests with multiple setup and assertion statements.
|
|
683
|
+
*
|
|
684
|
+
* @see https://eslint.org/docs/latest/rules/max-statements
|
|
685
|
+
*/
|
|
686
|
+
"max-statements": "off",
|
|
687
|
+
/**
|
|
688
|
+
* Enforce a maximum number of lines per file.
|
|
689
|
+
* Disabled for comprehensive test suites.
|
|
690
|
+
*
|
|
691
|
+
* @see https://eslint.org/docs/latest/rules/max-lines
|
|
692
|
+
*/
|
|
693
|
+
"max-lines": "off",
|
|
694
|
+
/**
|
|
695
|
+
* Disallow assigning a value with type any to variables and properties.
|
|
696
|
+
* Disabled for mock objects and test utilities.
|
|
697
|
+
*
|
|
698
|
+
* @see https://typescript-eslint.io/rules/no-unsafe-assignment
|
|
699
|
+
*/
|
|
700
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
701
|
+
/**
|
|
702
|
+
* Disallow member access on a value with type any.
|
|
703
|
+
* Disabled for mock objects.
|
|
704
|
+
*
|
|
705
|
+
* @see https://typescript-eslint.io/rules/no-unsafe-member-access
|
|
706
|
+
*/
|
|
707
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
708
|
+
/**
|
|
709
|
+
* Disallow calling a value with type any.
|
|
710
|
+
* Disabled for test utilities like vi.fn().
|
|
711
|
+
*
|
|
712
|
+
* @see https://typescript-eslint.io/rules/no-unsafe-call
|
|
713
|
+
*/
|
|
714
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
715
|
+
/**
|
|
716
|
+
* Disallow returning a value with type any from a function.
|
|
717
|
+
* Disabled for test helper functions.
|
|
718
|
+
*
|
|
719
|
+
* @see https://typescript-eslint.io/rules/no-unsafe-return
|
|
720
|
+
*/
|
|
721
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
722
|
+
/**
|
|
723
|
+
* Disallow passing a value with type any to a function parameter.
|
|
724
|
+
* Disabled for test mock parameters.
|
|
725
|
+
*
|
|
726
|
+
* @see https://typescript-eslint.io/rules/no-unsafe-argument
|
|
727
|
+
*/
|
|
728
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
729
|
+
/**
|
|
730
|
+
* Require unbound methods to be called with correct this context.
|
|
731
|
+
* Disabled for Vitest expectations like expect(obj.method).toBeCalled().
|
|
732
|
+
*
|
|
733
|
+
* @see https://typescript-eslint.io/rules/unbound-method
|
|
734
|
+
*/
|
|
735
|
+
"@typescript-eslint/unbound-method": "off",
|
|
736
|
+
/**
|
|
737
|
+
* Disallow magic numbers.
|
|
738
|
+
* Disabled for test assertions with literal values.
|
|
739
|
+
*
|
|
740
|
+
* @see https://typescript-eslint.io/rules/no-magic-numbers
|
|
741
|
+
*/
|
|
742
|
+
"@typescript-eslint/no-magic-numbers": "off",
|
|
743
|
+
/**
|
|
744
|
+
* Require Promise-like statements to be handled appropriately.
|
|
745
|
+
* Downgraded to warn for test utilities.
|
|
746
|
+
*
|
|
747
|
+
* @see https://typescript-eslint.io/rules/no-floating-promises
|
|
748
|
+
*/
|
|
749
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
750
|
+
/**
|
|
751
|
+
* Disallow non-null assertions using the ! postfix operator.
|
|
752
|
+
* Disabled for tests where values are known to exist.
|
|
753
|
+
*
|
|
754
|
+
* @see https://typescript-eslint.io/rules/no-non-null-assertion
|
|
755
|
+
*/
|
|
756
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
757
|
+
/**
|
|
758
|
+
* Disallow empty functions.
|
|
759
|
+
* Disabled for test stubs and spies.
|
|
760
|
+
*
|
|
761
|
+
* @see https://eslint.org/docs/latest/rules/no-empty-function
|
|
762
|
+
*/
|
|
763
|
+
"no-empty-function": "off",
|
|
764
|
+
/**
|
|
765
|
+
* Disallow empty functions.
|
|
766
|
+
* Disabled for test stubs and spies.
|
|
767
|
+
*
|
|
768
|
+
* @see https://typescript-eslint.io/rules/no-empty-function
|
|
769
|
+
*/
|
|
770
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
771
|
+
/**
|
|
772
|
+
* Disallow magic numbers.
|
|
773
|
+
* Disabled for test assertions.
|
|
774
|
+
*
|
|
775
|
+
* @see https://eslint.org/docs/latest/rules/no-magic-numbers
|
|
776
|
+
*/
|
|
777
|
+
"no-magic-numbers": "off",
|
|
778
|
+
/**
|
|
779
|
+
* Disallow the use of console.
|
|
780
|
+
* Disabled for test debugging.
|
|
781
|
+
*
|
|
782
|
+
* @see https://eslint.org/docs/latest/rules/no-console
|
|
783
|
+
*/
|
|
784
|
+
"no-console": "off",
|
|
785
|
+
/**
|
|
786
|
+
* Disallow focused tests.
|
|
787
|
+
* Prevents .only from being committed.
|
|
788
|
+
*
|
|
789
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
|
|
790
|
+
*/
|
|
791
|
+
"vitest/no-focused-tests": "error",
|
|
792
|
+
/**
|
|
793
|
+
* Disallow disabled tests.
|
|
794
|
+
* Warns about .skip usage.
|
|
795
|
+
*
|
|
796
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
|
797
|
+
*/
|
|
798
|
+
"vitest/no-disabled-tests": "warn",
|
|
799
|
+
/**
|
|
800
|
+
* Enforce lowercase test names.
|
|
801
|
+
* Consistent test naming convention.
|
|
802
|
+
*
|
|
803
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
|
|
804
|
+
*/
|
|
805
|
+
"vitest/prefer-lowercase-title": "warn",
|
|
806
|
+
/**
|
|
807
|
+
* Enforce a maximum depth for nested describe calls.
|
|
808
|
+
*
|
|
809
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
|
|
810
|
+
*/
|
|
811
|
+
"vitest/max-nested-describe": ["error", { max: 5 }],
|
|
812
|
+
/**
|
|
813
|
+
* Disallow conditional logic in tests.
|
|
814
|
+
* Tests should be deterministic.
|
|
815
|
+
*
|
|
816
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|
817
|
+
*/
|
|
818
|
+
"vitest/no-conditional-in-test": "error",
|
|
819
|
+
/**
|
|
820
|
+
* Disallow conditional expects.
|
|
821
|
+
* Expectations should not be inside conditionals.
|
|
822
|
+
*
|
|
823
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
824
|
+
*/
|
|
825
|
+
"vitest/no-conditional-expect": "error",
|
|
826
|
+
/**
|
|
827
|
+
* Enforce consistent hook ordering.
|
|
828
|
+
*
|
|
829
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
830
|
+
*/
|
|
831
|
+
"vitest/prefer-hooks-in-order": "warn",
|
|
832
|
+
/**
|
|
833
|
+
* Prefer vi.spyOn over manual mocks.
|
|
834
|
+
*
|
|
835
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
|
836
|
+
*/
|
|
837
|
+
"vitest/prefer-spy-on": "warn"
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
]);
|
|
841
|
+
export {
|
|
842
|
+
config as base,
|
|
843
|
+
config2 as configFiles,
|
|
844
|
+
config3 as nestjs,
|
|
845
|
+
config4 as vitest
|
|
846
|
+
};
|