@will-stone/eslint-config 0.7.3 → 0.8.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.
Files changed (3) hide show
  1. package/dist/index.cjs +81 -608
  2. package/dist/index.js +80 -607
  3. package/package.json +16 -16
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  var _eslintconfigflatgitignore = require('eslint-config-flat-gitignore'); var _eslintconfigflatgitignore2 = _interopRequireDefault(_eslintconfigflatgitignore);
3
3
 
4
4
  // src/configs/astro.ts
5
- var _parser = require('@typescript-eslint/parser'); var _parser2 = _interopRequireDefault(_parser);
5
+ var _parser = require('@typescript-eslint/parser'); var parserTypescript2 = _interopRequireWildcard(_parser);
6
6
  var _astroeslintparser = require('astro-eslint-parser'); var _astroeslintparser2 = _interopRequireDefault(_astroeslintparser);
7
7
  var _eslintpluginastro = require('eslint-plugin-astro'); var _eslintpluginastro2 = _interopRequireDefault(_eslintpluginastro);
8
8
  function astro() {
@@ -14,15 +14,66 @@ function astro() {
14
14
  parser: _astroeslintparser2.default,
15
15
  parserOptions: {
16
16
  extraFileExtensions: [".astro"],
17
- parser: _parser2.default
17
+ parser: parserTypescript2.default
18
18
  }
19
19
  },
20
20
  plugins: {
21
21
  // @ts-expect-error -- does not confirm to type
22
22
  astro: _eslintpluginastro2.default
23
23
  },
24
- // @ts-expect-error -- does not confirm to type
25
- rules: _eslintpluginastro.configs.recommended.rules
24
+ rules: {
25
+ "astro/no-conflict-set-directives": "error",
26
+ "astro/no-deprecated-astro-canonicalurl": "error",
27
+ "astro/no-deprecated-astro-fetchcontent": "error",
28
+ "astro/no-deprecated-astro-resolve": "error",
29
+ "astro/no-deprecated-getentrybyslug": "error",
30
+ "astro/no-unused-define-vars-in-style": "error",
31
+ "astro/semi": "off",
32
+ "astro/valid-compile": "error",
33
+ // TODO off until checked to see if I need them.
34
+ "astro/jsx-a11y/alt-text": "off",
35
+ "astro/jsx-a11y/anchor-ambiguous-text": "off",
36
+ "astro/jsx-a11y/anchor-has-content": "off",
37
+ "astro/jsx-a11y/anchor-is-valid": "off",
38
+ "astro/jsx-a11y/aria-activedescendant-has-tabindex": "off",
39
+ "astro/jsx-a11y/aria-props": "off",
40
+ "astro/jsx-a11y/aria-proptypes": "off",
41
+ "astro/jsx-a11y/aria-role": "off",
42
+ "astro/jsx-a11y/aria-unsupported-elements": "off",
43
+ "astro/jsx-a11y/autocomplete-valid": "off",
44
+ "astro/jsx-a11y/click-events-have-key-events": "off",
45
+ "astro/jsx-a11y/control-has-associated-label": "off",
46
+ "astro/jsx-a11y/heading-has-content": "off",
47
+ "astro/jsx-a11y/html-has-lang": "off",
48
+ "astro/jsx-a11y/iframe-has-title": "off",
49
+ "astro/jsx-a11y/img-redundant-alt": "off",
50
+ "astro/jsx-a11y/interactive-supports-focus": "off",
51
+ "astro/jsx-a11y/label-has-associated-control": "off",
52
+ "astro/jsx-a11y/lang": "off",
53
+ "astro/jsx-a11y/media-has-caption": "off",
54
+ "astro/jsx-a11y/mouse-events-have-key-events": "off",
55
+ "astro/jsx-a11y/no-access-key": "off",
56
+ "astro/jsx-a11y/no-aria-hidden-on-focusable": "off",
57
+ "astro/jsx-a11y/no-autofocus": "off",
58
+ "astro/jsx-a11y/no-distracting-elements": "off",
59
+ "astro/jsx-a11y/no-interactive-element-to-noninteractive-role": "off",
60
+ "astro/jsx-a11y/no-noninteractive-element-interactions": "off",
61
+ "astro/jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
62
+ "astro/jsx-a11y/no-noninteractive-tabindex": "off",
63
+ "astro/jsx-a11y/no-redundant-roles": "off",
64
+ "astro/jsx-a11y/no-static-element-interactions": "off",
65
+ "astro/jsx-a11y/prefer-tag-over-role": "off",
66
+ "astro/jsx-a11y/role-has-required-aria-props": "off",
67
+ "astro/jsx-a11y/role-supports-aria-props": "off",
68
+ "astro/jsx-a11y/scope": "off",
69
+ "astro/jsx-a11y/tabindex-no-positive": "off",
70
+ "astro/no-set-html-directive": "off",
71
+ "astro/no-set-text-directive": "off",
72
+ "astro/no-unused-css-selector": "off",
73
+ "astro/prefer-class-list-directive": "off",
74
+ "astro/prefer-object-class-list": "off",
75
+ "astro/prefer-split-class-list": "off"
76
+ }
26
77
  }
27
78
  ];
28
79
  }
@@ -39,6 +90,11 @@ function base() {
39
90
  ..._globals2.default.es2021
40
91
  }
41
92
  },
93
+ linterOptions: {
94
+ // Indicate if unused disable and enable directives should be reported
95
+ // as "warn".
96
+ reportUnusedDisableDirectives: true
97
+ },
42
98
  rules: {
43
99
  /**
44
100
  * Built-in rules
@@ -125,9 +181,7 @@ function base() {
125
181
  "wrap-iife": "off",
126
182
  "wrap-regex": "off",
127
183
  "yield-star-spacing": "off",
128
- // Enforces getter/setter pairs in objects and classes
129
184
  "accessor-pairs": "error",
130
- // Enforces return statements in callbacks of array's methods
131
185
  "array-callback-return": [
132
186
  "error",
133
187
  // To be compatible with unicorn/no-useless-undefined
@@ -136,414 +190,167 @@ function base() {
136
190
  // Can cause issues when Prettier is enabled
137
191
  // TODO should this move to prettier config?
138
192
  "arrow-body-style": "off",
139
- // Generates warnings when variables are used outside of the
140
- // block in which they were defined
141
193
  "block-scoped-var": "error",
142
- // camelCase vars
143
194
  "camelcase": "error",
144
- // Write comments however you like
145
195
  "capitalized-comments": "off",
146
196
  "class-methods-use-this": "off",
147
- // Measures the number of linearly independent paths through a program's
148
- // source code. Rubbish. Use your own judgement on complexity.
149
197
  "complexity": "off",
150
- // Do not care how return statements specify values.
151
- // When on, this rule gets annoying when combined with Unicorn's no-useless-* rules.
198
+ // When on, this rule gets annoying when combined with Unicorn's
199
+ // no-useless-* rules.
152
200
  "consistent-return": "off",
153
201
  // Not sure if required
154
202
  "consistent-this": "error",
155
- // Constructors of derived classes must call super().
156
- // Constructors of non derived classes must not call super()
157
203
  "constructor-super": "error",
158
- // Require Default Case in Switch Statements
159
204
  "default-case": "error",
160
- // enforce default clauses in switch statements to be last
161
205
  "default-case-last": "error",
162
- // Putting default parameter at last allows function calls
163
- // to omit optional tail arguments.
164
206
  "default-param-last": "error",
165
- // Access properties using the dot notation.
166
207
  "dot-notation": "warn",
167
- // Use === over ==
168
208
  "eqeqeq": "warn",
169
- // Enforce "for" loop update clause moving the counter in the right direction
170
209
  "for-direction": "error",
171
- // Require function names to match the name of the variable or property to
172
- // which they are assigned.
173
210
  "func-name-matching": "error",
174
- // Requires function expressions to have a name,
175
- // If the name cannot be assigned automatically
176
211
  "func-names": ["error", "as-needed"],
177
- // Declaration style: function name() {}
178
- // Except arrow functions
179
212
  "func-style": ["error", "declaration", { allowArrowFunctions: true }],
180
- // Enforces that a return statement is present in property getters
181
213
  "getter-return": "error",
182
- // If a property has a getter and a setter, the setter should be defined
183
- // right after the getter, or vice versa.
184
214
  "grouped-accessor-pairs": "error",
185
- // This rule is aimed at preventing unexpected behavior that could arise
186
- // from using a for in loop without filtering the results in the loop.
187
215
  "guard-for-in": "error",
188
- // Disallows specified identifiers.
189
216
  // Maybe turn this on when it's obvious which identifiers do not make sense.
190
217
  // Rules like unicorn/catch-error-name look after some of these, anyway.
191
218
  "id-denylist": "off",
192
- // Allow variables named with as little chars as you like
193
219
  "id-length": "off",
194
- // Requires identifiers to match a specified regular expression.
195
220
  // Mainly covered by rules like "camelcase". This could probably cause more
196
221
  // trouble than it's worth.
197
222
  "id-match": "off",
198
- // Initialise vairables however you like
199
223
  "init-declarations": "off",
200
- // Enforces line comments positioned above code
201
224
  "line-comment-position": "error",
202
- // Require an empty line between class members
203
225
  "lines-between-class-members": "warn",
204
226
  "logical-assignment-operators": ["warn", "always"],
205
- // Organise classes how you see fit
206
227
  "max-classes-per-file": "off",
207
- // This rule enforces a maximum depth that blocks can be nested to reduce
208
- // code complexity. Just gets in the way too much.
209
228
  "max-depth": "off",
210
- // Files can contain as many lines as you like
211
229
  "max-lines": "off",
212
- // Functions can be as complicated as you like
213
230
  "max-lines-per-function": "off",
214
- // This rule enforces a maximum depth that callbacks can be nested to
215
- // increase code clarity. Defaults to 10.
216
231
  "max-nested-callbacks": "error",
217
- // Enforces a maximum number of parameters allowed in function definitions.
218
- // This is usually to help readability but TS self-documents this kind of thing.
219
232
  "max-params": "off",
220
- // Statements can be as complicated as you like
221
233
  "max-statements": "off",
222
- // Enforces maximum number of statements allowed per line to 1.
223
234
  "max-statements-per-line": "error",
224
- // Allow any style of multiline comments
225
235
  "multiline-comment-style": "off",
226
- // Require constructor names to begin with a capital letter
227
236
  "new-cap": "error",
228
- // alert is often used while debugging code, which should be removed before
229
- // deployment to production.
230
237
  "no-alert": "error",
231
- // Use of the Array constructor to construct a new array is generally
232
- // discouraged in favor of array literal notation because of the
233
- // single-argument pitfall and because the Array global may be redefined.
234
- // The exception is when the Array constructor is used to intentionally
235
- // create sparse arrays of a specified size by giving the constructor a
236
- // single numeric argument.
237
238
  "no-array-constructor": "error",
238
- // The executor function can also be an async function.
239
- // However, this is usually a mistake:
240
- // https://eslint.org/docs/rules/no-async-promise-executor#top
241
239
  "no-async-promise-executor": "error",
242
- // Use Promise.all() instead
243
240
  "no-await-in-loop": "error",
244
- // Use of bitwise operators in JavaScript is very rare and often & or | is
245
- // simply a mistyped && or ||, which will lead to unexpected behavior.
246
241
  "no-bitwise": "error",
247
- // Use the producer methods Buffer.from, Buffer.alloc,
248
- // and Buffer.allocUnsafe instead.
249
242
  "no-buffer-constructor": "error",
250
- // arguments.caller and arguments.callee ave been deprecated in future
251
- // versions of JavaScript and their use is forbidden in ECMAScript 5 while
252
- // in strict mode.
253
243
  "no-caller": "error",
254
- // Disallows lexical declarations (let, const, function and class) in
255
- // case/default clauses. To ensure that the lexical declaration only applies
256
- // to the current case clause wrap your clauses in blocks.
257
244
  "no-case-declarations": "error",
258
- // Disallow modifying variables of class declarations
259
245
  "no-class-assign": "error",
260
- // Disallow comparing against -0
261
246
  "no-compare-neg-zero": "error",
262
- // Disallow assignment operators in conditional statements. e.g.
263
- // if (user.jobTitle = "manager") { }
264
247
  "no-cond-assign": "error",
265
- // Disallow the use of console
266
248
  "no-console": "warn",
267
- // Disallow modifying variables that are declared using const
268
249
  "no-const-assign": "error",
269
- // This rule identifies == and === comparisons which, based on the semantics
270
- // of the JavaScript language, will always evaluate to true or false.
271
250
  "no-constant-binary-expression": "error",
272
- // Disallow constant expressions in conditions
273
- // if (true) {}
274
251
  "no-constant-condition": "error",
275
- // Disallows return statements in the constructor of a class
276
252
  "no-constructor-return": "error",
277
- // Disallow continue statements.
278
- // When used incorrectly it makes code less testable, less readable and less
279
- // maintainable. Structured control flow statements such as if should be
280
- // used instead.
281
253
  "no-continue": "error",
282
- // Control characters are special, invisible characters in the ASCII range
283
- // 0-31. These characters are rarely used in JavaScript strings so a regular
284
- // expression containing these characters is most likely a mistake.
285
254
  "no-control-regex": "error",
286
- // The debugger statement is used to tell the executing JavaScript
287
- // environment to stop execution and start up a debugger at the current
288
- // point in the code. This has fallen out of favor as a good practice with
289
- // the advent of modern debugging and development tools.
290
255
  "no-debugger": "error",
291
- // The purpose of the delete operator is to remove a property from an
292
- // object. Using the delete operator on a variable might lead to unexpected
293
- // behavior.
294
256
  "no-delete-var": "error",
295
- // Require regex literals to escape division operators.
296
257
  "no-div-regex": "warn",
297
- // function foo(a, b, a) { } // duplicate "a" arg
298
258
  "no-dupe-args": "error",
299
- // class Foo {
300
- // bar() { console.log("hello") }
301
- // bar() { console.log("goodbye") } // duplicate class member
302
- // }
303
259
  "no-dupe-class-members": "error",
304
- // if (isSomething(x)) {
305
- // foo()
306
- // } else if (isSomething(x)) { // duplicate condition
307
- // bar()
308
- // }
309
260
  "no-dupe-else-if": "error",
310
- // const foo = {
311
- // bar: "baz",
312
- // bar: "qux" // duplicate key
313
- // }
314
261
  "no-dupe-keys": "error",
315
- // switch (a) {
316
- // case 1:
317
- // break
318
- // case 2:
319
- // break
320
- // case 1: // duplicate test expression
321
- // break
322
- // default:
323
- // break
324
- // }
325
262
  "no-duplicate-case": "error",
326
- // Combine named imports in single statement.
327
263
  "no-duplicate-imports": "error",
328
- // If an `if` block contains a return statement, the else block becomes
329
- // unnecessary. Its contents can be placed outside of the block.
330
264
  "no-else-return": "warn",
331
- // Disallow empty block statements.
332
265
  "no-empty": "error",
333
- // Disallow empty character classes in regular expressions.
334
266
  "no-empty-character-class": "error",
335
- // Disallow empty functions.
336
267
  "no-empty-function": "error",
337
- // Disallow empty destructuring patterns.
338
268
  "no-empty-pattern": "error",
339
269
  "no-empty-static-block": "error",
340
- // Error: if (foo == null)
341
- // Good: if (foo === null)
342
270
  "no-eq-null": "error",
343
- // Disallow eval()
344
271
  "no-eval": "error",
345
- // Disallow reassigning exceptions in catch clauses.
346
272
  "no-ex-assign": "error",
347
- // Disallow extending of native objects.
348
273
  "no-extend-native": "error",
349
- // Disallow unnecessary function binding
350
274
  "no-extra-bind": "warn",
351
- // In contexts such as an if statement's test where the result of the
352
- // expression will already be coerced to a Boolean, casting to a Boolean via
353
- // double negation (!!) or a Boolean call is unnecessary.
354
275
  "no-extra-boolean-cast": "warn",
355
- // If a loop contains no nested loops or switches, labeling the loop is unnecessary.
356
276
  "no-extra-label": "warn",
357
- // Disallow case statement fallthrough.
358
277
  "no-fallthrough": "error",
359
- // Disallow reassigning function declarations.
360
278
  "no-func-assign": "error",
361
- // Disallow assignment to native objects or read-only global variables.
362
279
  "no-global-assign": "error",
363
- // Disallow the type conversion with shorter notations.
364
280
  "no-implicit-coercion": "warn",
365
- // Disallow declarations in the global scope.
366
281
  "no-implicit-globals": "error",
367
- // There are some other ways to pass a string and have it interpreted as
368
- // JavaScript code that have similar concerns.
369
- // e.g. setTimeout("alert('Hi!');", 100);
370
282
  "no-implied-eval": "error",
371
- // Disallow assigning to imported bindings.
372
283
  "no-import-assign": "error",
373
- // Disallow inline comments after code.
374
284
  "no-inline-comments": "error",
375
- // Disallow variable or function declarations in nested blocks.
376
285
  "no-inner-declarations": "error",
377
- // Disallow invalid regular expression strings in RegExp constructors.
378
286
  "no-invalid-regexp": "error",
379
- // Disallow this keywords outside of classes or class-like objects.
380
287
  "no-invalid-this": "error",
381
- // Invalid or irregular whitespace causes issues with ECMAScript 5 parsers
382
- // and also makes code harder to debug in a similar nature to mixed tabs and spaces.
383
288
  "no-irregular-whitespace": "error",
384
- // The __iterator__ property was a SpiderMonkey extension to JavaScript that
385
- // could be used to create custom iterators that are compatible with
386
- // JavaScript's for in and for each constructs. However, this property is
387
- // now obsolete, so it should not be used.
388
289
  "no-iterator": "error",
389
- // Disallow labels that are variables names.
390
290
  "no-label-var": "error",
391
- // While convenient in some cases, labels tend to be used only rarely and
392
- // are frowned upon by some as a remedial form of flow control that is more
393
- // error prone and harder to understand.
394
291
  "no-labels": "error",
395
- // Disallow unnecessary nested blocks
396
292
  "no-lone-blocks": "error",
397
- // Disallow if statements as the only statement in else blocks.
398
293
  "no-lonely-if": "warn",
399
- // Writing functions within loops tends to result in errors due to the way
400
- // the function creates a closure around the loop.
401
294
  "no-loop-func": "error",
402
- // Disallow the use of number literals that immediately lose precision at
403
- // runtime when converted to a JS Number due to 64-bit floating-point rounding.
404
295
  "no-loss-of-precision": "error",
405
- // Disallowing magic numbers causes all sorts of problems
406
296
  "no-magic-numbers": "off",
407
- // Disallow characters which are made with multiple code points in character class syntax.
408
297
  "no-misleading-character-class": "error",
409
- // const foo = bar = "baz"
410
298
  "no-multi-assign": "error",
411
- // var x = "Line 1 \
412
- // Line 2"
413
299
  "no-multi-str": "error",
414
- // Negated conditions are more difficult to understand. Code can be made
415
- // more readable by inverting the condition instead.
416
300
  // This is handled by unicorn.
417
301
  "no-negated-condition": "off",
418
- // Disallow nested ternary expressions
419
302
  "no-nested-ternary": "error",
420
- // Disallows constructor calls using the new keyword that do not assign
421
- // the resulting object to a variable.
422
303
  "no-new": "error",
423
- // ❌ Function()
424
- // ✅ function()
425
304
  "no-new-func": "error",
426
- // ❌ new BigInt(12344555)
427
- // ✅ BigInt(12344555)
428
305
  "no-new-native-nonconstructor": "error",
429
- // ❌ var myObject = new Object()
430
- // ✅ var myObject = {}
431
306
  "no-new-object": "error",
432
- // Symbol is not intended to be used with the new operator, but to be called
433
- // as a function.
434
307
  "no-new-symbol": "error",
435
- // This rule aims to eliminate the use of String, Number, and Boolean with
436
- // the new operator. As such, it warns whenever it sees new String,
437
- // new Number, or new Boolean.
438
308
  "no-new-wrappers": "error",
439
- // Disallow \8 and \9 escape sequences in string literals
440
309
  "no-nonoctal-decimal-escape": "error",
441
- // This rule disallows calling the Math, JSON, Reflect and Atomics objects as functions.
442
310
  "no-obj-calls": "error",
443
311
  "no-object-constructor": "error",
444
- // the leading zero which identifies an octal literal has been a source of
445
- // confusion and error in JavaScript code, ECMAScript 5 deprecates the use
446
- // of octal numeric literals.
447
312
  "no-octal": "error",
448
- // As of the ECMAScript 5 specification, octal escape sequences in string
449
- // literals are deprecated and should not be used. Unicode escape sequences
450
- // should be used instead.
451
313
  "no-octal-escape": "error",
452
- // Assignment to variables declared as function parameters can be misleading
453
- // and lead to confusing behavior, as modifying function parameters will
454
- // also mutate the arguments object.
455
314
  "no-param-reassign": "error",
456
- // Because the unary ++ and -- operators are subject to automatic semicolon
457
- // insertion, differences in whitespace can change semantics of source code.
458
315
  "no-plusplus": "error",
459
- // Disallow returning values from Promise executor functions
460
316
  "no-promise-executor-return": "error",
461
- // __proto__ property has been deprecated as of ECMAScript 3.1 and shouldn't
462
- // be used in the code. Use Object.getPrototypeOf and Object.setPrototypeOf instead.
463
317
  "no-proto": "error",
464
- // Disallow use of Object.prototypes builtins directly.
465
318
  "no-prototype-builtins": "error",
466
- // Disallow variable redeclaration.
467
319
  "no-redeclare": "error",
468
- // Disallow multiple spaces in regular expression literals.
469
320
  "no-regex-spaces": "warn",
470
- // No export names are restricted
471
321
  "no-restricted-exports": "off",
472
- // Global variable names that are dangerous to use by mistake
473
322
  "no-restricted-globals": ["error", ..._confusingbrowserglobals2.default],
474
- // No imports are restricted
475
323
  "no-restricted-imports": "off",
476
- // No properties are restricted
477
324
  "no-restricted-properties": "off",
478
- // No syntax is restricted
479
325
  "no-restricted-syntax": "off",
480
- // Disallow assignment in return statement
481
326
  "no-return-assign": "error",
482
- // Disallows unnecessary return await
483
327
  "no-return-await": "error",
484
- // ❌ location.href = "javascript:void(0)"
485
328
  "no-script-url": "error",
486
- // Self assignments have no effect.
487
- // ❌ foo = foo
488
329
  "no-self-assign": "error",
489
- // Comparing a variable against itself is usually an error, either a typo or
490
- // refactoring error.
491
330
  "no-self-compare": "error",
492
- // Disallow use of the comma operator.
493
331
  "no-sequences": "error",
494
- // Disallow returning values from setters.
495
332
  "no-setter-return": "error",
496
- // Disallow variable declarations from shadowing variables declared in the outer scope.
497
333
  "no-shadow": "error",
498
- // ES5 Value Properties of the Global Object (NaN, Infinity, undefined) as
499
- // well as strict mode restricted identifiers eval and arguments are considered
500
- // to be restricted names in JavaScript. Defining them to mean something
501
- // else can have unintended consequences and confuse others reading the code.
502
334
  "no-shadow-restricted-names": "error",
503
- // This rule disallows sparse array literals which have "holes" where commas
504
- // are not preceded by elements. It does not apply to a trailing comma
505
- // following the last element. Use ignored values instead.
506
335
  "no-sparse-arrays": "error",
507
- // Disallow template literal placeholder syntax in regular strings.
508
336
  "no-template-curly-in-string": "error",
509
- // Simple ternaries are okay
510
337
  "no-ternary": "off",
511
- // Disallow use of this/super before calling super() in constructors.
512
338
  "no-this-before-super": "error",
513
- // Maintain consistency when throwing exception by disallowing to throw
514
- // literals and other expressions which cannot possibly be an Error object.
515
339
  "no-throw-literal": "error",
516
- // Disallow undeclared variables.
517
340
  "no-undef": "error",
518
- // Disallow initializing to undefined.
519
341
  "no-undef-init": "warn",
520
- // Allow undefined. Use no-global-assign and no-shadow-restricted-names
521
- // rules to prevent undefined from being shadowed or assigned a different value.
522
342
  "no-undefined": "off",
523
- // Allow dangling underscores in identifiers.
524
343
  "no-underscore-dangle": "off",
525
- // Disallow unmodified conditions of loops
526
344
  "no-unmodified-loop-condition": "error",
527
- // Disallow ternary operators when simpler alternatives exist.
528
345
  "no-unneeded-ternary": "warn",
529
- // Disallow unreachable code after return, throw, continue, and break statements.
530
346
  "no-unreachable": "error",
531
- // Disallow loops with a body that allows only one iteration
532
347
  "no-unreachable-loop": "error",
533
- // Disallow control flow statements in finally blocks.
534
348
  "no-unsafe-finally": "error",
535
- // Disallow negating the left operand of relational operators.
536
349
  "no-unsafe-negation": "error",
537
- // Disallow use of optional chaining in contexts where the `undefined` value is not allowed
538
350
  "no-unsafe-optional-chaining": "error",
539
- // An unused expression which has no effect on the state of the program
540
- // indicates a logic error.
541
351
  "no-unused-expressions": "error",
542
- // Labels that are declared and not used anywhere in the code are most
543
- // likely an error due to incomplete refactoring.
544
352
  "no-unused-labels": "warn",
545
353
  "no-unused-private-class-members": "error",
546
- // Variables must be used unless name starts with "ignored"
547
354
  "no-unused-vars": [
548
355
  "error",
549
356
  {
@@ -553,53 +360,23 @@ function base() {
553
360
  varsIgnorePattern: "[iI]gnored"
554
361
  }
555
362
  ],
556
- // It's possible to use identifiers before their formal declarations in code.
557
- // This can be confusing and some believe it is best to always declare
558
- // variables and functions before using them.
559
363
  "no-use-before-define": "error",
560
- // Do I need this? https://eslint.org/docs/rules/no-useless-backreference
364
+ // TODO Do I need this? https://eslint.org/docs/rules/no-useless-backreference
561
365
  "no-useless-backreference": "off",
562
- // Function.prototype.call() and Function.prototype.apply() are slower than
563
- // the normal function invocation.
564
366
  "no-useless-call": "error",
565
- // A catch clause that only rethrows the original error is redundant, and
566
- // has no effect on the runtime behavior of the program.
567
367
  "no-useless-catch": "error",
568
- // ❌ var foo = {['a']: 'b'}
569
- // ✅ var foo = {a: 'b'}
570
368
  "no-useless-computed-key": "error",
571
- // ❌ var foo = 'a' + 'b'
572
- // ✅ var foo = 'ab'
573
369
  "no-useless-concat": "error",
574
- // ES2015 provides a default class constructor if one is not specified. As
575
- // such, it isunnecessary to provide an empty constructor or one that simply
576
- // delegates into its parent class.
577
370
  "no-useless-constructor": "error",
578
- // Escaping non-special characters in strings, template literals, and
579
- // regular expressions doesn't have any effect.
580
371
  "no-useless-escape": "error",
581
- // Disallow renaming import, export, and destructured assignments to the same name.
582
372
  "no-useless-rename": "warn",
583
- // A return; statement with nothing after it is redundant, and has no effect
584
- // on the runtime behavior of a function. This can be confusing, so it's
585
- // better to disallow these redundant statements.
586
373
  "no-useless-return": "warn",
587
- // Require let or const instead of var.
588
374
  "no-var": "warn",
589
- // Disallow use of the void operator.
590
375
  "no-void": "error",
591
- // Allow TODOs and FIXMEs
592
376
  "no-warning-comments": "off",
593
- // The with statement is potentially problematic because it adds members of
594
- // an object to the current scope, making it impossible to tell what a
595
- // variable inside the block actually refers to.
596
377
  "no-with": "error",
597
- // Functions declared in object keys must conform to a certain style
598
- // Capitalised functions are exempt as they are probably constructor functions
599
378
  "object-shorthand": ["warn", "always", { ignoreConstructors: true }],
600
- // Prevent combined variable declarations
601
379
  "one-var": ["warn", "never"],
602
- // Disallow assignment operator shorthand where possible.
603
380
  "operator-assignment": ["warn", "never"],
604
381
  "padding-line-between-statements": [
605
382
  "warn",
@@ -614,52 +391,24 @@ function base() {
614
391
  ],
615
392
  // Can cause issues when Prettier is enabled
616
393
  "prefer-arrow-callback": "off",
617
- // If a variable is never reassigned, using the const declaration is better.
618
394
  "prefer-const": "warn",
619
395
  // Make compatible with Unicorn's no-unreadable-array-destructuring
620
396
  "prefer-destructuring": ["warn", { array: false, object: true }],
621
- // Introduced in ES2016, the infix exponentiation operator ** is an
622
- // alternative for the standard Math.pow function. Infix notation is
623
- // considered to be more readable and thus more preferable than the function notation.
624
397
  "prefer-exponentiation-operator": "warn",
625
- // Allow regex to be left as-is
626
398
  "prefer-named-capture-group": "off",
627
- // This rule disallows calls to parseInt() or Number.parseInt() if called
628
- // with two arguments: a string; and a radix option of 2 (binary), 8 (octal),
629
- // or 16 (hexadecimal).
630
399
  "prefer-numeric-literals": "warn",
631
- // Not supported by Typescript yet
400
+ // TODO Not supported by Typescript yet?
632
401
  "prefer-object-has-own": "off",
633
- // Prefer use of an object spread over Object.assign()
634
402
  "prefer-object-spread": "warn",
635
- // It is considered good practice to only pass instances of the built-in
636
- // Error object to the reject() function for user-defined errors in Promises.
637
- // Error objects automatically store a stack trace, which can be used to
638
- // debug an error by determining where it came from. If a Promise is rejected
639
- // with a non-Error value, it can be difficult to determine where the rejection occurred.
640
403
  "prefer-promise-reject-errors": "error",
641
- // Disallow use of the RegExp constructor in favor of regular expression literals.
642
404
  "prefer-regex-literals": "error",
643
- // Suggest using the rest parameters instead of `arguments`.
644
405
  "prefer-rest-params": "error",
645
- // Suggest using spread syntax instead of `.apply()`.
646
406
  "prefer-spread": "error",
647
- // Suggest using template literals instead of string concatenation.
648
407
  "prefer-template": "warn",
649
- // When using the parseInt() function it is common to omit the second argument,
650
- // the radix, and let the function try to determine from the first argument
651
- // what type of number it is. By default, parseInt() will autodetect decimal
652
- // and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also
653
- // autodetected octal literals, which caused problems because many developers
654
- // assumed a leading 0 would be ignored.
655
408
  "radix": "error",
656
- // Disallow assignments that can lead to race conditions due to usage of await or yield.
657
409
  "require-atomic-updates": "error",
658
- // Disallow async functions which have no await expression.
659
410
  "require-await": "error",
660
- // Enforce the use of 'u' flag on RegExp.
661
411
  "require-unicode-regexp": "error",
662
- // Disallow generator functions that do not have yield.
663
412
  "require-yield": "error",
664
413
  // Sorting imports is handled by simple-import-sort
665
414
  "sort-imports": "off",
@@ -672,27 +421,17 @@ function base() {
672
421
  natural: true
673
422
  }
674
423
  ],
675
- // Not required as one-var rule is set to 'error' and so there will never be vars to sort.
424
+ // Not required as one-var rule is set to 'error' and so there will
425
+ // never be vars to sort.
676
426
  "sort-vars": "off",
677
- // All comments must have a space after the //
678
- // This also allows /// reference comments
679
427
  "spaced-comment": ["warn", "always", { markers: ["/"] }],
680
- // Generally gets in the way as it's difficult to know when this may be required.
428
+ // Generally gets in the way as it's difficult to know when this may be
429
+ // required.
681
430
  "strict": "off",
682
- // Using description promotes easier debugging.
683
- // ✅ var foo = Symbol("some description")
684
431
  "symbol-description": "error",
685
- // Require calls to isNaN() when checking for NaN.
686
432
  "use-isnan": "error",
687
- // Enforce comparing typeof expressions against valid strings.
688
433
  "valid-typeof": ["error", { requireStringLiterals: true }],
689
- // By default variable declarations are always moved (“hoisted”) invisibly
690
- // to the top of their containing scope by the JavaScript interpreter.
691
- // This rule forces the programmer to represent that behavior by manually
692
- // moving the variable declaration to the top of its containing scope.
693
434
  "vars-on-top": "error",
694
- // ❌ if ('red' === color) {}
695
- // ✅ if (color === 'red') {}
696
435
  "yoda": "warn"
697
436
  }
698
437
  }
@@ -747,26 +486,13 @@ function imports() {
747
486
  "simple-import-sort": _eslintpluginsimpleimportsort2.default
748
487
  },
749
488
  rules: {
750
- // Prefer inline types
751
489
  "import/consistent-type-specifier-style": ["warn", "prefer-top-level"],
752
- // Reports funny business with exports,
753
- // like repeated exports of names or defaults
754
490
  "import/export": "error",
755
- // Stating exports at the end of the file can make refactoring a two-step process
756
491
  "import/exports-last": "off",
757
- // Same as import/exports-last
758
492
  "import/group-exports": "off",
759
- // There must be a line's space between imports and code
760
493
  "import/newline-after-import": "warn",
761
- // ❌ import {} from 'mod'
762
494
  "import/no-empty-named-blocks": "warn",
763
- // When there is only a single export from a module,
764
- // this _would_ prefer using default export over named export, but it
765
- // causes too many issues and it soon becomes tiresome with some tools
766
- // requiring defaults and others forbidding them or requiring a certain
767
- // named export.
768
495
  "import/prefer-default-export": "off",
769
- // Sort all the imports!
770
496
  "simple-import-sort/exports": "warn",
771
497
  "simple-import-sort/imports": "warn",
772
498
  // The rest of the rules, off until required
@@ -829,97 +555,59 @@ function jest() {
829
555
  jest: _eslintpluginjest2.default
830
556
  },
831
557
  rules: {
832
- // Consistent test function names
833
- // test
834
- // describe -> it
835
558
  "jest/consistent-test-it": [
836
559
  "error",
837
560
  { fn: "test", withinDescribe: "it" }
838
561
  ],
839
- // Enforce assertion to be made in a test body
840
562
  "jest/expect-expect": "error",
841
- // Have as many expects as you like
842
563
  "jest/max-expects": "off",
843
564
  "jest/max-nested-describe": "off",
844
- // Consistent expect methods
845
565
  "jest/no-alias-methods": "error",
846
566
  "jest/no-commented-out-tests": "error",
847
- // Prevent calling expect conditionally
848
567
  "jest/no-conditional-expect": "error",
849
568
  "jest/no-conditional-in-test": "error",
850
569
  "jest/no-deprecated-functions": "warn",
851
570
  "jest/no-disabled-tests": "warn",
852
- // Avoid using a callback in asynchronous tests and hooks
853
571
  "jest/no-done-callback": "error",
854
- // Do not allow multiple beforeEach, for example
855
572
  "jest/no-duplicate-hooks": "error",
856
- // Disallow using exports in files containing tests
857
573
  "jest/no-export": "error",
858
574
  "jest/no-focused-tests": "error",
859
575
  "jest/no-hooks": "off",
860
576
  "jest/no-identical-title": "error",
861
- // Conditional logic in tests is usually an indication that a test is attempting to cover too much
862
577
  "jest/no-if": "error",
863
- // Disallow string interpolation inside snapshots
864
578
  "jest/no-interpolation-in-snapshots": "error",
865
579
  "jest/no-jasmine-globals": "warn",
866
580
  "jest/no-large-snapshots": "off",
867
- // Disallow manually importing from __mocks__
868
581
  "jest/no-mocks-import": "error",
869
- // No methods that need restricting
870
582
  "jest/no-restricted-jest-methods": "off",
871
583
  "jest/no-restricted-matchers": "off",
872
- // No standalone expect in a describe block
873
584
  "jest/no-standalone-expect": "error",
874
- // Use .only and .skip over f and x
875
585
  "jest/no-test-prefixes": "warn",
876
- // Tests shouldn't return anything
877
586
  "jest/no-test-return-statement": "error",
878
587
  "jest/prefer-called-with": "off",
879
- // https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-comparison-matcher.md
880
588
  "jest/prefer-comparison-matcher": "warn",
881
589
  "jest/prefer-each": "error",
882
- // https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-equality-matcher.md
883
590
  "jest/prefer-equality-matcher": "error",
884
591
  "jest/prefer-expect-assertions": "off",
885
592
  "jest/prefer-expect-resolves": "warn",
886
- // Put lifecycle hooks in particular order
887
593
  "jest/prefer-hooks-in-order": "error",
888
- // beforeEach, beforeAll, afterEach etc. should be at top of test block
889
594
  "jest/prefer-hooks-on-top": "error",
890
- // Allow any case in test names
891
595
  "jest/prefer-lowercase-title": "off",
892
- // When working with mocks of functions that return promises, Jest provides
893
- // some API sugar functions to reduce the amount of boilerplate you have to write.
894
596
  "jest/prefer-mock-promise-shorthand": "warn",
895
597
  "jest/prefer-snapshot-hint": "error",
896
- // By overwriting a property with `jest.fn()` you have to manually restore
897
- // the original implementation when cleaning up. When using jest.spyOn()
898
- // Jest keeps track of changes, and they can be restored.
899
598
  "jest/prefer-spy-on": "error",
900
599
  "jest/prefer-strict-equal": "error",
901
600
  "jest/prefer-to-be": "warn",
902
- // expect(a.includes(b)).toBe(true) -> expect(a).toContain(b)
903
601
  "jest/prefer-to-contain": "error",
904
- // expect(files.length).toBe(1) -> expect(files).toHaveLength(1)
905
602
  "jest/prefer-to-have-length": "error",
906
- // When test cases are empty then it is better to mark them as test.todo
907
- // as it will be highlighted in the summary output
908
603
  "jest/prefer-todo": "error",
909
- // Require setup and tear down code to be within lifecycle hooks
910
604
  "jest/require-hook": "error",
911
- // Requiring a message ensures that the intended error is thrown
912
605
  "jest/require-to-throw-message": "error",
913
606
  "jest/require-top-level-describe": "off",
914
607
  "jest/unbound-method": "off",
915
608
  "jest/valid-describe-callback": "error",
916
609
  "jest/valid-expect": "error",
917
610
  "jest/valid-expect-in-promise": "error",
918
- // Titles are...
919
- // - not empty
920
- // - is a string
921
- // - not prefixed with their block name
922
- // - have no leading or trailing spaces
923
611
  "jest/valid-title": "error"
924
612
  }
925
613
  },
@@ -945,28 +633,15 @@ function node() {
945
633
  n: _eslintpluginn2.default
946
634
  },
947
635
  rules: {
948
- // Enforces return statements in callbacks of array's methods
949
636
  "n/callback-return": "error",
950
- // require() should be called only in the top level of a module to make it
951
- // easier to identify dependencies.
952
637
  "n/global-require": "error",
953
- // This rule expects that when you're using the callback pattern in Node.js
954
- // you'll handle the error.
955
638
  "n/handle-callback-err": "error",
956
- // Disallow require calls to be mixed with regular variable declarations.
957
639
  "n/no-mixed-requires": "error",
958
- // ❌ var appHeader = new require('app-header')
959
- // ✅ var AppHeader = require('app-header')
960
- // var appHeader = new AppHeader()
961
640
  "n/no-new-require": "error",
962
- // Disallow string concatenation when using __dirname and __filename.
963
- // Use path.join() instead.
964
641
  "n/no-path-concat": "error",
965
- // Allow env vars in code
966
642
  "n/no-process-env": "off",
967
643
  // Handled by Unicorn
968
644
  "n/no-process-exit": "off",
969
- // No modules are restricted
970
645
  "n/no-restricted-require": "off",
971
646
  // I like synchronous functions
972
647
  "n/no-sync": "off",
@@ -1217,28 +892,20 @@ function react() {
1217
892
  "react/default-props-match-prop-types": "error",
1218
893
  "react/destructuring-assignment": "error",
1219
894
  "react/display-name": "error",
1220
- // Components can use any props.
1221
895
  "react/forbid-component-props": "off",
1222
896
  "react/forbid-dom-props": "error",
1223
897
  "react/forbid-elements": "error",
1224
898
  "react/forbid-foreign-prop-types": "error",
1225
899
  "react/forbid-prop-types": "error",
1226
- // Functional components can use any style.
1227
900
  "react/function-component-definition": "off",
1228
901
  "react/hook-use-state": "error",
1229
902
  "react/iframe-missing-sandbox": "error",
1230
- // ❌ <Hello personal={true} />
1231
- // ✅ <Hello personal />
1232
903
  "react/jsx-boolean-value": "warn",
1233
- // disallow unnecessary curly braces in JSX props and/or children.
1234
904
  "react/jsx-curly-brace-presence": "warn",
1235
- // Allow JSX in any files
1236
905
  "react/jsx-filename-extension": "off",
1237
- // Enforce shorthand for React fragments.
1238
906
  "react/jsx-fragments": "warn",
1239
907
  "react/jsx-handler-names": "error",
1240
908
  "react/jsx-key": "error",
1241
- // Unlimited JSX nesting.
1242
909
  "react/jsx-max-depth": "off",
1243
910
  // I haven't found any modern benchmarks for disallowing inline arrow
1244
911
  // functions, and quite frankly it feels like this "optimisation" is just
@@ -1252,20 +919,14 @@ function react() {
1252
919
  "react/jsx-no-comment-textnodes": "error",
1253
920
  "react/jsx-no-constructed-context-values": "error",
1254
921
  "react/jsx-no-duplicate-props": "error",
1255
- // In React, you might end up rendering unexpected values like 0 or NaN.
1256
- // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
1257
922
  "react/jsx-no-leaked-render": "warn",
1258
- // ✅ <div>test</div>
1259
- // ✅ <div>{'test'}</div>
1260
923
  "react/jsx-no-literals": "off",
1261
924
  "react/jsx-no-script-url": "error",
1262
925
  "react/jsx-no-target-blank": "error",
1263
926
  "react/jsx-no-undef": "error",
1264
927
  "react/jsx-no-useless-fragment": "warn",
1265
928
  "react/jsx-pascal-case": "error",
1266
- // Allow prop spreading, you know the dangers!
1267
929
  "react/jsx-props-no-spreading": "off",
1268
- // Alphabetical sorting of props
1269
930
  // TODO there's other options in this one that could be useful.
1270
931
  "react/jsx-sort-props": ["warn", { reservedFirst: true }],
1271
932
  "react/jsx-uses-react": "error",
@@ -1284,10 +945,8 @@ function react() {
1284
945
  "react/no-find-dom-node": "error",
1285
946
  "react/no-invalid-html-attribute": "error",
1286
947
  "react/no-is-mounted": "error",
1287
- // Allow as many components per file as you like
1288
948
  "react/no-multi-comp": "off",
1289
949
  "react/no-namespace": "error",
1290
- // Prevent potential unnecessary rerenders, and performance regressions
1291
950
  "react/no-object-type-as-default-prop": "error",
1292
951
  "react/no-redundant-should-component-update": "error",
1293
952
  "react/no-render-return-value": "error",
@@ -1296,8 +955,6 @@ function react() {
1296
955
  "react/no-this-in-sfc": "error",
1297
956
  "react/no-typos": "error",
1298
957
  "react/no-unescaped-entities": "error",
1299
- // ❌ <div class="hello">Hello World</div>
1300
- // ✅ <div className="hello">Hello World</div>
1301
958
  "react/no-unknown-property": "warn",
1302
959
  "react/no-unsafe": "error",
1303
960
  "react/no-unstable-nested-components": "error",
@@ -1310,15 +967,10 @@ function react() {
1310
967
  "react/prefer-read-only-props": "error",
1311
968
  "react/prefer-stateless-function": "error",
1312
969
  "react/prop-types": "off",
1313
- // React is no longer required to be imported to use JSX
1314
970
  "react/react-in-jsx-scope": "off",
1315
- // Enforce a defaultProps definition for every prop that is not a required prop
1316
- // TODO turn this back on and create a react-typescript rule set for disabling thing like this.
1317
971
  "react/require-default-props": "off",
1318
- // Do not enforce React components to have a shouldComponentUpdate method.
1319
972
  "react/require-optimization": "off",
1320
973
  "react/require-render-return": "error",
1321
- // Prevent extra closing tags for components without children.
1322
974
  "react/self-closing-comp": "warn",
1323
975
  "react/sort-comp": "error",
1324
976
  "react/sort-default-props": "error",
@@ -1330,9 +982,7 @@ function react() {
1330
982
  /**
1331
983
  * Hooks
1332
984
  */
1333
- // Checks effect dependencies
1334
985
  "react-hooks/exhaustive-deps": "warn",
1335
- // Checks rules of Hooks
1336
986
  "react-hooks/rules-of-hooks": "error"
1337
987
  },
1338
988
  settings: {
@@ -1353,13 +1003,11 @@ function switchCase() {
1353
1003
  "switch-case": _eslintpluginswitchcase2.default
1354
1004
  },
1355
1005
  rules: {
1356
- // Switches must have new lines between case groups
1357
1006
  "switch-case/newline-between-switch-case": [
1358
1007
  "warn",
1359
1008
  "always",
1360
1009
  { fallthrough: "never" }
1361
1010
  ],
1362
- // It can be useful for switch cases to have their own scope.
1363
1011
  "switch-case/no-case-curly": "off"
1364
1012
  }
1365
1013
  }
@@ -1375,7 +1023,7 @@ function typescript() {
1375
1023
  files: ["**/*.{ts,tsx,astro}"],
1376
1024
  languageOptions: {
1377
1025
  // @ts-expect-error -- does not confirm to type
1378
- parser: _parser2.default
1026
+ parser: parserTypescript2
1379
1027
  },
1380
1028
  plugins: {
1381
1029
  // @ts-expect-error -- does not confirm to type
@@ -1452,7 +1100,7 @@ function typescript() {
1452
1100
  "no-empty-function": "off",
1453
1101
  "no-extra-semi": "off",
1454
1102
  /**
1455
- * These are for type checking which I don't use eslint for
1103
+ * These require type checking
1456
1104
  */
1457
1105
  "@typescript-eslint/await-thenable": "off",
1458
1106
  "@typescript-eslint/consistent-type-exports": "off",
@@ -1481,6 +1129,7 @@ function typescript() {
1481
1129
  "@typescript-eslint/no-unsafe-member-access": "off",
1482
1130
  "@typescript-eslint/no-unsafe-return": "off",
1483
1131
  "@typescript-eslint/non-nullable-type-assertion-style": "off",
1132
+ "@typescript-eslint/prefer-destructuring": "off",
1484
1133
  "@typescript-eslint/prefer-includes": "off",
1485
1134
  "@typescript-eslint/prefer-nullish-coalescing": "off",
1486
1135
  "@typescript-eslint/prefer-optional-chain": "off",
@@ -1543,22 +1192,14 @@ function typescript() {
1543
1192
  /**
1544
1193
  * The rest
1545
1194
  */
1546
- // Requires using T[] over Array<T> for arrays
1547
1195
  "@typescript-eslint/array-type": ["warn", { default: "array" }],
1548
- // Bans // tslint:<rule-flag> comments from being used
1549
1196
  "@typescript-eslint/ban-tslint-comment": "warn",
1550
- // Ensures that literals on classes are exposed in a consistent style
1551
1197
  "@typescript-eslint/class-literal-property-style": "warn",
1552
1198
  "@typescript-eslint/class-methods-use-this": "off",
1553
- // https://typescript-eslint.io/rules/consistent-generic-constructors/
1554
1199
  "@typescript-eslint/consistent-generic-constructors": "warn",
1555
- // Enforce the use of the record type
1556
1200
  "@typescript-eslint/consistent-indexed-object-style": "warn",
1557
- // Enforces consistent usage of type assertions
1558
1201
  "@typescript-eslint/consistent-type-assertions": "error",
1559
- // Enforce using types for object type definitions
1560
1202
  "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
1561
- // Enforces consistent usage of type imports
1562
1203
  "@typescript-eslint/consistent-type-imports": [
1563
1204
  "warn",
1564
1205
  {
@@ -1566,77 +1207,38 @@ function typescript() {
1566
1207
  prefer: "type-imports"
1567
1208
  }
1568
1209
  ],
1569
- // Enforce default parameters to be last
1570
1210
  "@typescript-eslint/default-param-last": ["error"],
1571
- // Don't mind if functions do not have return types.
1572
1211
  "@typescript-eslint/explicit-function-return-type": "off",
1573
- // Require explicit accessibility modifiers ("public") on class properties and methods
1574
1212
  "@typescript-eslint/explicit-member-accessibility": "warn",
1575
- // Initialise vairables however you like
1576
1213
  "@typescript-eslint/init-declarations": "off",
1577
1214
  "@typescript-eslint/lines-between-class-members": [
1578
1215
  "warn",
1579
1216
  "always",
1580
1217
  { exceptAfterOverload: true }
1581
1218
  ],
1582
- // Require a consistent member declaration order
1583
1219
  "@typescript-eslint/member-ordering": "error",
1584
- // ❌
1585
- // interface T1 {
1586
- // func(arg: string): number;
1587
- // }
1588
- // ✅
1589
- // interface T1 {
1590
- // func: (arg: string) => number;
1591
- // }
1592
1220
  "@typescript-eslint/method-signature-style": "warn",
1593
- // Disallow non-null assertion in locations that may be confusing
1594
1221
  "@typescript-eslint/no-confusing-non-null-assertion": "warn",
1595
- // Disallow duplicate class members
1596
1222
  "@typescript-eslint/no-dupe-class-members": "error",
1597
- // ❌
1598
- // enum E {
1599
- // A = 0,
1600
- // B = 0,
1601
- // }
1602
- // ✅
1603
- // enum E {
1604
- // A = 0,
1605
- // B = 1,
1606
- // }
1607
1223
  "@typescript-eslint/no-duplicate-enum-values": "error",
1608
- // Deleting missing key/value is safe
1609
1224
  "@typescript-eslint/no-dynamic-delete": "off",
1610
- // ❌ const bar = foo!!!.bar
1611
- // ✅ const bar = foo!.bar
1612
1225
  "@typescript-eslint/no-extra-non-null-assertion": "warn",
1613
- // Warns when a class is accidentally used as a namespace
1614
1226
  "@typescript-eslint/no-extraneous-class": "error",
1615
1227
  "@typescript-eslint/no-import-type-side-effects": "warn",
1616
- // Disallow this keywords outside of classes or class-like objects
1617
1228
  "@typescript-eslint/no-invalid-this": "error",
1618
- // Disallows usage of void type outside of generic or return types
1619
1229
  "@typescript-eslint/no-invalid-void-type": "error",
1620
- // Disallow function declarations that contain unsafe references inside loop statements
1621
1230
  "@typescript-eslint/no-loop-func": "error",
1622
- // Disallow literal numbers that lose precision
1623
1231
  "@typescript-eslint/no-loss-of-precision": ["error"],
1624
- // Disallowing magic numbers causes all sorts of problems
1625
1232
  "@typescript-eslint/no-magic-numbers": "off",
1626
1233
  "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
1627
1234
  "@typescript-eslint/no-redeclare": "error",
1628
1235
  "@typescript-eslint/no-require-imports": "error",
1629
1236
  "@typescript-eslint/no-restricted-imports": "off",
1630
- // Disallow variable declarations from shadowing variables declared in the outer scope
1631
1237
  "@typescript-eslint/no-shadow": ["error"],
1632
- // Aliasing can be useful
1633
1238
  "@typescript-eslint/no-type-alias": "off",
1634
- // Disallows unnecessary constraints on generic types
1635
1239
  "@typescript-eslint/no-unnecessary-type-constraint": "warn",
1636
1240
  "@typescript-eslint/no-unsafe-declaration-merging": "error",
1637
- // Aims to eliminate unused expressions which have no effect on the state of the program.
1638
1241
  "@typescript-eslint/no-unused-expressions": ["error"],
1639
- // Variables must be used unless name ends with "ignored"
1640
1242
  "@typescript-eslint/no-unused-vars": [
1641
1243
  "error",
1642
1244
  {
@@ -1648,7 +1250,6 @@ function typescript() {
1648
1250
  ],
1649
1251
  "@typescript-eslint/no-use-before-define": "error",
1650
1252
  "@typescript-eslint/no-useless-constructor": "error",
1651
- // Disallow empty exports that don't change anything in a module file
1652
1253
  "@typescript-eslint/no-useless-empty-export": "warn",
1653
1254
  "@typescript-eslint/padding-line-between-statements": [
1654
1255
  "error",
@@ -1661,19 +1262,15 @@ function typescript() {
1661
1262
  { blankLine: "always", next: "*", prev: "multiline-var" },
1662
1263
  { blankLine: "always", next: "multiline-var", prev: "*" }
1663
1264
  ],
1664
- // Not sure I need this, how many classes do I write?!
1665
- // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/parameter-properties.md
1666
1265
  "@typescript-eslint/parameter-properties": "off",
1667
1266
  "@typescript-eslint/prefer-enum-initializers": "error",
1668
1267
  // Unicorn does this better by providing a fixer
1669
1268
  "@typescript-eslint/prefer-for-of": "off",
1670
1269
  "@typescript-eslint/prefer-function-type": "warn",
1671
- // Require that all enum members be literal values to prevent unintended enum member name shadow issues.
1672
1270
  "@typescript-eslint/prefer-literal-enum-member": "error",
1673
- // Recommends using // @ts-expect-error over // @ts-ignore
1674
1271
  "@typescript-eslint/prefer-ts-expect-error": "warn",
1675
1272
  "@typescript-eslint/sort-type-constituents": "warn",
1676
- // Not sure if required yet. Might be too strict and produce noist code.
1273
+ // TODO Not sure if required yet. Might be too strict and produce noisy code.
1677
1274
  "@typescript-eslint/typedef": "off",
1678
1275
  "@typescript-eslint/unified-signatures": "error"
1679
1276
  }
@@ -1692,243 +1289,129 @@ function unicorn() {
1692
1289
  rules: {
1693
1290
  // This rule is superseded by the unicorn version below
1694
1291
  "no-nested-ternary": "off",
1695
- // Improve regexes by making them shorter, consistent, and safer
1696
1292
  "unicorn/better-regex": "warn",
1697
- // Catch error argument name should be "error"
1698
1293
  "unicorn/catch-error-name": "error",
1699
- // Use destructured variables over properties
1700
1294
  "unicorn/consistent-destructuring": "warn",
1701
- // Move function definitions to the highest possible scope
1702
1295
  "unicorn/consistent-function-scoping": [
1703
1296
  "error",
1704
1297
  { checkArrowFunctions: false }
1705
1298
  ],
1706
- // Custom Error classes must conform to standard
1707
1299
  "unicorn/custom-error-definition": "warn",
1708
- // Enforce no spaces between braces
1709
1300
  "unicorn/empty-brace-spaces": "warn",
1710
- // Enforces a message value to be passed in when throwing built-in Error
1711
1301
  "unicorn/error-message": "error",
1712
- // Enforces defining escape sequence values with uppercase characters rather
1713
- // than lowercase ones. This promotes readability by making the escaped
1714
- // value more distinguishable from the identifier.
1715
1302
  "unicorn/escape-case": "warn",
1716
- // Allows todo/fixme to be given expiry conditions and will error when met
1717
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/expiring-todo-comments.md
1718
1303
  "unicorn/expiring-todo-comments": "error",
1719
1304
  // Don't care how if(blah.length) is checked
1720
1305
  "unicorn/explicit-length-check": "off",
1721
- // Kebab-case only
1722
1306
  "unicorn/filename-case": "error",
1723
- // Enforces requiring index file with . instead of ./, ./index or ./index.js
1724
- // Turned off for imports where this can mess with ESM.
1725
1307
  "unicorn/import-index": ["warn", { ignoreImports: true }],
1726
- // Not sure if this is useful yet
1308
+ // TODO Not sure if this is useful yet
1727
1309
  "unicorn/import-style": "off",
1728
- // Enforce the use of new for all builtins, except String, Number and Boolean
1729
1310
  "unicorn/new-for-builtins": "warn",
1730
- // Enforce specifying rules to disable in eslint-disable comments
1731
1311
  "unicorn/no-abusive-eslint-disable": "error",
1732
- // Allow passing a function reference directly to iterator methods
1733
1312
  "unicorn/no-array-callback-reference": "off",
1734
- // Prefer for…of over Array#forEach(…)
1735
1313
  "unicorn/no-array-for-each": "warn",
1736
- // Disallow using the this argument in array methods
1737
1314
  "unicorn/no-array-method-this-argument": "warn",
1738
- // Enforce combining multiple Array#push() into one call
1739
1315
  "unicorn/no-array-push-push": "warn",
1740
- // for..of is much easier to read
1741
1316
  "unicorn/no-array-reduce": "error",
1742
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md
1743
1317
  "unicorn/no-await-expression-member": "warn",
1744
- // Do not use leading/trailing space between console.log parameters
1745
1318
  "unicorn/no-console-spaces": "warn",
1746
- // Do not use document.cookie directly
1747
1319
  "unicorn/no-document-cookie": "error",
1748
- // Disallow empty files
1749
1320
  // TODO turn back on when it can exclude files. As this warns about the
1750
1321
  // auto-generated next-env.d.ts file.
1751
1322
  "unicorn/no-empty-file": "off",
1752
- // Do not use a for loop that can be replaced with a for-of loop
1753
1323
  "unicorn/no-for-loop": "warn",
1754
- // Enforce the use of Unicode escapes instead of hexadecimal escapes
1755
1324
  "unicorn/no-hex-escape": "warn",
1756
- // Require Array.isArray() instead of instanceof Array
1757
1325
  "unicorn/no-instanceof-array": "warn",
1758
- // The removeEventListener function must be called with a reference to the same
1759
- // function that was passed to addEventListener.
1760
1326
  "unicorn/no-invalid-remove-event-listener": "error",
1761
- // Disallow identifiers (var names) starting with new.
1762
- // Do not check properties and allow "class" so that "className" is allowed.
1763
1327
  "unicorn/no-keyword-prefix": [
1764
1328
  "error",
1765
- { checkProperties: false, disallowedPrefixes: ["new"] }
1329
+ {
1330
+ // Do not check properties and allow "class" so that "className" is
1331
+ // allowed.
1332
+ checkProperties: false,
1333
+ disallowedPrefixes: ["new"]
1334
+ }
1766
1335
  ],
1767
- // This rule adds onto the built-in no-lonely-if rule, which only forbids if
1768
- // statements in else, not in if.
1769
1336
  "unicorn/no-lonely-if": "warn",
1770
- // This is an improved version of the no-negated-condition ESLint rule that
1771
- // makes it automatically fixable. ESLint did not want to make it fixable.
1772
1337
  "unicorn/no-negated-condition": "warn",
1773
- // Improved version of the no-nested-ternary ESLint rule, which allows cases
1774
- // where the nested ternary is only one level and wrapped in parens.
1775
1338
  "unicorn/no-nested-ternary": "warn",
1776
- // Disallow new Array()
1777
1339
  "unicorn/no-new-array": "warn",
1778
- // Enforce the use of Buffer.from() and Buffer.alloc() instead of the
1779
- // deprecated new Buffer()
1780
1340
  "unicorn/no-new-buffer": "warn",
1781
- // Allow the use of the null literal, it useful for React components and empty JSON values.
1782
1341
  "unicorn/no-null": "off",
1783
- // Disallow the use of objects as default parameters
1784
1342
  "unicorn/no-object-as-default-parameter": "error",
1785
- // Extension to ESLint's no-process-exit rule, that allows process.exit() to
1786
- // be called in files that start with a hashbang → #!/usr/bin/env node
1787
1343
  "unicorn/no-process-exit": "error",
1788
- // A class with only static members could just be an object instead
1789
1344
  "unicorn/no-static-only-class": "error",
1790
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-thenable.md
1791
1345
  "unicorn/no-thenable": "error",
1792
- // Disallow assigning this to a variable
1793
1346
  "unicorn/no-this-assignment": "error",
1794
- // Checking if a value is undefined by using typeof value === 'undefined' is needlessly verbose.
1795
1347
  "unicorn/no-typeof-undefined": "warn",
1796
- // Disallow awaiting non-promise values
1797
1348
  "unicorn/no-unnecessary-await": "warn",
1798
- // Disallow [,, foo], use ignored vars instead
1799
1349
  "unicorn/no-unreadable-array-destructuring": "error",
1800
- // IIFE with parenthesized arrow function body is considered unreadable
1801
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md
1802
1350
  "unicorn/no-unreadable-iife": "error",
1803
- // Uses safe-regex to disallow potentially catastrophic exponential-time regular expressions.
1804
- // Turned off for now, even Sindre doesn't like it: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/153
1351
+ // Turned off for now, even Sindre doesn't like it:
1352
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/153
1805
1353
  "unicorn/no-unsafe-regex": "off",
1806
1354
  // Recommended config turned this off so I will too
1807
1355
  "unicorn/no-unused-properties": "off",
1808
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-fallback-in-spread.md
1809
1356
  "unicorn/no-useless-fallback-in-spread": "warn",
1810
- // Disallow useless array length check
1811
1357
  "unicorn/no-useless-length-check": "warn",
1812
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md
1813
1358
  "unicorn/no-useless-promise-resolve-reject": "warn",
1814
- // Disallow useless spread
1815
1359
  "unicorn/no-useless-spread": "warn",
1816
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md
1817
1360
  "unicorn/no-useless-switch-case": "error",
1818
- // ❌ let foo = undefined;
1819
- // ✅ let foo;
1820
1361
  "unicorn/no-useless-undefined": "warn",
1821
- // Disallow number literals with zero fractions or dangling dots
1822
1362
  "unicorn/no-zero-fractions": "warn",
1823
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
1824
1363
  "unicorn/number-literal-case": "warn",
1825
- // Enforce the style of numeric separators by correctly grouping digits
1826
1364
  "unicorn/numeric-separators-style": "warn",
1827
- // Prefer .addEventListener() and .removeEventListener() over on-functions
1828
1365
  "unicorn/prefer-add-event-listener": "warn",
1829
- // Prefer .find(…) over the first element from .filter(…)
1830
1366
  "unicorn/prefer-array-find": "warn",
1831
- // Prefer Array#flat() over legacy techniques to flatten arrays
1832
1367
  "unicorn/prefer-array-flat": "warn",
1833
- // Prefer .flatMap(…) over .map(…).flat()
1834
1368
  "unicorn/prefer-array-flat-map": "warn",
1835
- // Prefer Array#indexOf() over Array#findIndex() when looking for the index of an item
1836
1369
  "unicorn/prefer-array-index-of": "warn",
1837
- // Prefer using Array#some over Array#find when ensuring at least one element
1838
- // in the array passes a given check.
1839
1370
  "unicorn/prefer-array-some": "error",
1840
- // Prefer .at() method for index access and String#charAt()
1841
1371
  "unicorn/prefer-at": "warn",
1842
- // Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…)
1843
1372
  "unicorn/prefer-blob-reading-methods": "error",
1844
- // Prefer String#codePointAt(…) over String#charCodeAt(…)
1845
- // and String.fromCodePoint(…) over String.fromCharCode(…)
1846
1373
  "unicorn/prefer-code-point": "error",
1847
- // Prefer Date.now() to get the number of milliseconds since the Unix Epoch
1848
1374
  "unicorn/prefer-date-now": "warn",
1849
- // Prefer default parameters over reassignment
1850
1375
  "unicorn/prefer-default-parameters": "warn",
1851
- // Prefer Node#append() over Node#appendChild()
1852
1376
  "unicorn/prefer-dom-node-append": "warn",
1853
- // Prefer using .dataset on DOM elements over .setAttribute(…)
1854
1377
  "unicorn/prefer-dom-node-dataset": "warn",
1855
- // Prefer node.remove() over parentNode.removeChild(node) and parentElement.removeChild(node)
1856
1378
  "unicorn/prefer-dom-node-remove": "warn",
1857
- // Prefer .textContent over .innerText
1858
1379
  "unicorn/prefer-dom-node-text-content": "warn",
1859
- // Prefer EventTarget over EventEmitter.
1860
1380
  "unicorn/prefer-event-target": "error",
1861
- // Prefer `export…from` when re-exporting
1862
1381
  "unicorn/prefer-export-from": "warn",
1863
- // Prefer .includes() over .indexOf() when checking for existence or non-existence
1864
1382
  "unicorn/prefer-includes": "warn",
1865
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-json-parse-buffer.md
1866
1383
  "unicorn/prefer-json-parse-buffer": "warn",
1867
- // Prefer KeyboardEvent#key over KeyboardEvent#keyCode
1868
1384
  "unicorn/prefer-keyboard-event-key": "warn",
1869
- // Disallow ternary operators when simpler logical operator alternatives exist.
1870
1385
  "unicorn/prefer-logical-operator-over-ternary": "warn",
1871
- // Enforce the use of Math.trunc instead of bitwise operators
1872
1386
  "unicorn/prefer-math-trunc": "warn",
1873
- // e.g. foo.insertBefore(baz, bar) -> foo.before(bar, 'baz')
1874
1387
  "unicorn/prefer-modern-dom-apis": "warn",
1875
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md
1876
1388
  "unicorn/prefer-modern-math-apis": "warn",
1877
1389
  // Not ready yet for ESM modules
1878
1390
  // https://github.com/microsoft/TypeScript/issues/33079
1879
1391
  "unicorn/prefer-module": "off",
1880
- // If a function is equivalent to String, Number, BigInt, Boolean, or Symbol,
1881
- // you should use the built-in one directly. Wrapping the built-in in a function is moot.
1882
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-native-coercion-functions.md
1883
1392
  "unicorn/prefer-native-coercion-functions": "warn",
1884
- // Prefer negative index over .length - index
1885
- // for {String,Array,TypedArray}#slice() and Array#splice()
1886
1393
  "unicorn/prefer-negative-index": "warn",
1887
- // Prefer using the node: protocol when importing Node.js builtin modules
1888
1394
  // TODO seems like this is not well supported by webpack yet
1889
1395
  "unicorn/prefer-node-protocol": "off",
1890
- // Prefer Number static properties over global ones
1891
1396
  "unicorn/prefer-number-properties": "warn",
1892
- // Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object
1893
1397
  "unicorn/prefer-object-from-entries": "warn",
1894
- // Prefer Object.hasOwn(…) over Object.prototype.hasOwnProperty.call(…)
1895
1398
  "unicorn/prefer-object-has-own": "warn",
1896
- // Prefer omitting the catch binding parameter
1897
1399
  "unicorn/prefer-optional-catch-binding": "warn",
1898
- // Prefer borrowing methods from the prototype instead of methods from an instance
1899
1400
  "unicorn/prefer-prototype-methods": "warn",
1900
- // Prefer .querySelector() over .getElementById(),
1901
- // .querySelectorAll() over .getElementsByClassName() and .getElementsByTagName()
1902
1401
  "unicorn/prefer-query-selector": "warn",
1903
- // Prefer Reflect.apply() over Function#apply()
1904
1402
  "unicorn/prefer-reflect-apply": "warn",
1905
- // Prefer RegExp#test() over String#match() and RegExp#exec()
1906
1403
  "unicorn/prefer-regexp-test": "warn",
1907
- // Prefer Set#has() over Array#includes() when checking for existence or non-existence
1908
- // Set#has() is faster than Array#includes().
1909
1404
  "unicorn/prefer-set-has": "warn",
1910
- // Prefer using Set#size instead of Array#length
1911
1405
  "unicorn/prefer-set-size": "warn",
1912
- // Prefer the spread operator over Array.from()
1913
1406
  "unicorn/prefer-spread": "warn",
1914
- // Prefer String#replaceAll() over regex searches with the global flag
1915
1407
  "unicorn/prefer-string-replace-all": "warn",
1916
- // Prefer String#slice() over String#substr() and String#substring()
1917
1408
  "unicorn/prefer-string-slice": "warn",
1918
- // Prefer String#startsWith() & String#endsWith() over more complex alternatives
1919
1409
  "unicorn/prefer-string-starts-ends-with": "error",
1920
- // Prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight()
1921
1410
  "unicorn/prefer-string-trim-start-end": "warn",
1922
- // Use whatever feels correct in the moment
1923
1411
  "unicorn/prefer-switch": "off",
1924
- // Prefer ternary expressions over simple if-else statements
1925
1412
  "unicorn/prefer-ternary": ["warn", "only-single-line"],
1926
- // Prefer top-level await over top-level promises and async function calls
1927
1413
  "unicorn/prefer-top-level-await": "error",
1928
- // Enforce throwing TypeError in type checking conditions
1929
1414
  "unicorn/prefer-type-error": "warn",
1930
- // Using complete words results in more readable code. Not everyone knows all your abbreviations.
1931
- // Code is written only once, but read many times.
1932
1415
  "unicorn/prevent-abbreviations": [
1933
1416
  "warn",
1934
1417
  {
@@ -1943,22 +1426,13 @@ function unicorn() {
1943
1426
  }
1944
1427
  }
1945
1428
  ],
1946
- // Enforce the use of regex shorthands to improve readability
1947
1429
  "unicorn/regex-shorthand": "warn",
1948
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/relative-url-style.md
1949
1430
  "unicorn/relative-url-style": "warn",
1950
- // Enforce using the separator argument with Array#join()
1951
1431
  "unicorn/require-array-join-separator": "warn",
1952
- // Enforce using the digits argument with Number#toFixed()
1953
1432
  "unicorn/require-number-to-fixed-digits-argument": "warn",
1954
- // Enforce using the targetOrigin argument with window.postMessage()
1955
1433
  "unicorn/require-post-message-target-origin": "error",
1956
- // No swaps needed yet
1957
1434
  "unicorn/string-content": "off",
1958
- // Only allow braces when there are variable declaration or function
1959
- // declaration which requires a scope.
1960
1435
  "unicorn/switch-case-braces": ["warn", "avoid"],
1961
- // Fix whitespace-insensitive template indentation
1962
1436
  "unicorn/template-indent": [
1963
1437
  "warn",
1964
1438
  {
@@ -1966,7 +1440,6 @@ function unicorn() {
1966
1440
  }
1967
1441
  ],
1968
1442
  "unicorn/text-encoding-identifier-case": "error",
1969
- // Require new when throwing an error
1970
1443
  "unicorn/throw-new-error": "warn"
1971
1444
  }
1972
1445
  }