@viclafouch/eslint-config-viclafouch 4.22.1-beta.4 → 4.22.1-beta.6

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.
@@ -1,25 +1,41 @@
1
+ import { defineConfig } from 'eslint/config'
2
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn'
3
+ import pluginPromise from 'eslint-plugin-promise'
4
+ import globals from 'globals'
1
5
  import tseslint from 'typescript-eslint'
2
- import bestPracticesConfig from './best-practices.mjs'
3
- import es6Config from './es6.mjs'
4
- import variablesConfig from './variables.mjs'
5
-
6
- const { rules: baseBestPracticesRules } = bestPracticesConfig
7
- const { rules: baseVariablesRules } = variablesConfig
8
- const { rules: baseES6Rules } = es6Config
9
6
 
10
7
  /**
11
8
  * @type {import("eslint").Linter.Config}
12
9
  */
13
- export default tseslint.config(
10
+ export default defineConfig(
14
11
  tseslint.configs.recommended,
15
12
  {
16
- name: 'typescript',
13
+ name: 'typescript/setup',
14
+ files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
15
+ linterOptions: {
16
+ reportUnusedDisableDirectives: 'error'
17
+ },
17
18
  languageOptions: {
19
+ globals: {
20
+ ...globals.builtin,
21
+ ...globals.browser,
22
+ ...globals.node,
23
+ ...globals.vitest
24
+ },
18
25
  parserOptions: {
19
26
  projectService: {
20
- allowDefaultProject: ['*.js', '*.mjs', '*.cjs']
27
+ allowDefaultProject: ['*.js', '*.cjs']
28
+ },
29
+ ecmaFeatures: {
30
+ jsx: true
21
31
  }
22
- }
32
+ },
33
+ ecmaVersion: 'latest',
34
+ sourceType: 'module'
35
+ },
36
+ plugins: {
37
+ unicorn: eslintPluginUnicorn,
38
+ promise: pluginPromise
23
39
  },
24
40
  settings: {
25
41
  // Apply special parsing for TypeScript files
@@ -27,83 +43,961 @@ export default tseslint.config(
27
43
  '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts']
28
44
  },
29
45
  // Append 'ts' extensions to @viclafouch/eslint 'import/resolver' setting
30
- // Original: ['.mjs', '.js', '.json']
31
46
  'import/resolver': {
32
47
  node: {
33
48
  extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts']
34
49
  }
35
50
  },
36
51
  // Append 'ts' extensions to @viclafouch/eslint 'import/extensions' setting
37
- // Original: ['.js', '.mjs', '.jsx']
38
52
  'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
39
53
  // Resolve type definition packages
40
54
  'import/external-module-folders': ['node_modules', 'node_modules/@types']
41
- },
55
+ }
56
+ },
57
+ {
58
+ name: 'typescript/rules',
59
+ files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
42
60
  rules: {
43
- // Replace @viclafouch/eslint 'default-param-last' rule with '@typescript-eslint' version
44
- // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/default-param-last.md
61
+ // ==========================================
62
+ // Best Practices
63
+ // ==========================================
64
+
65
+ // Enforces getter/setter pairs in objects
66
+ // https://eslint.org/docs/rules/accessor-pairs
67
+ 'accessor-pairs': 'off',
68
+
69
+ // Force curly everytime
70
+ // https://eslint.org/docs/rules/curly
71
+ curly: ['error', 'all'],
72
+
73
+ // Enforces return statements in callbacks of array's methods
74
+ // https://eslint.org/docs/rules/array-callback-return
75
+ 'array-callback-return': [
76
+ 'error',
77
+ { allowImplicit: true, checkForEach: true }
78
+ ],
79
+
80
+ // Enforce for loop update clause moving the counter in the right direction
81
+ // https://eslint.org/docs/latest/rules/for-direction
82
+ 'for-direction': 'error',
83
+
84
+ // Enforce return statements in getters
85
+ // https://eslint.org/docs/latest/rules/getter-return
86
+ 'getter-return': 'error',
87
+
88
+ // Disallow returning values from setters
89
+ // https://eslint.org/docs/latest/rules/no-setter-return
90
+ 'no-setter-return': 'error',
91
+
92
+ // Treat var statements as if they were block scoped
93
+ // https://eslint.org/docs/rules/block-scoped-var
94
+ 'block-scoped-var': 'error',
95
+
96
+ // Specify the maximum cyclomatic complexity allowed in a program
97
+ // https://eslint.org/docs/rules/complexity
98
+ complexity: ['error', 20],
99
+
100
+ // Disallow nested ternary expressions
101
+ // https://eslint.org/docs/latest/rules/no-nested-ternary
102
+ 'no-nested-ternary': 'error',
103
+
104
+ // Enforce a maximum number of parameters in function definitions
105
+ // https://eslint.org/docs/latest/rules/max-params
106
+ 'max-params': ['error', { max: 3 }],
107
+
108
+ // Enforce a maximum depth of nested blocks
109
+ // https://eslint.org/docs/latest/rules/max-depth
110
+ 'max-depth': ['error', { max: 3 }],
111
+
112
+ // Enforce a maximum number of lines per function
113
+ // https://eslint.org/docs/latest/rules/max-lines-per-function
114
+ 'max-lines-per-function': [
115
+ 'error',
116
+ { max: 100, skipBlankLines: true, skipComments: true }
117
+ ],
118
+
119
+ // Enforce that class methods use "this"
120
+ // https://eslint.org/docs/rules/class-methods-use-this
121
+ 'class-methods-use-this': [
122
+ 'error',
123
+ {
124
+ exceptMethods: []
125
+ }
126
+ ],
127
+
128
+ // Require return statements to either always or never specify values
129
+ // https://eslint.org/docs/rules/consistent-return
130
+ 'consistent-return': ['error', { treatUndefinedAsUnspecified: true }],
131
+
132
+ // Disallow comparing against -0
133
+ // https://eslint.org/docs/latest/rules/no-compare-neg-zero
134
+ 'no-compare-neg-zero': 'error',
135
+
136
+ // Disallow sparse arrays
137
+ // https://eslint.org/docs/latest/rules/no-sparse-arrays
138
+ 'no-sparse-arrays': 'error',
139
+
140
+ // Disallow expressions where the operation doesn't affect the value
141
+ // https://eslint.org/docs/latest/rules/no-constant-binary-expression
142
+ 'no-constant-binary-expression': 'error',
143
+
144
+ // Require default case in switch statements
145
+ // https://eslint.org/docs/rules/default-case
146
+ 'default-case': ['error'],
147
+
148
+ // Enforce default clauses in switch statements to be last
149
+ // https://eslint.org/docs/rules/default-case-last
150
+ 'default-case-last': 'error',
151
+
152
+ // Require the use of === and !==
153
+ // https://eslint.org/docs/latest/rules/eqeqeq
154
+ eqeqeq: ['error', 'always'],
155
+
156
+ // Enforces consistent newlines before or after dots
157
+ // https://eslint.org/docs/rules/dot-location
158
+ 'dot-location': ['error', 'property'],
159
+
160
+ // Make sure for-in loops have an if statement
161
+ // https://eslint.org/docs/rules/guard-for-in
162
+ 'guard-for-in': 'error',
163
+
164
+ // Disallow the use of alert, confirm, and prompt
165
+ // https://eslint.org/docs/rules/no-alert
166
+ 'no-alert': 'error',
167
+
168
+ // Disallow lexical declarations in case/default clauses
169
+ // https://eslint.org/docs/rules/no-case-declarations
170
+ 'no-case-declarations': 'error',
171
+
172
+ // Disallow returning value in constructor
173
+ // https://eslint.org/docs/rules/no-constructor-return
174
+ 'no-constructor-return': 'error',
175
+
176
+ // Disallow else after a return in an if
177
+ // https://eslint.org/docs/rules/no-else-return
178
+ 'no-else-return': ['error', { allowElseIf: false }],
179
+
180
+ // Disallow empty destructuring patterns
181
+ // https://eslint.org/docs/rules/no-empty-pattern
182
+ 'no-empty-pattern': 'error',
183
+
184
+ // Disallow comparisons to null without a type-checking operator
185
+ // https://eslint.org/docs/rules/no-eq-null
186
+ 'no-eq-null': 'off',
187
+
188
+ // Disallow adding to native types
189
+ // https://eslint.org/docs/rules/no-extend-native
190
+ 'no-extend-native': 'error',
191
+
192
+ // Disallow Unnecessary Labels
193
+ // https://eslint.org/docs/rules/no-extra-label
194
+ 'no-extra-label': 'error',
195
+
196
+ // Disallow fallthrough of case statements
197
+ // https://eslint.org/docs/rules/no-fallthrough
198
+ 'no-fallthrough': 'error',
199
+
200
+ // Disallow the use of leading or trailing decimal points in numeric literals
201
+ // https://eslint.org/docs/rules/no-floating-decimal
202
+ 'no-floating-decimal': 'error',
203
+
204
+ // Disallow reassignments of native objects or read-only globals
205
+ // https://eslint.org/docs/rules/no-global-assign
206
+ 'no-global-assign': ['error', { exceptions: [] }],
207
+
208
+ // Deprecated in favor of no-global-assign
209
+ // https://eslint.org/docs/rules/no-native-reassign
210
+ 'no-native-reassign': 'off',
211
+
212
+ // Disallow implicit type conversions
213
+ // https://eslint.org/docs/rules/no-implicit-coercion
214
+ 'no-implicit-coercion': 'error',
215
+
216
+ // Disallow reassigning function declarations
217
+ // https://eslint.org/docs/latest/rules/no-func-assign
218
+ 'no-func-assign': 'error',
219
+
220
+ // Disallow assigning to imported bindings
221
+ // https://eslint.org/docs/latest/rules/no-import-assign
222
+ 'no-import-assign': 'error',
223
+
224
+ // Disallow var and named functions in global scope
225
+ // https://eslint.org/docs/rules/no-implicit-globals
226
+ 'no-implicit-globals': 'off',
227
+
228
+ // Disallow this keywords outside of classes or class-like objects
229
+ // https://eslint.org/docs/rules/no-invalid-this
230
+ 'no-invalid-this': 'off',
231
+
232
+ // Disallow variable or function declarations in nested blocks
233
+ // https://eslint.org/docs/latest/rules/no-inner-declarations
234
+ 'no-inner-declarations': ['error', 'both'],
235
+
236
+ // Disallow usage of __iterator__ property
237
+ // https://eslint.org/docs/rules/no-iterator
238
+ 'no-iterator': 'error',
239
+
240
+ // Disallow use of labels for anything other than loops and switches
241
+ // https://eslint.org/docs/rules/no-labels
242
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
243
+
244
+ // Disallow unnecessary nested blocks
245
+ // https://eslint.org/docs/rules/no-lone-blocks
246
+ 'no-lone-blocks': 'error',
247
+
248
+ // Disallow use of multiple spaces
249
+ // https://eslint.org/docs/rules/no-multi-spaces
250
+ 'no-multi-spaces': [
251
+ 'error',
252
+ {
253
+ ignoreEOLComments: false
254
+ }
255
+ ],
256
+
257
+ // Disallow use of multiline strings
258
+ // https://eslint.org/docs/rules/no-multi-str
259
+ 'no-multi-str': 'error',
260
+
261
+ // Disallow use of new operator when not part of the assignment or comparison
262
+ // https://eslint.org/docs/rules/no-new
263
+ 'no-new': 'error',
264
+
265
+ // Disallows creating new instances of String, Number, and Boolean
266
+ // https://eslint.org/docs/rules/no-new-wrappers
267
+ 'no-new-wrappers': 'error',
268
+
269
+ // Disallow use of (old style) octal literals
270
+ // https://eslint.org/docs/rules/no-octal
271
+ 'no-octal': 'error',
272
+
273
+ // Disallow use of octal escape sequences in string literals
274
+ // https://eslint.org/docs/rules/no-octal-escape
275
+ 'no-octal-escape': 'error',
276
+
277
+ // Disallow reassignment of function parameters
278
+ // https://eslint.org/docs/rules/no-param-reassign
279
+ 'no-param-reassign': [
280
+ 'error',
281
+ {
282
+ ignorePropertyModificationsForRegex: [
283
+ 'draft',
284
+ 'context2D',
285
+ 'canvasElement'
286
+ ]
287
+ }
288
+ ],
289
+
290
+ // Disallow certain object properties
291
+ // https://eslint.org/docs/rules/no-restricted-properties
292
+ 'no-restricted-properties': [
293
+ 'error',
294
+ {
295
+ object: 'arguments',
296
+ property: 'callee',
297
+ message: 'arguments.callee is deprecated'
298
+ },
299
+ {
300
+ object: 'global',
301
+ property: 'isFinite',
302
+ message: 'Please use Number.isFinite instead'
303
+ },
304
+ {
305
+ object: 'self',
306
+ property: 'isFinite',
307
+ message: 'Please use Number.isFinite instead'
308
+ },
309
+ {
310
+ object: 'window',
311
+ property: 'isFinite',
312
+ message: 'Please use Number.isFinite instead'
313
+ },
314
+ {
315
+ object: 'global',
316
+ property: 'isNaN',
317
+ message: 'Please use Number.isNaN instead'
318
+ },
319
+ {
320
+ object: 'self',
321
+ property: 'isNaN',
322
+ message: 'Please use Number.isNaN instead'
323
+ },
324
+ {
325
+ object: 'window',
326
+ property: 'isNaN',
327
+ message: 'Please use Number.isNaN instead'
328
+ },
329
+ {
330
+ object: 'Math',
331
+ property: 'pow',
332
+ message: 'Use the exponentiation operator (**) instead.'
333
+ }
334
+ ],
335
+
336
+ // Disallow use of assignment in return statement
337
+ // https://eslint.org/docs/rules/no-return-assign
338
+ 'no-return-assign': ['error', 'always'],
339
+
340
+ // Disallow ternary operators when simpler alternatives exist
341
+ // https://eslint.org/docs/rules/no-unneeded-ternary
342
+ 'no-unneeded-ternary': 'error',
343
+
344
+ // Disallow assignments where both sides are exactly the same
345
+ // https://eslint.org/docs/rules/no-self-assign
346
+ 'no-self-assign': [
347
+ 'error',
348
+ {
349
+ props: true
350
+ }
351
+ ],
352
+
353
+ // Disallow comparisons where both sides are exactly the same
354
+ // https://eslint.org/docs/rules/no-self-compare
355
+ 'no-self-compare': 'error',
356
+
357
+ // Restrict what can be thrown as an exception
358
+ // https://eslint.org/docs/rules/no-throw-literal
359
+ 'no-throw-literal': 'error',
360
+
361
+ // Disallow unmodified conditions of loops
362
+ // https://eslint.org/docs/rules/no-unmodified-loop-condition
363
+ 'no-unmodified-loop-condition': 'error',
364
+
365
+ // Disallow negating the left operand of relational operators
366
+ // https://eslint.org/docs/latest/rules/no-unsafe-negation
367
+ 'no-unsafe-negation': 'error',
368
+
369
+ // Enforce comparing typeof expressions against valid strings
370
+ // https://eslint.org/docs/latest/rules/valid-typeof
371
+ 'valid-typeof': 'error',
372
+
373
+ // Require calls to isNaN() when checking for NaN
374
+ // https://eslint.org/docs/latest/rules/use-isnan
375
+ 'use-isnan': 'error',
376
+
377
+ // Disallow unreachable code after return, throw, continue, and break statements
378
+ // https://eslint.org/docs/latest/rules/no-unreachable
379
+ 'no-unreachable': 'error',
380
+
381
+ // Disallow unused labels
382
+ // https://eslint.org/docs/rules/no-unused-labels
383
+ 'no-unused-labels': 'error',
384
+
385
+ // Disallow unnecessary .call() and .apply()
386
+ // https://eslint.org/docs/rules/no-useless-call
387
+ 'no-useless-call': 'off',
388
+
389
+ // Disallow unnecessary catch clauses
390
+ // https://eslint.org/docs/rules/no-useless-catch
391
+ 'no-useless-catch': 'error',
392
+
393
+ // Disallow useless string concatenation
394
+ // https://eslint.org/docs/rules/no-useless-concat
395
+ 'no-useless-concat': 'error',
396
+
397
+ // Disallow unnecessary string escaping
398
+ // https://eslint.org/docs/rules/no-useless-escape
399
+ 'no-useless-escape': 'error',
400
+
401
+ // Disallow redundant return; keywords
402
+ // https://eslint.org/docs/rules/no-useless-return
403
+ 'no-useless-return': 'error',
404
+
405
+ // Require using Error objects as Promise rejection reasons
406
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
407
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
408
+
409
+ // Suggest using named capture group in regular expression
410
+ // https://eslint.org/docs/rules/prefer-named-capture-group
411
+ 'prefer-named-capture-group': 'off',
412
+
413
+ // Require using regex literals instead of RegExp constructor
414
+ // https://eslint.org/docs/rules/prefer-regex-literals
415
+ 'prefer-regex-literals': [
416
+ 'error',
417
+ {
418
+ disallowRedundantWrapping: true
419
+ }
420
+ ],
421
+
422
+ // Require use of the second argument for parseInt()
423
+ // https://eslint.org/docs/rules/radix
424
+ radix: 'error',
425
+
426
+ // Enforce the use of u flag on RegExp
427
+ // https://eslint.org/docs/rules/require-unicode-regexp
428
+ 'require-unicode-regexp': 'off',
429
+
430
+ // ==========================================
431
+ // Variables
432
+ // ==========================================
433
+
434
+ // Enforce or disallow variable initializations at definition
435
+ // https://eslint.org/docs/rules/init-declarations
436
+ 'init-declarations': 'off',
437
+
438
+ // Disallow the catch clause parameter name being the same as a variable in the outer scope
439
+ // https://eslint.org/docs/rules/no-catch-shadow
440
+ 'no-catch-shadow': 'off',
441
+
442
+ // Disallow deletion of variables
443
+ // https://eslint.org/docs/latest/rules/no-delete-var
444
+ 'no-delete-var': 'error',
445
+
446
+ // Disallow labels that share a name with a variable
447
+ // https://eslint.org/docs/rules/no-label-var
448
+ 'no-label-var': 'error',
449
+
450
+ // For code readability, prevent creating unclear naming
451
+ // https://eslint.org/docs/rules/id-length
452
+ 'id-length': [
453
+ 'error',
454
+ { min: 2, max: Infinity, exceptions: ['t', '_'], properties: 'never' }
455
+ ],
456
+
457
+ // Prefer object shorthands for properties
458
+ // https://eslint.org/docs/rules/object-shorthand
459
+ 'object-shorthand': [
460
+ 'error',
461
+ 'always',
462
+ {
463
+ ignoreConstructors: false,
464
+ avoidQuotes: true
465
+ }
466
+ ],
467
+
468
+ // Disallow shadowing of names such as arguments
469
+ // https://eslint.org/docs/rules/no-shadow-restricted-names
470
+ 'no-shadow-restricted-names': 'error',
471
+
472
+ // Disallow use of undeclared variables unless mentioned in a /*global */ block
473
+ // https://eslint.org/docs/rules/no-undef
474
+ 'no-undef': ['error', { typeof: true }],
475
+
476
+ // Disallow use of undefined when initializing variables
477
+ // https://eslint.org/docs/rules/no-undef-init
478
+ 'no-undef-init': 'error',
479
+
480
+ // Most common naming that is not always understandable
481
+ // https://eslint.org/docs/rules/id-denylist
482
+ 'id-denylist': [
483
+ 'error',
484
+ 'err',
485
+ 'cb',
486
+ 'arr',
487
+ 'acc',
488
+ 'idx',
489
+ 'ctx',
490
+ 'res',
491
+ 'val',
492
+ 'obj',
493
+ 'el',
494
+ 'elem',
495
+ 'req',
496
+ 'str'
497
+ ],
498
+
499
+ // ==========================================
500
+ // ES6+
501
+ // ==========================================
502
+
503
+ // Require braces around arrow function bodies
504
+ // https://eslint.org/docs/rules/arrow-body-style
505
+ 'arrow-body-style': ['error', 'always'],
506
+
507
+ // Require parens in arrow function arguments
508
+ // https://eslint.org/docs/rules/arrow-parens
509
+ 'arrow-parens': ['error', 'always'],
510
+
511
+ // Require space before/after arrow function's arrow
512
+ // https://eslint.org/docs/rules/arrow-spacing
513
+ 'arrow-spacing': ['error', { before: true, after: true }],
514
+
515
+ // Verify super() callings in constructors
516
+ // https://eslint.org/docs/rules/constructor-super
517
+ 'constructor-super': 'error',
518
+
519
+ // Disallow modifying variables of class declarations
520
+ // https://eslint.org/docs/rules/no-class-assign
521
+ 'no-class-assign': 'error',
522
+
523
+ // Disallow duplicate class members
524
+ // https://eslint.org/docs/latest/rules/no-dupe-class-members
525
+ 'no-dupe-class-members': 'error',
526
+
527
+ // Disallow arrow functions where they could be confused with comparisons
528
+ // https://eslint.org/docs/rules/no-confusing-arrow
529
+ 'no-confusing-arrow': [
530
+ 'error',
531
+ {
532
+ allowParens: true
533
+ }
534
+ ],
535
+
536
+ // Disallow modifying variables that are declared using const
537
+ // https://eslint.org/docs/latest/rules/no-const-assign
538
+ 'no-const-assign': 'error',
539
+
540
+ // Disallow importing from the same path more than once
541
+ // https://eslint.org/docs/rules/no-duplicate-imports
542
+ 'no-duplicate-imports': 'off',
543
+
544
+ // Disallow new operators with global non-constructor functions
545
+ // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
546
+ 'no-new-native-nonconstructor': 'error',
547
+
548
+ // Disallow returning values from Promise executor functions
549
+ // https://eslint.org/docs/latest/rules/no-promise-executor-return
550
+ 'no-promise-executor-return': 'error',
551
+
552
+ // Disallow invalid regular expression strings in RegExp constructors
553
+ // https://eslint.org/docs/latest/rules/no-invalid-regexp
554
+ 'no-invalid-regexp': 'error',
555
+
556
+ // Disallow specified names in exports
557
+ // https://eslint.org/docs/rules/no-restricted-exports
558
+ 'no-restricted-exports': [
559
+ 'error',
560
+ {
561
+ restrictedNamedExports: ['default', 'then']
562
+ }
563
+ ],
564
+
565
+ // Disallow this/super before calling super() in constructors
566
+ // https://eslint.org/docs/rules/no-this-before-super
567
+ 'no-this-before-super': 'error',
568
+
569
+ // Disallow use of optional chaining in contexts where the undefined value is not allowed
570
+ // https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining
571
+ 'no-unsafe-optional-chaining': 'error',
572
+
573
+ // Disallow control flow statements in finally blocks
574
+ // https://eslint.org/docs/latest/rules/no-unsafe-finally
575
+ 'no-unsafe-finally': 'error',
576
+
577
+ // Disallow useless computed property keys
578
+ // https://eslint.org/docs/rules/no-useless-computed-key
579
+ 'no-useless-computed-key': 'error',
580
+
581
+ // Disallow renaming import, export, and destructured assignments to the same name
582
+ // https://eslint.org/docs/rules/no-useless-rename
583
+ 'no-useless-rename': [
584
+ 'error',
585
+ {
586
+ ignoreDestructuring: false,
587
+ ignoreImport: false,
588
+ ignoreExport: false
589
+ }
590
+ ],
591
+
592
+ // Require let or const instead of var
593
+ // https://eslint.org/docs/rules/no-var
594
+ 'no-var': 'error',
595
+
596
+ // Suggest using arrow functions as callbacks
597
+ // https://eslint.org/docs/rules/prefer-arrow-callback
598
+ 'prefer-arrow-callback': [
599
+ 'error',
600
+ {
601
+ allowNamedFunctions: false,
602
+ allowUnboundThis: true
603
+ }
604
+ ],
605
+
606
+ // Suggest using of const declaration for variables that are never modified after declared
607
+ // https://eslint.org/docs/rules/prefer-const
608
+ 'prefer-const': [
609
+ 'error',
610
+ {
611
+ destructuring: 'any',
612
+ ignoreReadBeforeAssign: true
613
+ }
614
+ ],
615
+
616
+ // Prefer destructuring from arrays and objects
617
+ // https://eslint.org/docs/rules/prefer-destructuring
618
+ 'prefer-destructuring': [
619
+ 'error',
620
+ {
621
+ VariableDeclarator: {
622
+ array: false,
623
+ object: true
624
+ },
625
+ AssignmentExpression: {
626
+ array: true,
627
+ object: false
628
+ }
629
+ },
630
+ {
631
+ enforceForRenamedProperties: false
632
+ }
633
+ ],
634
+
635
+ // Disallow parseInt() in favor of binary, octal, and hexadecimal literals
636
+ // https://eslint.org/docs/rules/prefer-numeric-literals
637
+ 'prefer-numeric-literals': 'error',
638
+
639
+ // Suggest using Reflect methods where applicable
640
+ // https://eslint.org/docs/rules/prefer-reflect
641
+ 'prefer-reflect': 'off',
642
+
643
+ // Use rest parameters instead of arguments
644
+ // https://eslint.org/docs/rules/prefer-rest-params
645
+ 'prefer-rest-params': 'error',
646
+
647
+ // Suggest using the spread syntax instead of .apply()
648
+ // https://eslint.org/docs/rules/prefer-spread
649
+ 'prefer-spread': 'error',
650
+
651
+ // Suggest using template literals instead of string concatenation
652
+ // https://eslint.org/docs/rules/prefer-template
653
+ 'prefer-template': 'error',
654
+
655
+ // Enforce spacing between object rest-spread
656
+ // https://eslint.org/docs/rules/rest-spread-spacing
657
+ 'rest-spread-spacing': ['error', 'never'],
658
+
659
+ // Enforce usage of spacing in template strings
660
+ // https://eslint.org/docs/rules/template-curly-spacing
661
+ 'template-curly-spacing': 'error',
662
+
663
+ // Disallow using an async function as a Promise executor
664
+ // https://eslint.org/docs/latest/rules/no-async-promise-executor
665
+ 'no-async-promise-executor': 'error',
666
+
667
+ // Disallow template literal placeholder syntax in regular strings
668
+ // https://eslint.org/docs/latest/rules/no-template-curly-in-string
669
+ 'no-template-curly-in-string': 'error',
670
+
671
+ // ==========================================
672
+ // Errors
673
+ // ==========================================
674
+
675
+ // Disallow await inside of loops
676
+ // https://eslint.org/docs/rules/no-await-in-loop
677
+ 'no-await-in-loop': 'error',
678
+
679
+ // Disallow assignment in conditional expressions
680
+ // https://eslint.org/docs/latest/rules/no-cond-assign
681
+ 'no-cond-assign': ['error', 'always'],
682
+
683
+ // Disallow use of console
684
+ // https://eslint.org/docs/rules/no-console
685
+ // EXCEPTION: This rule uses 'warn' instead of 'error' to allow console statements during development
686
+ 'no-console': 'warn',
687
+
688
+ // Disallow use of constant expressions in conditions
689
+ // https://eslint.org/docs/latest/rules/no-constant-condition
690
+ 'no-constant-condition': 'error',
691
+
692
+ // Disallow use of debugger
693
+ // https://eslint.org/docs/latest/rules/no-debugger
694
+ 'no-debugger': 'error',
695
+
696
+ // Disallow duplicate conditions in if-else-if chains
697
+ // https://eslint.org/docs/rules/no-dupe-else-if
698
+ 'no-dupe-else-if': 'error',
699
+
700
+ // Disallow duplicate case labels
701
+ // https://eslint.org/docs/latest/rules/no-duplicate-case
702
+ 'no-duplicate-case': 'error',
703
+
704
+ // Disallow duplicate keys when creating object literals
705
+ // https://eslint.org/docs/latest/rules/no-dupe-keys
706
+ 'no-dupe-keys': 'error',
707
+
708
+ // Disallow reassigning exceptions in catch clauses
709
+ // https://eslint.org/docs/latest/rules/no-ex-assign
710
+ 'no-ex-assign': 'error',
711
+
712
+ // Disallow unnecessary semicolons
713
+ // https://eslint.org/docs/rules/no-extra-semi
714
+ 'no-extra-semi': 'error',
715
+
716
+ // ==========================================
717
+ // Node
718
+ // ==========================================
719
+
720
+ // Require all requires be top-level
721
+ // https://eslint.org/docs/rules/global-require
722
+ 'global-require': 'error',
723
+
724
+ // ==========================================
725
+ // Style
726
+ // ==========================================
727
+
728
+ // Enforce camelcase naming convention
729
+ // https://eslint.org/docs/latest/rules/camelcase
730
+ camelcase: 'error',
731
+
732
+ // "red" === color is a "Yoda" condition, prefer color === "red" instead
733
+ // https://eslint.org/docs/latest/rules/yoda
734
+ yoda: 'error',
735
+
736
+ // Disallow the unary operators ++ and --
737
+ // https://eslint.org/docs/latest/rules/no-plusplus
738
+ 'no-plusplus': 'error',
739
+
740
+ // Disallow inline comments after code
741
+ // https://eslint.org/docs/latest/rules/no-inline-comments
742
+ 'no-inline-comments': 'error',
743
+
744
+ // Require or disallow an empty line between class members
745
+ // https://eslint.org/docs/latest/rules/lines-between-class-members
746
+ 'lines-between-class-members': ['error', 'always'],
747
+
748
+ // Require or disallow padding lines between statements
749
+ // https://eslint.org/docs/rules/padding-line-between-statements
750
+ 'padding-line-between-statements': [
751
+ 'error',
752
+ {
753
+ blankLine: 'always',
754
+ prev: '*',
755
+ next: ['return', 'multiline-block-like']
756
+ },
757
+ { blankLine: 'always', prev: 'multiline-block-like', next: '*' }
758
+ ],
759
+
760
+ // ==========================================
761
+ // Unicorn
762
+ // ==========================================
763
+
764
+ // Disallow creating a variable and immediately mutating it
765
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-immediate-mutation.md
766
+ 'unicorn/no-immediate-mutation': 'error',
767
+
768
+ // Disallow useless arguments when constructing Set, Map, WeakSet, WeakMap
769
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-collection-argument.md
770
+ 'unicorn/no-useless-collection-argument': 'error',
771
+
772
+ // Prefer class fields over constructor assignments
773
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md
774
+ 'unicorn/prefer-class-fields': 'error',
775
+
776
+ // Prefer Array#toReversed() over Array#reverse() to avoid mutation
777
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reverse.md
778
+ 'unicorn/no-array-reverse': 'error',
779
+
780
+ // Prefer Array#toSorted() over Array#sort() to avoid mutation
781
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-sort.md
782
+ 'unicorn/no-array-sort': 'error',
783
+
784
+ // Require using new when throwing an error
785
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md
786
+ 'unicorn/throw-new-error': 'error',
787
+
788
+ // Prefer includes() over indexOf() when checking for existence
789
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
790
+ 'unicorn/prefer-includes': 'error',
791
+
792
+ // Prefer find() over filter()[0] when searching for a single element
793
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
794
+ 'unicorn/prefer-array-find': 'error',
795
+
796
+ // Prefer startsWith() and endsWith() over regex or slice comparisons
797
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md
798
+ 'unicorn/prefer-string-starts-ends-with': 'error',
799
+
800
+ // Prefer .at() for accessing elements by negative index
801
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
802
+ 'unicorn/prefer-at': 'error',
803
+
804
+ // Prefer Number static properties over global ones
805
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-number-properties.md
806
+ 'unicorn/prefer-number-properties': 'error',
807
+
808
+ // Prefer for...of over Array#forEach
809
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
810
+ 'unicorn/no-array-for-each': 'error',
811
+
812
+ // Prefer Array#flat() over legacy techniques to flatten arrays
813
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
814
+ 'unicorn/prefer-array-flat': 'error',
815
+
816
+ // Prefer flatMap() over map().flat()
817
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
818
+ 'unicorn/prefer-array-flat-map': 'error',
819
+
820
+ // Disallow useless undefined
821
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md
822
+ 'unicorn/no-useless-undefined': 'error',
823
+
824
+ // Prefer String#replaceAll() over regex with global flag
825
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
826
+ 'unicorn/prefer-string-replace-all': 'error',
827
+
828
+ // Prefer String#trimStart() / String#trimEnd() over trimLeft() / trimRight()
829
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-trim-start-end.md
830
+ 'unicorn/prefer-string-trim-start-end': 'error',
831
+
832
+ // Disallow if statements as the only statement in else blocks
833
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-lonely-if.md
834
+ 'unicorn/no-lonely-if': 'error',
835
+
836
+ // Prefer RegExp#test() over String#match() for boolean checks
837
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-regexp-test.md
838
+ 'unicorn/prefer-regexp-test': 'error',
839
+
840
+ // Prefer modern DOM APIs
841
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
842
+ 'unicorn/prefer-modern-dom-apis': 'error',
843
+
844
+ // Prefer [...iterable] over Array.from(iterable)
845
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-spread.md
846
+ 'unicorn/prefer-spread': 'off',
847
+
848
+ // Prefer ternary expressions over simple if-else statements (DISABLED - prefer if-else for clarity)
849
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-ternary.md
850
+ 'unicorn/prefer-ternary': 'off',
851
+
852
+ // Prefer omitting catch binding when unused
853
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
854
+ 'unicorn/prefer-optional-catch-binding': 'off',
855
+
856
+ // Disallow negated conditions when alternative exists
857
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-condition.md
858
+ 'unicorn/no-negated-condition': 'off',
859
+
860
+ // Prefer TypeError for type-related errors
861
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md
862
+ 'unicorn/prefer-type-error': 'off',
863
+
864
+ // Prefer Date.now() over new Date().getTime()
865
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-date-now.md
866
+ 'unicorn/prefer-date-now': 'error',
867
+
868
+ // Prefer === undefined over typeof === 'undefined'
869
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md
870
+ 'unicorn/no-typeof-undefined': 'error',
871
+
872
+ // Prefer Object.fromEntries() over reduce to create objects
873
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-object-from-entries.md
874
+ 'unicorn/prefer-object-from-entries': 'error',
875
+
876
+ // Prefer Set#has() over Array#includes() for frequent checks
877
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-set-has.md
878
+ 'unicorn/prefer-set-has': 'off',
879
+
880
+ // Prefer some() over find() !== undefined for boolean checks
881
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md
882
+ 'unicorn/prefer-array-some': 'error',
883
+
884
+ // Disallow new Array() and prefer Array.from({length: n})
885
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md
886
+ 'unicorn/no-new-array': 'error',
887
+
888
+ // Prefer default parameters over reassignment
889
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md
890
+ 'unicorn/prefer-default-parameters': 'error',
891
+
892
+ // Prefer negative index over length minus index
893
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-negative-index.md
894
+ 'unicorn/prefer-negative-index': 'error',
895
+
896
+ // Enforce usage of the `node:` prefix for builtin imports
897
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
898
+ 'unicorn/prefer-node-protocol': 'error',
899
+
900
+ // ==========================================
901
+ // Promise
902
+ // ==========================================
903
+
904
+ // Prefer to use async/await for Promises
905
+ // https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/prefer-await-to-then.md
906
+ 'promise/prefer-await-to-then': 'off',
907
+
908
+ // ==========================================
909
+ // TypeScript (with ESLint rule replacements)
910
+ // ==========================================
911
+
912
+ // Enforce default parameters to be last
913
+ // https://typescript-eslint.io/rules/default-param-last
45
914
  'default-param-last': 'off',
46
- '@typescript-eslint/default-param-last':
47
- baseBestPracticesRules['default-param-last'],
915
+ '@typescript-eslint/default-param-last': 'error',
48
916
 
49
- // Replace @viclafouch/eslint 'dot-notation' rule with '@typescript-eslint' version
50
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
917
+ // Enforce dot notation whenever possible
918
+ // https://typescript-eslint.io/rules/dot-notation
51
919
  'dot-notation': 'off',
52
- '@typescript-eslint/dot-notation': baseBestPracticesRules['dot-notation'],
920
+ '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
53
921
 
54
- // Replace @viclafouch/eslint 'no-empty-function' rule with '@typescript-eslint' version
55
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
922
+ // Disallow empty functions
923
+ // https://typescript-eslint.io/rules/no-empty-function
56
924
  'no-empty-function': 'off',
57
- '@typescript-eslint/no-empty-function':
58
- baseBestPracticesRules['no-empty-function'],
925
+ '@typescript-eslint/no-empty-function': [
926
+ 'error',
927
+ {
928
+ allow: ['arrowFunctions', 'functions', 'methods']
929
+ }
930
+ ],
59
931
 
60
- // Replace @viclafouch/eslint 'no-redeclare' rule with '@typescript-eslint' version
61
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
932
+ // Disallow variable redeclaration
933
+ // https://typescript-eslint.io/rules/no-redeclare
62
934
  'no-redeclare': 'off',
63
- '@typescript-eslint/no-redeclare': baseBestPracticesRules['no-redeclare'],
935
+ '@typescript-eslint/no-redeclare': 'error',
64
936
 
65
- // Replace @viclafouch/eslint 'no-shadow' rule with '@typescript-eslint' version
66
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
937
+ // Disallow variable declarations from shadowing variables declared in the outer scope
938
+ // https://typescript-eslint.io/rules/no-shadow
67
939
  'no-shadow': 'off',
68
- '@typescript-eslint/no-shadow': baseVariablesRules['no-shadow'],
940
+ '@typescript-eslint/no-shadow': 'error',
69
941
 
70
- // Replace @viclafouch/eslint 'no-unused-expressions' rule with '@typescript-eslint' version
71
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
942
+ // Disallow unused expressions
943
+ // https://typescript-eslint.io/rules/no-unused-expressions
72
944
  'no-unused-expressions': 'off',
73
- '@typescript-eslint/no-unused-expressions':
74
- baseBestPracticesRules['no-unused-expressions'],
945
+ '@typescript-eslint/no-unused-expressions': [
946
+ 'error',
947
+ {
948
+ allowShortCircuit: false,
949
+ allowTernary: false,
950
+ allowTaggedTemplates: false
951
+ }
952
+ ],
75
953
 
76
- // Replace @viclafouch/eslint 'no-unused-vars' rule with '@typescript-eslint' version
77
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
954
+ // Disallow unused variables
955
+ // https://typescript-eslint.io/rules/no-unused-vars
78
956
  'no-unused-vars': 'off',
79
- '@typescript-eslint/no-unused-vars': baseVariablesRules['no-unused-vars'],
957
+ '@typescript-eslint/no-unused-vars': [
958
+ 'error',
959
+ {
960
+ vars: 'all',
961
+ args: 'after-used',
962
+ caughtErrors: 'none',
963
+ argsIgnorePattern: '^_',
964
+ ignoreRestSiblings: true
965
+ }
966
+ ],
80
967
 
81
- // Replace @viclafouch/eslint 'no-use-before-define' rule with '@typescript-eslint' version
82
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
968
+ // Disallow the use of variables before they are defined
969
+ // https://typescript-eslint.io/rules/no-use-before-define
83
970
  'no-use-before-define': 'off',
84
- '@typescript-eslint/no-use-before-define':
85
- baseVariablesRules['no-use-before-define'],
971
+ '@typescript-eslint/no-use-before-define': 'off',
86
972
 
87
- // Replace @viclafouch/eslint 'no-useless-constructor' rule with '@typescript-eslint' version
88
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
973
+ // Disallow unnecessary constructors
974
+ // https://typescript-eslint.io/rules/no-useless-constructor
89
975
  'no-useless-constructor': 'off',
90
- '@typescript-eslint/no-useless-constructor':
91
- baseES6Rules['no-useless-constructor'],
976
+ '@typescript-eslint/no-useless-constructor': 'error',
92
977
 
93
- '@typescript-eslint/require-await': baseES6Rules['require-await'],
978
+ // Disallow async functions which have no await expression
979
+ // https://typescript-eslint.io/rules/require-await
980
+ '@typescript-eslint/require-await': 'off',
94
981
 
95
- // Replace @viclafouch/eslint 'no-return-await' rule with '@typescript-eslint' version
96
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
982
+ // Enforce consistent returning of awaited values
983
+ // https://typescript-eslint.io/rules/return-await
97
984
  'no-return-await': 'off',
98
- '@typescript-eslint/return-await': [
99
- baseES6Rules['no-return-await'],
100
- 'in-try-catch'
101
- ],
985
+ '@typescript-eslint/return-await': ['error', 'in-try-catch'],
102
986
 
103
- // Accept banning ts lines
104
- '@typescript-eslint/ban-ts-comment': 'off',
987
+ // Disallow @ts-<directive> comments or require descriptions after directives
988
+ // https://typescript-eslint.io/rules/ban-ts-comment
989
+ '@typescript-eslint/ban-ts-comment': [
990
+ 'error',
991
+ {
992
+ 'ts-expect-error': 'allow-with-description',
993
+ 'ts-ignore': 'allow-with-description',
994
+ 'ts-nocheck': 'allow-with-description',
995
+ 'ts-check': false
996
+ }
997
+ ],
105
998
 
106
- // Naming convention
999
+ // Naming convention for type parameters
1000
+ // https://typescript-eslint.io/rules/naming-convention
107
1001
  '@typescript-eslint/naming-convention': [
108
1002
  'error',
109
1003
  {
@@ -122,11 +1016,30 @@ export default tseslint.config(
122
1016
  // https://typescript-eslint.io/rules/array-type
123
1017
  '@typescript-eslint/array-type': 'error',
124
1018
 
1019
+ // Enforce type definitions to consistently use type instead of interface
1020
+ // https://typescript-eslint.io/rules/consistent-type-definitions
1021
+ '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
1022
+
1023
+ // Disallow the any type
1024
+ // https://typescript-eslint.io/rules/no-explicit-any
1025
+ '@typescript-eslint/no-explicit-any': 'error',
1026
+
1027
+ // Require Promise-like statements to be handled appropriately
1028
+ // https://typescript-eslint.io/rules/no-floating-promises
1029
+ '@typescript-eslint/no-floating-promises': [
1030
+ 'error',
1031
+ { ignoreVoid: true }
1032
+ ],
1033
+
1034
+ // Disallow explicit return type annotations on functions (trust inference)
1035
+ // https://typescript-eslint.io/rules/explicit-function-return-type
1036
+ '@typescript-eslint/explicit-function-return-type': 'off',
1037
+
125
1038
  // Forbid delete array, use splice for example
126
- // https://typescript-eslint.io/rules/no-array-delete/
1039
+ // https://typescript-eslint.io/rules/no-array-delete
127
1040
  '@typescript-eslint/no-array-delete': 'error',
128
1041
 
129
- // Don't do array.filter(callback)[0], use arrat.find instead
1042
+ // Don't do array.filter(callback)[0], use array.find instead
130
1043
  // https://typescript-eslint.io/rules/prefer-find
131
1044
  '@typescript-eslint/prefer-find': 'error',
132
1045
 
@@ -134,24 +1047,20 @@ export default tseslint.config(
134
1047
  // https://typescript-eslint.io/rules/prefer-string-starts-ends-with
135
1048
  '@typescript-eslint/prefer-string-starts-ends-with': 'error',
136
1049
 
137
- // Prefer to use unknown instead of any for error in catch callback
138
- // https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
139
- // '@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
140
-
141
1050
  // No more "as Record<any, any>" in Array.reduce initial value, use generics
142
1051
  // https://typescript-eslint.io/rules/prefer-reduce-type-parameter
143
1052
  '@typescript-eslint/prefer-reduce-type-parameter': 'error',
144
1053
 
145
- // Disallow duplicate constituents of union or intersection types.
1054
+ // Disallow duplicate constituents of union or intersection types
146
1055
  // https://typescript-eslint.io/rules/no-duplicate-type-constituents
147
1056
  '@typescript-eslint/no-duplicate-type-constituents': 'error',
148
1057
 
149
- // Disallow using code marked as @deprecated.
1058
+ // Disallow using code marked as @deprecated
150
1059
  // https://typescript-eslint.io/rules/no-deprecated
151
1060
  '@typescript-eslint/no-deprecated': 'error',
152
1061
 
153
- // Disallow using the spread operator when it might cause unexpected behavior.
154
- // https://typescript-eslint.io/rules/no-misused-spread/
1062
+ // Disallow using the spread operator when it might cause unexpected behavior
1063
+ // https://typescript-eslint.io/rules/no-misused-spread
155
1064
  '@typescript-eslint/no-misused-spread': 'error',
156
1065
 
157
1066
  // Enforce import type { T }
@@ -183,68 +1092,40 @@ export default tseslint.config(
183
1092
  // Disallow passing a value-returning function where void is expected
184
1093
  // https://typescript-eslint.io/rules/strict-void-return
185
1094
  '@typescript-eslint/strict-void-return': 'off'
186
-
187
- // Prefer using nullish coalescing (??) over logical (||) when possible.
188
- // '@typescript-eslint/prefer-nullish-coalescing': 'error'
189
-
190
- // '@typescript-eslint/ban-types': [
191
- // 'error',
192
- // {
193
- // Types: {
194
- // // Omit is not strict enought
195
- // Omit: {
196
- // // https://twitter.com/erikras/status/1673694889974833152
197
- // Message:
198
- // 'Use StrictOmit instead by using reset.d.ts from @viclafouch/eslint-config-viclafouch/reset.d. See https://github.com/viclafouch/eslint-config-viclafouch#better-typing',
199
- // FixWith: 'StrictOmit'
200
- // }
201
- // }
202
- // }
203
- // ]
204
1095
  }
205
1096
  },
206
1097
  {
1098
+ name: 'typescript/disable-type-checked-for-js',
207
1099
  files: ['./**/*.js', './**/*.cjs'],
208
1100
  ...tseslint.configs.disableTypeChecked
209
1101
  },
210
1102
  {
211
- files: ['*.ts?(x)'],
1103
+ name: 'typescript/ts-specific-overrides',
1104
+ files: ['**/*.ts?(x)'],
212
1105
  rules: {
213
- // The following rules are enabled in @viclafouch/eslint config, but are already checked (more thoroughly) by the TypeScript compiler
214
- // Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
215
- // Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
1106
+ // The following rules are enabled but already checked (more thoroughly) by the TypeScript compiler
1107
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
216
1108
  'constructor-super': 'off',
217
1109
  'no-const-assign': 'off',
218
- // https://eslint.org/docs/latest/rules/no-dupe-args#handled_by_typescript
219
1110
  'no-dupe-args': 'off',
220
- // https://eslint.org/docs/latest/rules/no-dupe-class-members#handled_by_typescript
221
1111
  'no-dupe-class-members': 'off',
222
- // https://eslint.org/docs/latest/rules/no-dupe-keys#handled_by_typescript
223
1112
  'no-dupe-keys': 'off',
224
- // https://eslint.org/docs/latest/rules/no-func-assign#handled_by_typescript
225
1113
  'no-func-assign': 'off',
226
- // https://eslint.org/docs/latest/rules/no-import-assign#handled_by_typescript
227
1114
  'no-import-assign': 'off',
228
- // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor#handled_by_typescript
229
1115
  'no-new-native-nonconstructor': 'off',
230
1116
  'no-new-symbol': 'off',
231
1117
  'no-obj-calls': 'off',
232
1118
  'no-redeclare': 'off',
233
- // https://eslint.org/docs/latest/rules/no-setter-return#handled_by_typescript
234
1119
  'no-setter-return': 'off',
235
- // https://eslint.org/docs/latest/rules/no-this-before-super#handled_by_typescript
236
1120
  'no-this-before-super': 'off',
237
- // https://eslint.org/docs/latest/rules/no-undef#handled_by_typescript
238
1121
  'no-undef': 'off',
239
- // https://eslint.org/docs/latest/rules/no-unreachable#handled_by_typescript
240
1122
  'no-unreachable': 'off',
241
- // https://eslint.org/docs/latest/rules/no-unsafe-negation#handled_by_typescript
242
1123
  'no-unsafe-negation': 'off',
243
- // The following rules are enabled in @viclafouch/eslint config, but are recommended to be disabled within TypeScript projects
244
- // See: https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
1124
+
1125
+ // Disable import rules that don't work well with TypeScript
1126
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
245
1127
  'import/named': 'off',
246
1128
  'import/no-named-as-default-member': 'off',
247
- // Disable `import/no-unresolved`, see README.md for details
248
1129
  'import/no-unresolved': 'off'
249
1130
  }
250
1131
  }