@will-stone/eslint-config 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2089 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => factory
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/factory.ts
38
+ var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
39
+
40
+ // src/configs/astro.ts
41
+ var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
42
+ var import_astro_eslint_parser = __toESM(require("astro-eslint-parser"), 1);
43
+ var import_eslint_plugin_astro = __toESM(require("eslint-plugin-astro"), 1);
44
+ function astro() {
45
+ return [
46
+ {
47
+ files: ["**/*.astro"],
48
+ languageOptions: {
49
+ // @ts-expect-error -- does not confirm to type
50
+ parser: import_astro_eslint_parser.default,
51
+ parserOptions: {
52
+ extraFileExtensions: [".astro"],
53
+ parser: import_parser.default
54
+ }
55
+ },
56
+ plugins: {
57
+ // @ts-expect-error -- does not confirm to type
58
+ astro: import_eslint_plugin_astro.default
59
+ },
60
+ // @ts-expect-error -- does not confirm to type
61
+ rules: import_eslint_plugin_astro.configs.recommended.rules
62
+ }
63
+ ];
64
+ }
65
+
66
+ // src/configs/base.ts
67
+ var import_confusing_browser_globals = __toESM(require("confusing-browser-globals"), 1);
68
+ var import_globals = __toESM(require("globals"), 1);
69
+ function base() {
70
+ return [
71
+ {
72
+ languageOptions: {
73
+ globals: {
74
+ ...import_globals.default.browser,
75
+ ...import_globals.default.es2021
76
+ }
77
+ },
78
+ rules: {
79
+ /**
80
+ * Built-in rules
81
+ */
82
+ // Off for Prettier
83
+ // https://github.com/prettier/eslint-config-prettier/blob/main/index.js
84
+ // TODO move to prettier config
85
+ "array-bracket-newline": "off",
86
+ "array-bracket-spacing": "off",
87
+ "array-element-newline": "off",
88
+ "arrow-parens": "off",
89
+ "arrow-spacing": "off",
90
+ "block-spacing": "off",
91
+ "brace-style": "off",
92
+ "comma-dangle": "off",
93
+ "comma-spacing": "off",
94
+ "comma-style": "off",
95
+ "computed-property-spacing": "off",
96
+ "curly": 0,
97
+ "dot-location": "off",
98
+ "eol-last": "off",
99
+ "func-call-spacing": "off",
100
+ "function-call-argument-newline": "off",
101
+ "function-paren-newline": "off",
102
+ "generator-star": "off",
103
+ "generator-star-spacing": "off",
104
+ "implicit-arrow-linebreak": "off",
105
+ "indent": "off",
106
+ "jsx-quotes": "off",
107
+ "key-spacing": "off",
108
+ "keyword-spacing": "off",
109
+ "linebreak-style": "off",
110
+ "lines-around-comment": 0,
111
+ "max-len": 0,
112
+ "multiline-ternary": "off",
113
+ "new-parens": "off",
114
+ "newline-per-chained-call": "off",
115
+ "no-arrow-condition": "off",
116
+ "no-comma-dangle": "off",
117
+ "no-confusing-arrow": 0,
118
+ "no-extra-parens": "off",
119
+ "no-extra-semi": "off",
120
+ "no-floating-decimal": "off",
121
+ "no-mixed-operators": 0,
122
+ "no-mixed-spaces-and-tabs": "off",
123
+ "no-multi-spaces": "off",
124
+ "no-multiple-empty-lines": "off",
125
+ "no-reserved-keys": "off",
126
+ "no-space-before-semi": "off",
127
+ "no-tabs": 0,
128
+ "no-trailing-spaces": "off",
129
+ "no-unexpected-multiline": 0,
130
+ "no-whitespace-before-property": "off",
131
+ "no-wrap-func": "off",
132
+ "nonblock-statement-body-position": "off",
133
+ "object-curly-newline": "off",
134
+ "object-curly-spacing": "off",
135
+ "object-property-newline": "off",
136
+ "one-var-declaration-per-line": "off",
137
+ "operator-linebreak": "off",
138
+ "padded-blocks": "off",
139
+ "quote-props": "off",
140
+ "quotes": 0,
141
+ "rest-spread-spacing": "off",
142
+ "semi": "off",
143
+ "semi-spacing": "off",
144
+ "semi-style": "off",
145
+ "space-after-function-name": "off",
146
+ "space-after-keywords": "off",
147
+ "space-before-blocks": "off",
148
+ "space-before-function-paren": "off",
149
+ "space-before-function-parentheses": "off",
150
+ "space-before-keywords": "off",
151
+ "space-in-brackets": "off",
152
+ "space-in-parens": "off",
153
+ "space-infix-ops": "off",
154
+ "space-return-throw-case": "off",
155
+ "space-unary-ops": "off",
156
+ "space-unary-word-ops": "off",
157
+ "switch-colon-spacing": "off",
158
+ "template-curly-spacing": "off",
159
+ "template-tag-spacing": "off",
160
+ "unicode-bom": "off",
161
+ "wrap-iife": "off",
162
+ "wrap-regex": "off",
163
+ "yield-star-spacing": "off",
164
+ // Enforces getter/setter pairs in objects and classes
165
+ "accessor-pairs": "error",
166
+ // Enforces return statements in callbacks of array's methods
167
+ "array-callback-return": [
168
+ "error",
169
+ // To be compatible with unicorn/no-useless-undefined
170
+ { allowImplicit: true }
171
+ ],
172
+ // Can cause issues when Prettier is enabled
173
+ // TODO should this move to prettier config?
174
+ "arrow-body-style": "off",
175
+ // Generates warnings when variables are used outside of the
176
+ // block in which they were defined
177
+ "block-scoped-var": "error",
178
+ // camelCase vars
179
+ "camelcase": "error",
180
+ // Write comments however you like
181
+ "capitalized-comments": "off",
182
+ // If a class method does not use this,
183
+ // it can sometimes be made into a static function
184
+ "class-methods-use-this": "error",
185
+ // Measures the number of linearly independent paths through a program's
186
+ // source code. Rubbish. Use your own judgement on complexity.
187
+ "complexity": "off",
188
+ // Do not care how return statements specify values.
189
+ // When on, this rule gets annoying when combined with Unicorn's no-useless-* rules.
190
+ "consistent-return": "off",
191
+ // Not sure if required
192
+ "consistent-this": "error",
193
+ // Constructors of derived classes must call super().
194
+ // Constructors of non derived classes must not call super()
195
+ "constructor-super": "error",
196
+ // Require Default Case in Switch Statements
197
+ "default-case": "error",
198
+ // enforce default clauses in switch statements to be last
199
+ "default-case-last": "error",
200
+ // Putting default parameter at last allows function calls
201
+ // to omit optional tail arguments.
202
+ "default-param-last": "error",
203
+ // Access properties using the dot notation.
204
+ "dot-notation": "warn",
205
+ // Use === over ==
206
+ "eqeqeq": "warn",
207
+ // Enforce "for" loop update clause moving the counter in the right direction
208
+ "for-direction": "error",
209
+ // Require function names to match the name of the variable or property to
210
+ // which they are assigned.
211
+ "func-name-matching": "error",
212
+ // Requires function expressions to have a name,
213
+ // If the name cannot be assigned automatically
214
+ "func-names": ["error", "as-needed"],
215
+ // Declaration style: function name() {}
216
+ // Except arrow functions
217
+ "func-style": ["error", "declaration", { allowArrowFunctions: true }],
218
+ // Enforces that a return statement is present in property getters
219
+ "getter-return": "error",
220
+ // If a property has a getter and a setter, the setter should be defined
221
+ // right after the getter, or vice versa.
222
+ "grouped-accessor-pairs": "error",
223
+ // This rule is aimed at preventing unexpected behavior that could arise
224
+ // from using a for in loop without filtering the results in the loop.
225
+ "guard-for-in": "error",
226
+ // Disallows specified identifiers.
227
+ // Maybe turn this on when it's obvious which identifiers do not make sense.
228
+ // Rules like unicorn/catch-error-name look after some of these, anyway.
229
+ "id-denylist": "off",
230
+ // Allow variables named with as little chars as you like
231
+ "id-length": "off",
232
+ // Requires identifiers to match a specified regular expression.
233
+ // Mainly covered by rules like "camelcase". This could probably cause more
234
+ // trouble than it's worth.
235
+ "id-match": "off",
236
+ // Initialise vairables however you like
237
+ "init-declarations": "off",
238
+ // Enforces line comments positioned above code
239
+ "line-comment-position": "error",
240
+ // Require an empty line between class members
241
+ "lines-between-class-members": "warn",
242
+ "logical-assignment-operators": ["warn", "always"],
243
+ // Organise classes how you see fit
244
+ "max-classes-per-file": "off",
245
+ // This rule enforces a maximum depth that blocks can be nested to reduce
246
+ // code complexity. Just gets in the way too much.
247
+ "max-depth": "off",
248
+ // Files can contain as many lines as you like
249
+ "max-lines": "off",
250
+ // Functions can be as complicated as you like
251
+ "max-lines-per-function": "off",
252
+ // This rule enforces a maximum depth that callbacks can be nested to
253
+ // increase code clarity. Defaults to 10.
254
+ "max-nested-callbacks": "error",
255
+ // Enforces a maximum number of parameters allowed in function definitions.
256
+ // This is usually to help readability but TS self-documents this kind of thing.
257
+ "max-params": "off",
258
+ // Statements can be as complicated as you like
259
+ "max-statements": "off",
260
+ // Enforces maximum number of statements allowed per line to 1.
261
+ "max-statements-per-line": "error",
262
+ // Allow any style of multiline comments
263
+ "multiline-comment-style": "off",
264
+ // Require constructor names to begin with a capital letter
265
+ "new-cap": "error",
266
+ // alert is often used while debugging code, which should be removed before
267
+ // deployment to production.
268
+ "no-alert": "error",
269
+ // Use of the Array constructor to construct a new array is generally
270
+ // discouraged in favor of array literal notation because of the
271
+ // single-argument pitfall and because the Array global may be redefined.
272
+ // The exception is when the Array constructor is used to intentionally
273
+ // create sparse arrays of a specified size by giving the constructor a
274
+ // single numeric argument.
275
+ "no-array-constructor": "error",
276
+ // The executor function can also be an async function.
277
+ // However, this is usually a mistake:
278
+ // https://eslint.org/docs/rules/no-async-promise-executor#top
279
+ "no-async-promise-executor": "error",
280
+ // Use Promise.all() instead
281
+ "no-await-in-loop": "error",
282
+ // Use of bitwise operators in JavaScript is very rare and often & or | is
283
+ // simply a mistyped && or ||, which will lead to unexpected behavior.
284
+ "no-bitwise": "error",
285
+ // Use the producer methods Buffer.from, Buffer.alloc,
286
+ // and Buffer.allocUnsafe instead.
287
+ "no-buffer-constructor": "error",
288
+ // arguments.caller and arguments.callee ave been deprecated in future
289
+ // versions of JavaScript and their use is forbidden in ECMAScript 5 while
290
+ // in strict mode.
291
+ "no-caller": "error",
292
+ // Disallows lexical declarations (let, const, function and class) in
293
+ // case/default clauses. To ensure that the lexical declaration only applies
294
+ // to the current case clause wrap your clauses in blocks.
295
+ "no-case-declarations": "error",
296
+ // Disallow modifying variables of class declarations
297
+ "no-class-assign": "error",
298
+ // Disallow comparing against -0
299
+ "no-compare-neg-zero": "error",
300
+ // Disallow assignment operators in conditional statements. e.g.
301
+ // if (user.jobTitle = "manager") { }
302
+ "no-cond-assign": "error",
303
+ // Disallow the use of console
304
+ "no-console": "warn",
305
+ // Disallow modifying variables that are declared using const
306
+ "no-const-assign": "error",
307
+ // This rule identifies == and === comparisons which, based on the semantics
308
+ // of the JavaScript language, will always evaluate to true or false.
309
+ "no-constant-binary-expression": "error",
310
+ // Disallow constant expressions in conditions
311
+ // if (true) {}
312
+ "no-constant-condition": "error",
313
+ // Disallows return statements in the constructor of a class
314
+ "no-constructor-return": "error",
315
+ // Disallow continue statements.
316
+ // When used incorrectly it makes code less testable, less readable and less
317
+ // maintainable. Structured control flow statements such as if should be
318
+ // used instead.
319
+ "no-continue": "error",
320
+ // Control characters are special, invisible characters in the ASCII range
321
+ // 0-31. These characters are rarely used in JavaScript strings so a regular
322
+ // expression containing these characters is most likely a mistake.
323
+ "no-control-regex": "error",
324
+ // The debugger statement is used to tell the executing JavaScript
325
+ // environment to stop execution and start up a debugger at the current
326
+ // point in the code. This has fallen out of favor as a good practice with
327
+ // the advent of modern debugging and development tools.
328
+ "no-debugger": "error",
329
+ // The purpose of the delete operator is to remove a property from an
330
+ // object. Using the delete operator on a variable might lead to unexpected
331
+ // behavior.
332
+ "no-delete-var": "error",
333
+ // Require regex literals to escape division operators.
334
+ "no-div-regex": "warn",
335
+ // function foo(a, b, a) { } // duplicate "a" arg
336
+ "no-dupe-args": "error",
337
+ // class Foo {
338
+ // bar() { console.log("hello") }
339
+ // bar() { console.log("goodbye") } // duplicate class member
340
+ // }
341
+ "no-dupe-class-members": "error",
342
+ // if (isSomething(x)) {
343
+ // foo()
344
+ // } else if (isSomething(x)) { // duplicate condition
345
+ // bar()
346
+ // }
347
+ "no-dupe-else-if": "error",
348
+ // const foo = {
349
+ // bar: "baz",
350
+ // bar: "qux" // duplicate key
351
+ // }
352
+ "no-dupe-keys": "error",
353
+ // switch (a) {
354
+ // case 1:
355
+ // break
356
+ // case 2:
357
+ // break
358
+ // case 1: // duplicate test expression
359
+ // break
360
+ // default:
361
+ // break
362
+ // }
363
+ "no-duplicate-case": "error",
364
+ // Combine named imports in single statement.
365
+ "no-duplicate-imports": "error",
366
+ // If an `if` block contains a return statement, the else block becomes
367
+ // unnecessary. Its contents can be placed outside of the block.
368
+ "no-else-return": "warn",
369
+ // Disallow empty block statements.
370
+ "no-empty": "error",
371
+ // Disallow empty character classes in regular expressions.
372
+ "no-empty-character-class": "error",
373
+ // Disallow empty functions.
374
+ "no-empty-function": "error",
375
+ // Disallow empty destructuring patterns.
376
+ "no-empty-pattern": "error",
377
+ "no-empty-static-block": "error",
378
+ // Error: if (foo == null)
379
+ // Good: if (foo === null)
380
+ "no-eq-null": "error",
381
+ // Disallow eval()
382
+ "no-eval": "error",
383
+ // Disallow reassigning exceptions in catch clauses.
384
+ "no-ex-assign": "error",
385
+ // Disallow extending of native objects.
386
+ "no-extend-native": "error",
387
+ // Disallow unnecessary function binding
388
+ "no-extra-bind": "warn",
389
+ // In contexts such as an if statement's test where the result of the
390
+ // expression will already be coerced to a Boolean, casting to a Boolean via
391
+ // double negation (!!) or a Boolean call is unnecessary.
392
+ "no-extra-boolean-cast": "warn",
393
+ // If a loop contains no nested loops or switches, labeling the loop is unnecessary.
394
+ "no-extra-label": "warn",
395
+ // Disallow case statement fallthrough.
396
+ "no-fallthrough": "error",
397
+ // Disallow reassigning function declarations.
398
+ "no-func-assign": "error",
399
+ // Disallow assignment to native objects or read-only global variables.
400
+ "no-global-assign": "error",
401
+ // Disallow the type conversion with shorter notations.
402
+ "no-implicit-coercion": "warn",
403
+ // Disallow declarations in the global scope.
404
+ "no-implicit-globals": "error",
405
+ // There are some other ways to pass a string and have it interpreted as
406
+ // JavaScript code that have similar concerns.
407
+ // e.g. setTimeout("alert('Hi!');", 100);
408
+ "no-implied-eval": "error",
409
+ // Disallow assigning to imported bindings.
410
+ "no-import-assign": "error",
411
+ // Disallow inline comments after code.
412
+ "no-inline-comments": "error",
413
+ // Disallow variable or function declarations in nested blocks.
414
+ "no-inner-declarations": "error",
415
+ // Disallow invalid regular expression strings in RegExp constructors.
416
+ "no-invalid-regexp": "error",
417
+ // Disallow this keywords outside of classes or class-like objects.
418
+ "no-invalid-this": "error",
419
+ // Invalid or irregular whitespace causes issues with ECMAScript 5 parsers
420
+ // and also makes code harder to debug in a similar nature to mixed tabs and spaces.
421
+ "no-irregular-whitespace": "error",
422
+ // The __iterator__ property was a SpiderMonkey extension to JavaScript that
423
+ // could be used to create custom iterators that are compatible with
424
+ // JavaScript's for in and for each constructs. However, this property is
425
+ // now obsolete, so it should not be used.
426
+ "no-iterator": "error",
427
+ // Disallow labels that are variables names.
428
+ "no-label-var": "error",
429
+ // While convenient in some cases, labels tend to be used only rarely and
430
+ // are frowned upon by some as a remedial form of flow control that is more
431
+ // error prone and harder to understand.
432
+ "no-labels": "error",
433
+ // Disallow unnecessary nested blocks
434
+ "no-lone-blocks": "error",
435
+ // Disallow if statements as the only statement in else blocks.
436
+ "no-lonely-if": "warn",
437
+ // Writing functions within loops tends to result in errors due to the way
438
+ // the function creates a closure around the loop.
439
+ "no-loop-func": "error",
440
+ // Disallow the use of number literals that immediately lose precision at
441
+ // runtime when converted to a JS Number due to 64-bit floating-point rounding.
442
+ "no-loss-of-precision": "error",
443
+ // Disallowing magic numbers causes all sorts of problems
444
+ "no-magic-numbers": "off",
445
+ // Disallow characters which are made with multiple code points in character class syntax.
446
+ "no-misleading-character-class": "error",
447
+ // const foo = bar = "baz"
448
+ "no-multi-assign": "error",
449
+ // var x = "Line 1 \
450
+ // Line 2"
451
+ "no-multi-str": "error",
452
+ // Negated conditions are more difficult to understand. Code can be made
453
+ // more readable by inverting the condition instead.
454
+ // This is handled by unicorn.
455
+ "no-negated-condition": "off",
456
+ // Disallow nested ternary expressions
457
+ "no-nested-ternary": "error",
458
+ // Disallows constructor calls using the new keyword that do not assign
459
+ // the resulting object to a variable.
460
+ "no-new": "error",
461
+ // ❌ Function()
462
+ // ✅ function()
463
+ "no-new-func": "error",
464
+ // ❌ new BigInt(12344555)
465
+ // ✅ BigInt(12344555)
466
+ "no-new-native-nonconstructor": "error",
467
+ // ❌ var myObject = new Object()
468
+ // ✅ var myObject = {}
469
+ "no-new-object": "error",
470
+ // Symbol is not intended to be used with the new operator, but to be called
471
+ // as a function.
472
+ "no-new-symbol": "error",
473
+ // This rule aims to eliminate the use of String, Number, and Boolean with
474
+ // the new operator. As such, it warns whenever it sees new String,
475
+ // new Number, or new Boolean.
476
+ "no-new-wrappers": "error",
477
+ // Disallow \8 and \9 escape sequences in string literals
478
+ "no-nonoctal-decimal-escape": "error",
479
+ // This rule disallows calling the Math, JSON, Reflect and Atomics objects as functions.
480
+ "no-obj-calls": "error",
481
+ // the leading zero which identifies an octal literal has been a source of
482
+ // confusion and error in JavaScript code, ECMAScript 5 deprecates the use
483
+ // of octal numeric literals.
484
+ "no-octal": "error",
485
+ // As of the ECMAScript 5 specification, octal escape sequences in string
486
+ // literals are deprecated and should not be used. Unicode escape sequences
487
+ // should be used instead.
488
+ "no-octal-escape": "error",
489
+ // Assignment to variables declared as function parameters can be misleading
490
+ // and lead to confusing behavior, as modifying function parameters will
491
+ // also mutate the arguments object.
492
+ "no-param-reassign": "error",
493
+ // Because the unary ++ and -- operators are subject to automatic semicolon
494
+ // insertion, differences in whitespace can change semantics of source code.
495
+ "no-plusplus": "error",
496
+ // Disallow returning values from Promise executor functions
497
+ "no-promise-executor-return": "error",
498
+ // __proto__ property has been deprecated as of ECMAScript 3.1 and shouldn't
499
+ // be used in the code. Use Object.getPrototypeOf and Object.setPrototypeOf instead.
500
+ "no-proto": "error",
501
+ // Disallow use of Object.prototypes builtins directly.
502
+ "no-prototype-builtins": "error",
503
+ // Disallow variable redeclaration.
504
+ "no-redeclare": "error",
505
+ // Disallow multiple spaces in regular expression literals.
506
+ "no-regex-spaces": "warn",
507
+ // No export names are restricted
508
+ "no-restricted-exports": "off",
509
+ // Global variable names that are dangerous to use by mistake
510
+ "no-restricted-globals": ["error", ...import_confusing_browser_globals.default],
511
+ // No imports are restricted
512
+ "no-restricted-imports": "off",
513
+ // No properties are restricted
514
+ "no-restricted-properties": "off",
515
+ // No syntax is restricted
516
+ "no-restricted-syntax": "off",
517
+ // Disallow assignment in return statement
518
+ "no-return-assign": "error",
519
+ // Disallows unnecessary return await
520
+ "no-return-await": "error",
521
+ // ❌ location.href = "javascript:void(0)"
522
+ "no-script-url": "error",
523
+ // Self assignments have no effect.
524
+ // ❌ foo = foo
525
+ "no-self-assign": "error",
526
+ // Comparing a variable against itself is usually an error, either a typo or
527
+ // refactoring error.
528
+ "no-self-compare": "error",
529
+ // Disallow use of the comma operator.
530
+ "no-sequences": "error",
531
+ // Disallow returning values from setters.
532
+ "no-setter-return": "error",
533
+ // Disallow variable declarations from shadowing variables declared in the outer scope.
534
+ "no-shadow": "error",
535
+ // ES5 Value Properties of the Global Object (NaN, Infinity, undefined) as
536
+ // well as strict mode restricted identifiers eval and arguments are considered
537
+ // to be restricted names in JavaScript. Defining them to mean something
538
+ // else can have unintended consequences and confuse others reading the code.
539
+ "no-shadow-restricted-names": "error",
540
+ // This rule disallows sparse array literals which have "holes" where commas
541
+ // are not preceded by elements. It does not apply to a trailing comma
542
+ // following the last element. Use ignored values instead.
543
+ "no-sparse-arrays": "error",
544
+ // Disallow template literal placeholder syntax in regular strings.
545
+ "no-template-curly-in-string": "error",
546
+ // Simple ternaries are okay
547
+ "no-ternary": "off",
548
+ // Disallow use of this/super before calling super() in constructors.
549
+ "no-this-before-super": "error",
550
+ // Maintain consistency when throwing exception by disallowing to throw
551
+ // literals and other expressions which cannot possibly be an Error object.
552
+ "no-throw-literal": "error",
553
+ // Disallow undeclared variables.
554
+ "no-undef": "error",
555
+ // Disallow initializing to undefined.
556
+ "no-undef-init": "warn",
557
+ // Allow undefined. Use no-global-assign and no-shadow-restricted-names
558
+ // rules to prevent undefined from being shadowed or assigned a different value.
559
+ "no-undefined": "off",
560
+ // Allow dangling underscores in identifiers.
561
+ "no-underscore-dangle": "off",
562
+ // Disallow unmodified conditions of loops
563
+ "no-unmodified-loop-condition": "error",
564
+ // Disallow ternary operators when simpler alternatives exist.
565
+ "no-unneeded-ternary": "warn",
566
+ // Disallow unreachable code after return, throw, continue, and break statements.
567
+ "no-unreachable": "error",
568
+ // Disallow loops with a body that allows only one iteration
569
+ "no-unreachable-loop": "error",
570
+ // Disallow control flow statements in finally blocks.
571
+ "no-unsafe-finally": "error",
572
+ // Disallow negating the left operand of relational operators.
573
+ "no-unsafe-negation": "error",
574
+ // Disallow use of optional chaining in contexts where the `undefined` value is not allowed
575
+ "no-unsafe-optional-chaining": "error",
576
+ // An unused expression which has no effect on the state of the program
577
+ // indicates a logic error.
578
+ "no-unused-expressions": "error",
579
+ // Labels that are declared and not used anywhere in the code are most
580
+ // likely an error due to incomplete refactoring.
581
+ "no-unused-labels": "warn",
582
+ "no-unused-private-class-members": "error",
583
+ // Variables must be used unless name starts with "ignored"
584
+ "no-unused-vars": [
585
+ "error",
586
+ {
587
+ // Useful for extracting args from props and ignoring them:
588
+ // { style: _style, ...restProps }
589
+ argsIgnorePattern: "^_",
590
+ varsIgnorePattern: "[iI]gnored"
591
+ }
592
+ ],
593
+ // It's possible to use identifiers before their formal declarations in code.
594
+ // This can be confusing and some believe it is best to always declare
595
+ // variables and functions before using them.
596
+ "no-use-before-define": "error",
597
+ // Do I need this? https://eslint.org/docs/rules/no-useless-backreference
598
+ "no-useless-backreference": "off",
599
+ // Function.prototype.call() and Function.prototype.apply() are slower than
600
+ // the normal function invocation.
601
+ "no-useless-call": "error",
602
+ // A catch clause that only rethrows the original error is redundant, and
603
+ // has no effect on the runtime behavior of the program.
604
+ "no-useless-catch": "error",
605
+ // ❌ var foo = {['a']: 'b'}
606
+ // ✅ var foo = {a: 'b'}
607
+ "no-useless-computed-key": "error",
608
+ // ❌ var foo = 'a' + 'b'
609
+ // ✅ var foo = 'ab'
610
+ "no-useless-concat": "error",
611
+ // ES2015 provides a default class constructor if one is not specified. As
612
+ // such, it isunnecessary to provide an empty constructor or one that simply
613
+ // delegates into its parent class.
614
+ "no-useless-constructor": "error",
615
+ // Escaping non-special characters in strings, template literals, and
616
+ // regular expressions doesn't have any effect.
617
+ "no-useless-escape": "error",
618
+ // Disallow renaming import, export, and destructured assignments to the same name.
619
+ "no-useless-rename": "warn",
620
+ // A return; statement with nothing after it is redundant, and has no effect
621
+ // on the runtime behavior of a function. This can be confusing, so it's
622
+ // better to disallow these redundant statements.
623
+ "no-useless-return": "warn",
624
+ // Require let or const instead of var.
625
+ "no-var": "warn",
626
+ // Disallow use of the void operator.
627
+ "no-void": "error",
628
+ // Allow TODOs and FIXMEs
629
+ "no-warning-comments": "off",
630
+ // The with statement is potentially problematic because it adds members of
631
+ // an object to the current scope, making it impossible to tell what a
632
+ // variable inside the block actually refers to.
633
+ "no-with": "error",
634
+ // Functions declared in object keys must conform to a certain style
635
+ // Capitalised functions are exempt as they are probably constructor functions
636
+ "object-shorthand": ["warn", "always", { ignoreConstructors: true }],
637
+ // Prevent combined variable declarations
638
+ "one-var": ["warn", "never"],
639
+ // Disallow assignment operator shorthand where possible.
640
+ "operator-assignment": ["warn", "never"],
641
+ "padding-line-between-statements": [
642
+ "warn",
643
+ { blankLine: "always", next: "*", prev: "multiline-block-like" },
644
+ { blankLine: "always", next: "multiline-block-like", prev: "*" },
645
+ { blankLine: "always", next: "*", prev: "multiline-const" },
646
+ { blankLine: "always", next: "multiline-const", prev: "*" },
647
+ { blankLine: "always", next: "*", prev: "multiline-let" },
648
+ { blankLine: "always", next: "multiline-let", prev: "*" },
649
+ { blankLine: "always", next: "*", prev: "multiline-var" },
650
+ { blankLine: "always", next: "multiline-var", prev: "*" }
651
+ ],
652
+ // Can cause issues when Prettier is enabled
653
+ "prefer-arrow-callback": "off",
654
+ // If a variable is never reassigned, using the const declaration is better.
655
+ "prefer-const": "warn",
656
+ // Make compatible with Unicorn's no-unreadable-array-destructuring
657
+ "prefer-destructuring": ["warn", { array: false, object: true }],
658
+ // Introduced in ES2016, the infix exponentiation operator ** is an
659
+ // alternative for the standard Math.pow function. Infix notation is
660
+ // considered to be more readable and thus more preferable than the function notation.
661
+ "prefer-exponentiation-operator": "warn",
662
+ // Allow regex to be left as-is
663
+ "prefer-named-capture-group": "off",
664
+ // This rule disallows calls to parseInt() or Number.parseInt() if called
665
+ // with two arguments: a string; and a radix option of 2 (binary), 8 (octal),
666
+ // or 16 (hexadecimal).
667
+ "prefer-numeric-literals": "warn",
668
+ // Not supported by Typescript yet
669
+ "prefer-object-has-own": "off",
670
+ // Prefer use of an object spread over Object.assign()
671
+ "prefer-object-spread": "warn",
672
+ // It is considered good practice to only pass instances of the built-in
673
+ // Error object to the reject() function for user-defined errors in Promises.
674
+ // Error objects automatically store a stack trace, which can be used to
675
+ // debug an error by determining where it came from. If a Promise is rejected
676
+ // with a non-Error value, it can be difficult to determine where the rejection occurred.
677
+ "prefer-promise-reject-errors": "error",
678
+ // Disallow use of the RegExp constructor in favor of regular expression literals.
679
+ "prefer-regex-literals": "error",
680
+ // Suggest using the rest parameters instead of `arguments`.
681
+ "prefer-rest-params": "error",
682
+ // Suggest using spread syntax instead of `.apply()`.
683
+ "prefer-spread": "error",
684
+ // Suggest using template literals instead of string concatenation.
685
+ "prefer-template": "warn",
686
+ // When using the parseInt() function it is common to omit the second argument,
687
+ // the radix, and let the function try to determine from the first argument
688
+ // what type of number it is. By default, parseInt() will autodetect decimal
689
+ // and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also
690
+ // autodetected octal literals, which caused problems because many developers
691
+ // assumed a leading 0 would be ignored.
692
+ "radix": "error",
693
+ // Disallow assignments that can lead to race conditions due to usage of await or yield.
694
+ "require-atomic-updates": "error",
695
+ // Disallow async functions which have no await expression.
696
+ "require-await": "error",
697
+ // Enforce the use of 'u' flag on RegExp.
698
+ "require-unicode-regexp": "error",
699
+ // Disallow generator functions that do not have yield.
700
+ "require-yield": "error",
701
+ // Sorting imports is handled by simple-import-sort
702
+ "sort-imports": "off",
703
+ "sort-keys": [
704
+ "error",
705
+ "asc",
706
+ {
707
+ allowLineSeparatedGroups: true,
708
+ caseSensitive: false,
709
+ natural: true
710
+ }
711
+ ],
712
+ // Not required as one-var rule is set to 'error' and so there will never be vars to sort.
713
+ "sort-vars": "off",
714
+ // All comments must have a space after the //
715
+ // This also allows /// reference comments
716
+ "spaced-comment": ["warn", "always", { markers: ["/"] }],
717
+ // Generally gets in the way as it's difficult to know when this may be required.
718
+ "strict": "off",
719
+ // Using description promotes easier debugging.
720
+ // ✅ var foo = Symbol("some description")
721
+ "symbol-description": "error",
722
+ // Require calls to isNaN() when checking for NaN.
723
+ "use-isnan": "error",
724
+ // Enforce comparing typeof expressions against valid strings.
725
+ "valid-typeof": ["error", { requireStringLiterals: true }],
726
+ // By default variable declarations are always moved (“hoisted”) invisibly
727
+ // to the top of their containing scope by the JavaScript interpreter.
728
+ // This rule forces the programmer to represent that behavior by manually
729
+ // moving the variable declaration to the top of its containing scope.
730
+ "vars-on-top": "error",
731
+ // ❌ if ('red' === color) {}
732
+ // ✅ if (color === 'red') {}
733
+ "yoda": "warn"
734
+ }
735
+ }
736
+ ];
737
+ }
738
+
739
+ // src/globs.ts
740
+ var GLOB_EXCLUDE = [
741
+ "**/node_modules",
742
+ "**/dist",
743
+ "**/package-lock.json",
744
+ "**/yarn.lock",
745
+ "**/pnpm-lock.yaml",
746
+ "**/bun.lockb",
747
+ "**/output",
748
+ "**/coverage",
749
+ "**/temp",
750
+ "**/.vitepress/cache",
751
+ "**/.nuxt",
752
+ "**/.vercel",
753
+ "**/.changeset",
754
+ "**/.idea",
755
+ "**/.cache",
756
+ "**/.output",
757
+ "**/.vite-inspect",
758
+ "**/CHANGELOG*.md",
759
+ "**/*.min.*",
760
+ "**/LICENSE*",
761
+ "**/__snapshots__",
762
+ "**/auto-import?(s).d.ts",
763
+ "**/components.d.ts"
764
+ ];
765
+
766
+ // src/configs/ignores.ts
767
+ function ignores() {
768
+ return [
769
+ {
770
+ ignores: GLOB_EXCLUDE
771
+ }
772
+ ];
773
+ }
774
+
775
+ // src/configs/imports.ts
776
+ var import_eslint_plugin_i = __toESM(require("eslint-plugin-i"), 1);
777
+ var import_eslint_plugin_simple_import_sort = __toESM(require("eslint-plugin-simple-import-sort"), 1);
778
+ function imports() {
779
+ return [
780
+ {
781
+ plugins: {
782
+ "import": import_eslint_plugin_i.default,
783
+ "simple-import-sort": import_eslint_plugin_simple_import_sort.default
784
+ },
785
+ rules: {
786
+ // Prefer inline types
787
+ "import/consistent-type-specifier-style": ["warn", "prefer-top-level"],
788
+ // Reports funny business with exports,
789
+ // like repeated exports of names or defaults
790
+ "import/export": "error",
791
+ // Stating exports at the end of the file can make refactoring a two-step process
792
+ "import/exports-last": "off",
793
+ // Same as import/exports-last
794
+ "import/group-exports": "off",
795
+ // There must be a line's space between imports and code
796
+ "import/newline-after-import": "warn",
797
+ // ❌ import {} from 'mod'
798
+ "import/no-empty-named-blocks": "warn",
799
+ // When there is only a single export from a module,
800
+ // this _would_ prefer using default export over named export, but it
801
+ // causes too many issues and it soon becomes tiresome with some tools
802
+ // requiring defaults and others forbidding them or requiring a certain
803
+ // named export.
804
+ "import/prefer-default-export": "off",
805
+ // Sort all the imports!
806
+ "simple-import-sort/exports": "warn",
807
+ "simple-import-sort/imports": "warn",
808
+ // The rest of the rules, off until required
809
+ "import/default": "off",
810
+ "import/dynamic-import-chunkname": "off",
811
+ "import/extensions": "off",
812
+ "import/first": "off",
813
+ "import/max-dependencies": "off",
814
+ "import/named": "off",
815
+ "import/namespace": "off",
816
+ "import/no-absolute-path": "off",
817
+ "import/no-amd": "off",
818
+ "import/no-anonymous-default-export": "off",
819
+ "import/no-commonjs": "off",
820
+ "import/no-cycle": "off",
821
+ "import/no-default-export": "off",
822
+ "import/no-deprecated": "off",
823
+ "import/no-duplicates": "off",
824
+ "import/no-dynamic-require": "off",
825
+ "import/no-extraneous-dependencies": "off",
826
+ "import/no-import-module-exports": "off",
827
+ "import/no-internal-modules": "off",
828
+ "import/no-mutable-exports": "off",
829
+ "import/no-named-as-default": "off",
830
+ "import/no-named-as-default-member": "off",
831
+ "import/no-named-default": "off",
832
+ "import/no-named-export": "off",
833
+ "import/no-namespace": "off",
834
+ "import/no-nodejs-modules": "off",
835
+ "import/no-relative-packages": "off",
836
+ "import/no-relative-parent-imports": "off",
837
+ "import/no-restricted-paths": "off",
838
+ "import/no-self-import": "off",
839
+ "import/no-unassigned-import": "off",
840
+ "import/no-unresolved": "off",
841
+ "import/no-unused-modules": "off",
842
+ "import/no-useless-path-segments": "off",
843
+ "import/no-webpack-loader-syntax": "off",
844
+ "import/order": "off",
845
+ "import/unambiguous": "off"
846
+ }
847
+ }
848
+ ];
849
+ }
850
+
851
+ // src/configs/jest.ts
852
+ var import_eslint_plugin_jest = __toESM(require("eslint-plugin-jest"), 1);
853
+ var import_globals2 = __toESM(require("globals"), 1);
854
+ function jest() {
855
+ return [
856
+ {
857
+ files: ["**/__mocks__/**/*", "**/*.{spec,test}.{js,cjs,mjs,jsx,ts,tsx}"],
858
+ languageOptions: {
859
+ globals: import_globals2.default.jest
860
+ }
861
+ },
862
+ {
863
+ files: ["**/*.{spec,test}.{js,cjs,mjs,jsx,ts,tsx}"],
864
+ plugins: {
865
+ jest: import_eslint_plugin_jest.default
866
+ },
867
+ rules: {
868
+ // Consistent test function names
869
+ // test
870
+ // describe -> it
871
+ "jest/consistent-test-it": [
872
+ "error",
873
+ { fn: "test", withinDescribe: "it" }
874
+ ],
875
+ // Enforce assertion to be made in a test body
876
+ "jest/expect-expect": "error",
877
+ // Have as many expects as you like
878
+ "jest/max-expects": "off",
879
+ "jest/max-nested-describe": "off",
880
+ // Consistent expect methods
881
+ "jest/no-alias-methods": "error",
882
+ "jest/no-commented-out-tests": "error",
883
+ // Prevent calling expect conditionally
884
+ "jest/no-conditional-expect": "error",
885
+ "jest/no-conditional-in-test": "error",
886
+ "jest/no-deprecated-functions": "warn",
887
+ "jest/no-disabled-tests": "warn",
888
+ // Avoid using a callback in asynchronous tests and hooks
889
+ "jest/no-done-callback": "error",
890
+ // Do not allow multiple beforeEach, for example
891
+ "jest/no-duplicate-hooks": "error",
892
+ // Disallow using exports in files containing tests
893
+ "jest/no-export": "error",
894
+ "jest/no-focused-tests": "error",
895
+ "jest/no-hooks": "off",
896
+ "jest/no-identical-title": "error",
897
+ // Conditional logic in tests is usually an indication that a test is attempting to cover too much
898
+ "jest/no-if": "error",
899
+ // Disallow string interpolation inside snapshots
900
+ "jest/no-interpolation-in-snapshots": "error",
901
+ "jest/no-jasmine-globals": "warn",
902
+ "jest/no-large-snapshots": "off",
903
+ // Disallow manually importing from __mocks__
904
+ "jest/no-mocks-import": "error",
905
+ // No methods that need restricting
906
+ "jest/no-restricted-jest-methods": "off",
907
+ "jest/no-restricted-matchers": "off",
908
+ // No standalone expect in a describe block
909
+ "jest/no-standalone-expect": "error",
910
+ // Use .only and .skip over f and x
911
+ "jest/no-test-prefixes": "warn",
912
+ // Tests shouldn't return anything
913
+ "jest/no-test-return-statement": "error",
914
+ "jest/prefer-called-with": "off",
915
+ // https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-comparison-matcher.md
916
+ "jest/prefer-comparison-matcher": "warn",
917
+ "jest/prefer-each": "error",
918
+ // https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-equality-matcher.md
919
+ "jest/prefer-equality-matcher": "error",
920
+ "jest/prefer-expect-assertions": "off",
921
+ "jest/prefer-expect-resolves": "warn",
922
+ // Put lifecycle hooks in particular order
923
+ "jest/prefer-hooks-in-order": "error",
924
+ // beforeEach, beforeAll, afterEach etc. should be at top of test block
925
+ "jest/prefer-hooks-on-top": "error",
926
+ // Allow any case in test names
927
+ "jest/prefer-lowercase-title": "off",
928
+ // When working with mocks of functions that return promises, Jest provides
929
+ // some API sugar functions to reduce the amount of boilerplate you have to write.
930
+ "jest/prefer-mock-promise-shorthand": "warn",
931
+ "jest/prefer-snapshot-hint": "error",
932
+ // By overwriting a property with `jest.fn()` you have to manually restore
933
+ // the original implementation when cleaning up. When using jest.spyOn()
934
+ // Jest keeps track of changes, and they can be restored.
935
+ "jest/prefer-spy-on": "error",
936
+ "jest/prefer-strict-equal": "error",
937
+ "jest/prefer-to-be": "warn",
938
+ // expect(a.includes(b)).toBe(true) -> expect(a).toContain(b)
939
+ "jest/prefer-to-contain": "error",
940
+ // expect(files.length).toBe(1) -> expect(files).toHaveLength(1)
941
+ "jest/prefer-to-have-length": "error",
942
+ // When test cases are empty then it is better to mark them as test.todo
943
+ // as it will be highlighted in the summary output
944
+ "jest/prefer-todo": "error",
945
+ // Require setup and tear down code to be within lifecycle hooks
946
+ "jest/require-hook": "error",
947
+ // Requiring a message ensures that the intended error is thrown
948
+ "jest/require-to-throw-message": "error",
949
+ "jest/require-top-level-describe": "off",
950
+ "jest/unbound-method": "off",
951
+ "jest/valid-describe-callback": "error",
952
+ "jest/valid-expect": "error",
953
+ "jest/valid-expect-in-promise": "error",
954
+ // Titles are...
955
+ // - not empty
956
+ // - is a string
957
+ // - not prefixed with their block name
958
+ // - have no leading or trailing spaces
959
+ "jest/valid-title": "error"
960
+ }
961
+ },
962
+ {
963
+ files: ["**/*.{spec,test}.{ts,tsx}"],
964
+ rules: {
965
+ "jest/no-untyped-mock-factory": "warn"
966
+ }
967
+ }
968
+ ];
969
+ }
970
+
971
+ // src/configs/node.ts
972
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
973
+ function node() {
974
+ return [
975
+ {
976
+ plugins: {
977
+ n: import_eslint_plugin_n.default
978
+ },
979
+ rules: {
980
+ // Enforces return statements in callbacks of array's methods
981
+ "n/callback-return": "error",
982
+ // require() should be called only in the top level of a module to make it
983
+ // easier to identify dependencies.
984
+ "n/global-require": "error",
985
+ // This rule expects that when you're using the callback pattern in Node.js
986
+ // you'll handle the error.
987
+ "n/handle-callback-err": "error",
988
+ // Disallow require calls to be mixed with regular variable declarations.
989
+ "n/no-mixed-requires": "error",
990
+ // ❌ var appHeader = new require('app-header')
991
+ // ✅ var AppHeader = require('app-header')
992
+ // var appHeader = new AppHeader()
993
+ "n/no-new-require": "error",
994
+ // Disallow string concatenation when using __dirname and __filename.
995
+ // Use path.join() instead.
996
+ "n/no-path-concat": "error",
997
+ // Allow env vars in code
998
+ "n/no-process-env": "off",
999
+ // Handled by Unicorn
1000
+ "n/no-process-exit": "off",
1001
+ // No modules are restricted
1002
+ "n/no-restricted-require": "off",
1003
+ // I like synchronous functions
1004
+ "n/no-sync": "off",
1005
+ // Not sure I need this...?
1006
+ // TODO check others' configs to see how they use this.
1007
+ "n/shebang": "off",
1008
+ // Turn these off until I work out if I need them
1009
+ "n/exports-style": "off",
1010
+ "n/file-extension-in-import": "off",
1011
+ "n/no-callback-literal": "off",
1012
+ "n/no-deprecated-api": "off",
1013
+ "n/no-exports-assign": "off",
1014
+ "n/no-extraneous-import": "off",
1015
+ "n/no-extraneous-require": "off",
1016
+ "n/no-missing-import": "off",
1017
+ "n/no-missing-require": "off",
1018
+ "n/no-restricted-import": "off",
1019
+ "n/no-unpublished-bin": "off",
1020
+ "n/no-unpublished-import": "off",
1021
+ "n/no-unpublished-require": "off",
1022
+ "n/no-unsupported-features/es-builtins": "off",
1023
+ "n/no-unsupported-features/es-syntax": "off",
1024
+ "n/no-unsupported-features/node-builtins": "off",
1025
+ "n/prefer-global/buffer": "off",
1026
+ "n/prefer-global/console": "off",
1027
+ "n/prefer-global/process": "off",
1028
+ "n/prefer-global/text-decoder": "off",
1029
+ "n/prefer-global/text-encoder": "off",
1030
+ "n/prefer-global/url": "off",
1031
+ "n/prefer-global/url-search-params": "off",
1032
+ "n/prefer-promises/dns": "off",
1033
+ "n/prefer-promises/fs": "off",
1034
+ "n/process-exit-as-throw": "off"
1035
+ }
1036
+ }
1037
+ ];
1038
+ }
1039
+
1040
+ // src/configs/prettier.ts
1041
+ var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
1042
+ function prettier() {
1043
+ return [
1044
+ {
1045
+ plugins: {
1046
+ prettier: import_eslint_plugin_prettier.default
1047
+ },
1048
+ rules: {
1049
+ "prettier/prettier": "warn"
1050
+ }
1051
+ }
1052
+ ];
1053
+ }
1054
+
1055
+ // src/configs/react.ts
1056
+ var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"), 1);
1057
+ var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
1058
+ var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
1059
+ var import_globals3 = __toESM(require("globals"), 1);
1060
+ function react() {
1061
+ return [
1062
+ {
1063
+ files: ["**/*.{jsx,tsx}"],
1064
+ languageOptions: {
1065
+ globals: import_globals3.default.browser,
1066
+ parserOptions: {
1067
+ ecmaFeatures: {
1068
+ jsx: true
1069
+ }
1070
+ }
1071
+ },
1072
+ plugins: {
1073
+ "jsx-a11y": import_eslint_plugin_jsx_a11y.default,
1074
+ "react": import_eslint_plugin_react.default,
1075
+ "react-hooks": import_eslint_plugin_react_hooks.default
1076
+ },
1077
+ rules: {
1078
+ "jsx-a11y/alt-text": "error",
1079
+ "jsx-a11y/anchor-ambiguous-text": "error",
1080
+ "jsx-a11y/anchor-has-content": "error",
1081
+ "jsx-a11y/anchor-is-valid": "error",
1082
+ "jsx-a11y/aria-activedescendant-has-tabindex": "error",
1083
+ "jsx-a11y/aria-props": "error",
1084
+ "jsx-a11y/aria-proptypes": "error",
1085
+ "jsx-a11y/aria-role": "error",
1086
+ "jsx-a11y/aria-unsupported-elements": "error",
1087
+ "jsx-a11y/autocomplete-valid": "error",
1088
+ "jsx-a11y/click-events-have-key-events": "error",
1089
+ "jsx-a11y/control-has-associated-label": [
1090
+ "off",
1091
+ {
1092
+ ignoreElements: [
1093
+ "audio",
1094
+ "canvas",
1095
+ "embed",
1096
+ "input",
1097
+ "textarea",
1098
+ "tr",
1099
+ "video"
1100
+ ],
1101
+ ignoreRoles: [
1102
+ "grid",
1103
+ "listbox",
1104
+ "menu",
1105
+ "menubar",
1106
+ "radiogroup",
1107
+ "row",
1108
+ "tablist",
1109
+ "toolbar",
1110
+ "tree",
1111
+ "treegrid"
1112
+ ],
1113
+ includeRoles: ["alert", "dialog"]
1114
+ }
1115
+ ],
1116
+ "jsx-a11y/heading-has-content": "error",
1117
+ "jsx-a11y/html-has-lang": "error",
1118
+ "jsx-a11y/iframe-has-title": "error",
1119
+ "jsx-a11y/img-redundant-alt": "error",
1120
+ "jsx-a11y/interactive-supports-focus": [
1121
+ "error",
1122
+ {
1123
+ tabbable: [
1124
+ "button",
1125
+ "checkbox",
1126
+ "link",
1127
+ "searchbox",
1128
+ "spinbutton",
1129
+ "switch",
1130
+ "textbox"
1131
+ ]
1132
+ }
1133
+ ],
1134
+ "jsx-a11y/label-has-associated-control": "error",
1135
+ "jsx-a11y/label-has-for": "off",
1136
+ "jsx-a11y/lang": "error",
1137
+ "jsx-a11y/media-has-caption": "error",
1138
+ "jsx-a11y/mouse-events-have-key-events": "error",
1139
+ "jsx-a11y/no-access-key": "error",
1140
+ "jsx-a11y/no-aria-hidden-on-focusable": "error",
1141
+ "jsx-a11y/no-autofocus": "error",
1142
+ "jsx-a11y/no-distracting-elements": "error",
1143
+ "jsx-a11y/no-interactive-element-to-noninteractive-role": [
1144
+ "error",
1145
+ {
1146
+ canvas: ["img"],
1147
+ tr: ["none", "presentation"]
1148
+ }
1149
+ ],
1150
+ "jsx-a11y/no-noninteractive-element-interactions": [
1151
+ "error",
1152
+ {
1153
+ alert: ["onKeyUp", "onKeyDown", "onKeyPress"],
1154
+ body: ["onError", "onLoad"],
1155
+ dialog: ["onKeyUp", "onKeyDown", "onKeyPress"],
1156
+ handlers: [
1157
+ "onClick",
1158
+ "onError",
1159
+ "onLoad",
1160
+ "onMouseDown",
1161
+ "onMouseUp",
1162
+ "onKeyPress",
1163
+ "onKeyDown",
1164
+ "onKeyUp"
1165
+ ],
1166
+ iframe: ["onError", "onLoad"],
1167
+ img: ["onError", "onLoad"]
1168
+ }
1169
+ ],
1170
+ "jsx-a11y/no-noninteractive-element-to-interactive-role": [
1171
+ "error",
1172
+ {
1173
+ fieldset: ["radiogroup", "presentation"],
1174
+ li: ["menuitem", "option", "row", "tab", "treeitem"],
1175
+ ol: [
1176
+ "listbox",
1177
+ "menu",
1178
+ "menubar",
1179
+ "radiogroup",
1180
+ "tablist",
1181
+ "tree",
1182
+ "treegrid"
1183
+ ],
1184
+ table: ["grid"],
1185
+ td: ["gridcell"],
1186
+ ul: [
1187
+ "listbox",
1188
+ "menu",
1189
+ "menubar",
1190
+ "radiogroup",
1191
+ "tablist",
1192
+ "tree",
1193
+ "treegrid"
1194
+ ]
1195
+ }
1196
+ ],
1197
+ "jsx-a11y/no-noninteractive-tabindex": [
1198
+ "error",
1199
+ {
1200
+ allowExpressionValues: true,
1201
+ roles: ["tabpanel"],
1202
+ tags: []
1203
+ }
1204
+ ],
1205
+ "jsx-a11y/no-redundant-roles": "error",
1206
+ "jsx-a11y/no-static-element-interactions": [
1207
+ "error",
1208
+ {
1209
+ allowExpressionValues: true,
1210
+ handlers: [
1211
+ "onClick",
1212
+ "onMouseDown",
1213
+ "onMouseUp",
1214
+ "onKeyPress",
1215
+ "onKeyDown",
1216
+ "onKeyUp"
1217
+ ]
1218
+ }
1219
+ ],
1220
+ "jsx-a11y/prefer-tag-over-role": "error",
1221
+ "jsx-a11y/role-has-required-aria-props": "error",
1222
+ "jsx-a11y/role-supports-aria-props": "error",
1223
+ "jsx-a11y/scope": "error",
1224
+ "jsx-a11y/tabindex-no-positive": "error",
1225
+ /**
1226
+ * Off for Prettier
1227
+ * https://github.com/prettier/eslint-config-prettier/blob/main/index.js
1228
+ */
1229
+ "react/jsx-child-element-spacing": "off",
1230
+ "react/jsx-closing-bracket-location": "off",
1231
+ "react/jsx-closing-tag-location": "off",
1232
+ "react/jsx-curly-newline": "off",
1233
+ "react/jsx-curly-spacing": "off",
1234
+ "react/jsx-equals-spacing": "off",
1235
+ "react/jsx-first-prop-new-line": "off",
1236
+ "react/jsx-indent": "off",
1237
+ "react/jsx-indent-props": "off",
1238
+ "react/jsx-max-props-per-line": "off",
1239
+ "react/jsx-newline": "off",
1240
+ "react/jsx-one-expression-per-line": "off",
1241
+ "react/jsx-props-no-multi-spaces": "off",
1242
+ "react/jsx-tag-spacing": "off",
1243
+ "react/jsx-wrap-multilines": "off",
1244
+ // It is common to use these lifecycle methods without using "this".
1245
+ "class-methods-use-this": [
1246
+ "error",
1247
+ {
1248
+ exceptMethods: [
1249
+ "render",
1250
+ "getInitialState",
1251
+ "getDefaultProps",
1252
+ "getChildContext",
1253
+ "componentWillMount",
1254
+ "componentDidMount",
1255
+ "componentWillReceiveProps",
1256
+ "shouldComponentUpdate",
1257
+ "componentWillUpdate",
1258
+ "componentDidUpdate",
1259
+ "componentWillUnmount",
1260
+ "componentDidCatch"
1261
+ ]
1262
+ }
1263
+ ],
1264
+ "react/boolean-prop-naming": "error",
1265
+ "react/button-has-type": "error",
1266
+ "react/default-props-match-prop-types": "error",
1267
+ "react/destructuring-assignment": "error",
1268
+ "react/display-name": "error",
1269
+ // Components can use any props.
1270
+ "react/forbid-component-props": "off",
1271
+ "react/forbid-dom-props": "error",
1272
+ "react/forbid-elements": "error",
1273
+ "react/forbid-foreign-prop-types": "error",
1274
+ "react/forbid-prop-types": "error",
1275
+ // Functional components can use any style.
1276
+ "react/function-component-definition": "off",
1277
+ "react/hook-use-state": "error",
1278
+ "react/iframe-missing-sandbox": "error",
1279
+ // ❌ <Hello personal={true} />
1280
+ // ✅ <Hello personal />
1281
+ "react/jsx-boolean-value": "warn",
1282
+ // disallow unnecessary curly braces in JSX props and/or children.
1283
+ "react/jsx-curly-brace-presence": "warn",
1284
+ // Allow JSX in any files
1285
+ "react/jsx-filename-extension": "off",
1286
+ // Enforce shorthand for React fragments.
1287
+ "react/jsx-fragments": "warn",
1288
+ "react/jsx-handler-names": "error",
1289
+ "react/jsx-key": "error",
1290
+ // Unlimited JSX nesting.
1291
+ "react/jsx-max-depth": "off",
1292
+ // I haven't found any modern benchmarks for disallowing inline arrow
1293
+ // functions, and quite frankly it feels like this "optimisation" is just
1294
+ // people repeating sentiments from old blog posts.
1295
+ "react/jsx-no-bind": [
1296
+ "error",
1297
+ {
1298
+ allowArrowFunctions: true
1299
+ }
1300
+ ],
1301
+ "react/jsx-no-comment-textnodes": "error",
1302
+ "react/jsx-no-constructed-context-values": "error",
1303
+ "react/jsx-no-duplicate-props": "error",
1304
+ // In React, you might end up rendering unexpected values like 0 or NaN.
1305
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
1306
+ "react/jsx-no-leaked-render": "warn",
1307
+ // ✅ <div>test</div>
1308
+ // ✅ <div>{'test'}</div>
1309
+ "react/jsx-no-literals": "off",
1310
+ "react/jsx-no-script-url": "error",
1311
+ "react/jsx-no-target-blank": "error",
1312
+ "react/jsx-no-undef": "error",
1313
+ "react/jsx-no-useless-fragment": "warn",
1314
+ "react/jsx-pascal-case": "error",
1315
+ // Allow prop spreading, you know the dangers!
1316
+ "react/jsx-props-no-spreading": "off",
1317
+ // Alphabetical sorting of props
1318
+ // TODO there's other options in this one that could be useful.
1319
+ "react/jsx-sort-props": ["warn", { reservedFirst: true }],
1320
+ "react/jsx-uses-react": "error",
1321
+ "react/jsx-uses-vars": "error",
1322
+ "react/no-access-state-in-setstate": "error",
1323
+ "react/no-adjacent-inline-elements": "error",
1324
+ "react/no-array-index-key": "error",
1325
+ "react/no-arrow-function-lifecycle": "error",
1326
+ "react/no-children-prop": "error",
1327
+ "react/no-danger": "error",
1328
+ "react/no-danger-with-children": "error",
1329
+ "react/no-deprecated": "error",
1330
+ "react/no-did-mount-set-state": "error",
1331
+ "react/no-did-update-set-state": "error",
1332
+ "react/no-direct-mutation-state": "error",
1333
+ "react/no-find-dom-node": "error",
1334
+ "react/no-invalid-html-attribute": "error",
1335
+ "react/no-is-mounted": "error",
1336
+ // Allow as many components per file as you like
1337
+ "react/no-multi-comp": "off",
1338
+ "react/no-namespace": "error",
1339
+ // Prevent potential unnecessary rerenders, and performance regressions
1340
+ "react/no-object-type-as-default-prop": "error",
1341
+ "react/no-redundant-should-component-update": "error",
1342
+ "react/no-render-return-value": "error",
1343
+ "react/no-set-state": "error",
1344
+ "react/no-string-refs": "error",
1345
+ "react/no-this-in-sfc": "error",
1346
+ "react/no-typos": "error",
1347
+ "react/no-unescaped-entities": "error",
1348
+ // ❌ <div class="hello">Hello World</div>
1349
+ // ✅ <div className="hello">Hello World</div>
1350
+ "react/no-unknown-property": "warn",
1351
+ "react/no-unsafe": "error",
1352
+ "react/no-unstable-nested-components": "error",
1353
+ "react/no-unused-class-component-methods": "error",
1354
+ "react/no-unused-prop-types": "error",
1355
+ "react/no-unused-state": "error",
1356
+ "react/no-will-update-set-state": "error",
1357
+ "react/prefer-es6-class": "error",
1358
+ "react/prefer-exact-props": "error",
1359
+ "react/prefer-read-only-props": "error",
1360
+ "react/prefer-stateless-function": "error",
1361
+ "react/prop-types": "off",
1362
+ // React is no longer required to be imported to use JSX
1363
+ "react/react-in-jsx-scope": "off",
1364
+ // Enforce a defaultProps definition for every prop that is not a required prop
1365
+ // TODO turn this back on and create a react-typescript rule set for disabling thing like this.
1366
+ "react/require-default-props": "off",
1367
+ // Do not enforce React components to have a shouldComponentUpdate method.
1368
+ "react/require-optimization": "off",
1369
+ "react/require-render-return": "error",
1370
+ // Prevent extra closing tags for components without children.
1371
+ "react/self-closing-comp": "warn",
1372
+ "react/sort-comp": "error",
1373
+ "react/sort-default-props": "error",
1374
+ "react/sort-prop-types": "error",
1375
+ "react/state-in-constructor": "error",
1376
+ "react/static-property-placement": "error",
1377
+ "react/style-prop-object": "error",
1378
+ "react/void-dom-elements-no-children": "error",
1379
+ // Checks effect dependencies
1380
+ "react-hooks/exhaustive-deps": "warn",
1381
+ // Checks rules of Hooks
1382
+ "react-hooks/rules-of-hooks": "error"
1383
+ },
1384
+ settings: {
1385
+ react: {
1386
+ version: "detect"
1387
+ }
1388
+ }
1389
+ }
1390
+ ];
1391
+ }
1392
+
1393
+ // src/configs/switch-case.ts
1394
+ var import_eslint_plugin_switch_case = __toESM(require("eslint-plugin-switch-case"), 1);
1395
+ function switchCase() {
1396
+ return [
1397
+ {
1398
+ plugins: {
1399
+ "switch-case": import_eslint_plugin_switch_case.default
1400
+ },
1401
+ rules: {
1402
+ // Switches must have new lines between case groups
1403
+ "switch-case/newline-between-switch-case": [
1404
+ "warn",
1405
+ "always",
1406
+ { fallthrough: "never" }
1407
+ ],
1408
+ // It can be useful for switch cases to have their own scope.
1409
+ "switch-case/no-case-curly": "off"
1410
+ }
1411
+ }
1412
+ ];
1413
+ }
1414
+
1415
+ // src/configs/typescript.ts
1416
+ var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
1417
+ var import_parser2 = __toESM(require("@typescript-eslint/parser"), 1);
1418
+ function typescript() {
1419
+ return [
1420
+ {
1421
+ files: ["**/*.{ts,tsx,astro}"],
1422
+ languageOptions: {
1423
+ // @ts-expect-error -- does not confirm to type
1424
+ parser: import_parser2.default
1425
+ },
1426
+ plugins: {
1427
+ // @ts-expect-error -- does not confirm to type
1428
+ "@typescript-eslint": import_eslint_plugin.default
1429
+ },
1430
+ rules: {
1431
+ /**
1432
+ * Recommended to turn off these eslint built-in rules
1433
+ * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/eslint-recommended.ts
1434
+ */
1435
+ // ts(2335) & ts(2377)
1436
+ "constructor-super": "off",
1437
+ // ts(2378)
1438
+ "getter-return": "off",
1439
+ // ts(2588)
1440
+ "no-const-assign": "off",
1441
+ // ts(2300)
1442
+ "no-dupe-args": "off",
1443
+ // ts(2393) & ts(2300)
1444
+ "no-dupe-class-members": "off",
1445
+ // ts(1117)
1446
+ "no-dupe-keys": "off",
1447
+ // ts(2539)
1448
+ "no-func-assign": "off",
1449
+ // ts(2539) & ts(2540)
1450
+ "no-import-assign": "off",
1451
+ // ts(2588)
1452
+ "no-new-symbol": "off",
1453
+ // ts(2349)
1454
+ "no-obj-calls": "off",
1455
+ // ts(2408)
1456
+ "no-setter-return": "off",
1457
+ // ts(2376)
1458
+ "no-this-before-super": "off",
1459
+ // ts(2304)
1460
+ "no-undef": "off",
1461
+ // ts(7027)
1462
+ "no-unreachable": "off",
1463
+ // ts(2365) & ts(2360) & ts(2358)
1464
+ "no-unsafe-negation": "off",
1465
+ // ts transpiles let/const to var, so no need for vars any more
1466
+ "no-var": "error",
1467
+ // ts provides better types with const
1468
+ "prefer-const": "warn",
1469
+ // ts provides better types with rest args over arguments
1470
+ "prefer-rest-params": "error",
1471
+ // ts transpiles spread to apply, so no need for manual apply
1472
+ "prefer-spread": "error",
1473
+ // ts(2367)
1474
+ "valid-typeof": "off",
1475
+ /**
1476
+ * TS Recommended
1477
+ * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.ts
1478
+ */
1479
+ "@typescript-eslint/adjacent-overload-signatures": "error",
1480
+ "@typescript-eslint/ban-ts-comment": "error",
1481
+ "@typescript-eslint/ban-types": "error",
1482
+ "@typescript-eslint/explicit-module-boundary-types": "warn",
1483
+ "@typescript-eslint/no-array-constructor": "error",
1484
+ "@typescript-eslint/no-empty-function": "error",
1485
+ "@typescript-eslint/no-empty-interface": "error",
1486
+ "@typescript-eslint/no-explicit-any": "warn",
1487
+ "@typescript-eslint/no-inferrable-types": "error",
1488
+ "@typescript-eslint/no-misused-new": "error",
1489
+ "@typescript-eslint/no-namespace": "error",
1490
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
1491
+ "@typescript-eslint/no-non-null-assertion": "warn",
1492
+ "@typescript-eslint/no-this-alias": "error",
1493
+ "@typescript-eslint/no-var-requires": "error",
1494
+ "@typescript-eslint/prefer-as-const": "error",
1495
+ "@typescript-eslint/prefer-namespace-keyword": "error",
1496
+ "@typescript-eslint/triple-slash-reference": "error",
1497
+ "no-array-constructor": "off",
1498
+ "no-empty-function": "off",
1499
+ "no-extra-semi": "off",
1500
+ /**
1501
+ * These are for type checking which I don't use eslint for
1502
+ */
1503
+ "@typescript-eslint/await-thenable": "off",
1504
+ "@typescript-eslint/consistent-type-exports": "off",
1505
+ "@typescript-eslint/dot-notation": "off",
1506
+ "@typescript-eslint/naming-convention": "off",
1507
+ "@typescript-eslint/no-base-to-string": "off",
1508
+ "@typescript-eslint/no-confusing-void-expression": "off",
1509
+ "@typescript-eslint/no-duplicate-type-constituents": "off",
1510
+ "@typescript-eslint/no-floating-promises": "off",
1511
+ "@typescript-eslint/no-for-in-array": "off",
1512
+ "@typescript-eslint/no-implied-eval": "off",
1513
+ "@typescript-eslint/no-meaningless-void-operator": "off",
1514
+ "@typescript-eslint/no-misused-promises": "off",
1515
+ "@typescript-eslint/no-mixed-enums": "off",
1516
+ "@typescript-eslint/no-redundant-type-constituents": "off",
1517
+ "@typescript-eslint/no-throw-literal": "off",
1518
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
1519
+ "@typescript-eslint/no-unnecessary-condition": "off",
1520
+ "@typescript-eslint/no-unnecessary-qualifier": "off",
1521
+ "@typescript-eslint/no-unnecessary-type-arguments": "off",
1522
+ "@typescript-eslint/no-unnecessary-type-assertion": "off",
1523
+ "@typescript-eslint/no-unsafe-argument": "off",
1524
+ "@typescript-eslint/no-unsafe-assignment": "off",
1525
+ "@typescript-eslint/no-unsafe-call": "off",
1526
+ "@typescript-eslint/no-unsafe-enum-comparison": "off",
1527
+ "@typescript-eslint/no-unsafe-member-access": "off",
1528
+ "@typescript-eslint/no-unsafe-return": "off",
1529
+ "@typescript-eslint/non-nullable-type-assertion-style": "off",
1530
+ "@typescript-eslint/prefer-includes": "off",
1531
+ "@typescript-eslint/prefer-nullish-coalescing": "off",
1532
+ "@typescript-eslint/prefer-optional-chain": "off",
1533
+ "@typescript-eslint/prefer-readonly": "off",
1534
+ "@typescript-eslint/prefer-readonly-parameter-types": "off",
1535
+ "@typescript-eslint/prefer-reduce-type-parameter": "off",
1536
+ "@typescript-eslint/prefer-regexp-exec": "off",
1537
+ "@typescript-eslint/prefer-return-this-type": "off",
1538
+ "@typescript-eslint/prefer-string-starts-ends-with": "off",
1539
+ "@typescript-eslint/promise-function-async": "off",
1540
+ "@typescript-eslint/require-array-sort-compare": "off",
1541
+ "@typescript-eslint/require-await": "off",
1542
+ "@typescript-eslint/restrict-plus-operands": "off",
1543
+ "@typescript-eslint/restrict-template-expressions": "off",
1544
+ "@typescript-eslint/return-await": "off",
1545
+ "@typescript-eslint/strict-boolean-expressions": "off",
1546
+ "@typescript-eslint/switch-exhaustiveness-check": "off",
1547
+ "@typescript-eslint/unbound-method": "off",
1548
+ /**
1549
+ * Off for Prettier
1550
+ * https://github.com/prettier/eslint-config-prettier/blob/main/index.js
1551
+ */
1552
+ "@typescript-eslint/block-spacing": "off",
1553
+ "@typescript-eslint/brace-style": "off",
1554
+ "@typescript-eslint/comma-dangle": "off",
1555
+ "@typescript-eslint/comma-spacing": "off",
1556
+ "@typescript-eslint/func-call-spacing": "off",
1557
+ "@typescript-eslint/indent": "off",
1558
+ "@typescript-eslint/key-spacing": "off",
1559
+ "@typescript-eslint/keyword-spacing": "off",
1560
+ "@typescript-eslint/lines-around-comment": "off",
1561
+ "@typescript-eslint/member-delimiter-style": "off",
1562
+ "@typescript-eslint/no-extra-parens": "off",
1563
+ "@typescript-eslint/no-extra-semi": "off",
1564
+ "@typescript-eslint/object-curly-spacing": "off",
1565
+ "@typescript-eslint/quotes": "off",
1566
+ "@typescript-eslint/semi": "off",
1567
+ "@typescript-eslint/space-before-blocks": "off",
1568
+ "@typescript-eslint/space-before-function-paren": "off",
1569
+ "@typescript-eslint/space-infix-ops": "off",
1570
+ "@typescript-eslint/type-annotation-spacing": "off",
1571
+ /**
1572
+ * Superseded by TS rules below
1573
+ */
1574
+ "default-param-last": "off",
1575
+ "lines-between-class-members": "off",
1576
+ "no-duplicate-imports": "off",
1577
+ "no-invalid-this": "off",
1578
+ "no-loop-func": "off",
1579
+ "no-loss-of-precision": "off",
1580
+ "no-redeclare": "off",
1581
+ "no-restricted-imports": "off",
1582
+ "no-shadow": "off",
1583
+ "no-unused-expressions": "off",
1584
+ "no-unused-vars": "off",
1585
+ "no-use-before-define": "off",
1586
+ "no-useless-constructor": "off",
1587
+ "padding-line-between-statements": "off",
1588
+ /**
1589
+ * The rest
1590
+ */
1591
+ // Requires using T[] over Array<T> for arrays
1592
+ "@typescript-eslint/array-type": ["warn", { default: "array" }],
1593
+ // Bans // tslint:<rule-flag> comments from being used
1594
+ "@typescript-eslint/ban-tslint-comment": "warn",
1595
+ // Ensures that literals on classes are exposed in a consistent style
1596
+ "@typescript-eslint/class-literal-property-style": "warn",
1597
+ // https://typescript-eslint.io/rules/consistent-generic-constructors/
1598
+ "@typescript-eslint/consistent-generic-constructors": "warn",
1599
+ // Enforce the use of the record type
1600
+ "@typescript-eslint/consistent-indexed-object-style": "warn",
1601
+ // Enforces consistent usage of type assertions
1602
+ "@typescript-eslint/consistent-type-assertions": "error",
1603
+ // Enforce using types for object type definitions
1604
+ "@typescript-eslint/consistent-type-definitions": ["warn", "type"],
1605
+ // Enforces consistent usage of type imports
1606
+ "@typescript-eslint/consistent-type-imports": [
1607
+ "warn",
1608
+ {
1609
+ fixStyle: "separate-type-imports",
1610
+ prefer: "type-imports"
1611
+ }
1612
+ ],
1613
+ // Enforce default parameters to be last
1614
+ "@typescript-eslint/default-param-last": ["error"],
1615
+ // Don't mind if functions do not have return types.
1616
+ "@typescript-eslint/explicit-function-return-type": "off",
1617
+ // Require explicit accessibility modifiers ("public") on class properties and methods
1618
+ "@typescript-eslint/explicit-member-accessibility": "warn",
1619
+ // Initialise vairables however you like
1620
+ "@typescript-eslint/init-declarations": "off",
1621
+ "@typescript-eslint/lines-between-class-members": [
1622
+ "warn",
1623
+ "always",
1624
+ { exceptAfterOverload: true }
1625
+ ],
1626
+ // Require a consistent member declaration order
1627
+ "@typescript-eslint/member-ordering": "error",
1628
+ // ❌
1629
+ // interface T1 {
1630
+ // func(arg: string): number;
1631
+ // }
1632
+ // ✅
1633
+ // interface T1 {
1634
+ // func: (arg: string) => number;
1635
+ // }
1636
+ "@typescript-eslint/method-signature-style": "warn",
1637
+ // Disallow non-null assertion in locations that may be confusing
1638
+ "@typescript-eslint/no-confusing-non-null-assertion": "warn",
1639
+ // Disallow duplicate class members
1640
+ "@typescript-eslint/no-dupe-class-members": "error",
1641
+ // ❌
1642
+ // enum E {
1643
+ // A = 0,
1644
+ // B = 0,
1645
+ // }
1646
+ // ✅
1647
+ // enum E {
1648
+ // A = 0,
1649
+ // B = 1,
1650
+ // }
1651
+ "@typescript-eslint/no-duplicate-enum-values": "error",
1652
+ // Deleting missing key/value is safe
1653
+ "@typescript-eslint/no-dynamic-delete": "off",
1654
+ // ❌ const bar = foo!!!.bar
1655
+ // ✅ const bar = foo!.bar
1656
+ "@typescript-eslint/no-extra-non-null-assertion": "warn",
1657
+ // Warns when a class is accidentally used as a namespace
1658
+ "@typescript-eslint/no-extraneous-class": "error",
1659
+ "@typescript-eslint/no-import-type-side-effects": "warn",
1660
+ // Disallow this keywords outside of classes or class-like objects
1661
+ "@typescript-eslint/no-invalid-this": "error",
1662
+ // Disallows usage of void type outside of generic or return types
1663
+ "@typescript-eslint/no-invalid-void-type": "error",
1664
+ // Disallow function declarations that contain unsafe references inside loop statements
1665
+ "@typescript-eslint/no-loop-func": "error",
1666
+ // Disallow literal numbers that lose precision
1667
+ "@typescript-eslint/no-loss-of-precision": ["error"],
1668
+ // Disallowing magic numbers causes all sorts of problems
1669
+ "@typescript-eslint/no-magic-numbers": "off",
1670
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
1671
+ "@typescript-eslint/no-redeclare": "error",
1672
+ "@typescript-eslint/no-require-imports": "error",
1673
+ "@typescript-eslint/no-restricted-imports": "off",
1674
+ // Disallow variable declarations from shadowing variables declared in the outer scope
1675
+ "@typescript-eslint/no-shadow": ["error"],
1676
+ // Aliasing can be useful
1677
+ "@typescript-eslint/no-type-alias": "off",
1678
+ // Disallows unnecessary constraints on generic types
1679
+ "@typescript-eslint/no-unnecessary-type-constraint": "warn",
1680
+ "@typescript-eslint/no-unsafe-declaration-merging": "error",
1681
+ // Aims to eliminate unused expressions which have no effect on the state of the program.
1682
+ "@typescript-eslint/no-unused-expressions": ["error"],
1683
+ // Variables must be used unless name ends with "ignored"
1684
+ "@typescript-eslint/no-unused-vars": [
1685
+ "error",
1686
+ {
1687
+ // Useful for extracting args from props and ignoring them:
1688
+ // { style: _style, ...restProps }
1689
+ argsIgnorePattern: "^_",
1690
+ varsIgnorePattern: "[iI]gnored"
1691
+ }
1692
+ ],
1693
+ "@typescript-eslint/no-use-before-define": "error",
1694
+ "@typescript-eslint/no-useless-constructor": "error",
1695
+ // Disallow empty exports that don't change anything in a module file
1696
+ "@typescript-eslint/no-useless-empty-export": "warn",
1697
+ "@typescript-eslint/padding-line-between-statements": [
1698
+ "error",
1699
+ { blankLine: "always", next: "*", prev: "multiline-block-like" },
1700
+ { blankLine: "always", next: "multiline-block-like", prev: "*" },
1701
+ { blankLine: "always", next: "*", prev: "multiline-const" },
1702
+ { blankLine: "always", next: "multiline-const", prev: "*" },
1703
+ { blankLine: "always", next: "*", prev: "multiline-let" },
1704
+ { blankLine: "always", next: "multiline-let", prev: "*" },
1705
+ { blankLine: "always", next: "*", prev: "multiline-var" },
1706
+ { blankLine: "always", next: "multiline-var", prev: "*" }
1707
+ ],
1708
+ // Not sure I need this, how many classes do I write?!
1709
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/parameter-properties.md
1710
+ "@typescript-eslint/parameter-properties": "off",
1711
+ "@typescript-eslint/prefer-enum-initializers": "error",
1712
+ // Unicorn does this better by providing a fixer
1713
+ "@typescript-eslint/prefer-for-of": "off",
1714
+ "@typescript-eslint/prefer-function-type": "warn",
1715
+ // Require that all enum members be literal values to prevent unintended enum member name shadow issues.
1716
+ "@typescript-eslint/prefer-literal-enum-member": "error",
1717
+ // Recommends using // @ts-expect-error over // @ts-ignore
1718
+ "@typescript-eslint/prefer-ts-expect-error": "warn",
1719
+ "@typescript-eslint/sort-type-constituents": "warn",
1720
+ // Not sure if required yet. Might be too strict and produce noist code.
1721
+ "@typescript-eslint/typedef": "off",
1722
+ "@typescript-eslint/unified-signatures": "error"
1723
+ }
1724
+ }
1725
+ ];
1726
+ }
1727
+
1728
+ // src/configs/unicorn.ts
1729
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
1730
+ function unicorn() {
1731
+ return [
1732
+ {
1733
+ plugins: {
1734
+ unicorn: import_eslint_plugin_unicorn.default
1735
+ },
1736
+ rules: {
1737
+ // This rule is superseded by the unicorn version below
1738
+ "no-nested-ternary": "off",
1739
+ // Improve regexes by making them shorter, consistent, and safer
1740
+ "unicorn/better-regex": "warn",
1741
+ // Catch error argument name should be "error"
1742
+ "unicorn/catch-error-name": "error",
1743
+ // Use destructured variables over properties
1744
+ "unicorn/consistent-destructuring": "warn",
1745
+ // Move function definitions to the highest possible scope
1746
+ "unicorn/consistent-function-scoping": [
1747
+ "error",
1748
+ { checkArrowFunctions: false }
1749
+ ],
1750
+ // Custom Error classes must conform to standard
1751
+ "unicorn/custom-error-definition": "warn",
1752
+ // Enforce no spaces between braces
1753
+ "unicorn/empty-brace-spaces": "warn",
1754
+ // Enforces a message value to be passed in when throwing built-in Error
1755
+ "unicorn/error-message": "error",
1756
+ // Enforces defining escape sequence values with uppercase characters rather
1757
+ // than lowercase ones. This promotes readability by making the escaped
1758
+ // value more distinguishable from the identifier.
1759
+ "unicorn/escape-case": "warn",
1760
+ // Allows todo/fixme to be given expiry conditions and will error when met
1761
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/expiring-todo-comments.md
1762
+ "unicorn/expiring-todo-comments": "error",
1763
+ // Don't care how if(blah.length) is checked
1764
+ "unicorn/explicit-length-check": "off",
1765
+ // Kebab-case only
1766
+ "unicorn/filename-case": "error",
1767
+ // Enforces requiring index file with . instead of ./, ./index or ./index.js
1768
+ // Turned off for imports where this can mess with ESM.
1769
+ "unicorn/import-index": ["warn", { ignoreImports: true }],
1770
+ // Not sure if this is useful yet
1771
+ "unicorn/import-style": "off",
1772
+ // Enforce the use of new for all builtins, except String, Number and Boolean
1773
+ "unicorn/new-for-builtins": "warn",
1774
+ // Enforce specifying rules to disable in eslint-disable comments
1775
+ "unicorn/no-abusive-eslint-disable": "error",
1776
+ // Allow passing a function reference directly to iterator methods
1777
+ "unicorn/no-array-callback-reference": "off",
1778
+ // Prefer for…of over Array#forEach(…)
1779
+ "unicorn/no-array-for-each": "warn",
1780
+ // Disallow using the this argument in array methods
1781
+ "unicorn/no-array-method-this-argument": "warn",
1782
+ // Enforce combining multiple Array#push() into one call
1783
+ "unicorn/no-array-push-push": "warn",
1784
+ // for..of is much easier to read
1785
+ "unicorn/no-array-reduce": "error",
1786
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md
1787
+ "unicorn/no-await-expression-member": "warn",
1788
+ // Do not use leading/trailing space between console.log parameters
1789
+ "unicorn/no-console-spaces": "warn",
1790
+ // Do not use document.cookie directly
1791
+ "unicorn/no-document-cookie": "error",
1792
+ // Disallow empty files
1793
+ // TODO turn back on when it can exclude files. As this warns about the
1794
+ // auto-generated next-env.d.ts file.
1795
+ "unicorn/no-empty-file": "off",
1796
+ // Do not use a for loop that can be replaced with a for-of loop
1797
+ "unicorn/no-for-loop": "warn",
1798
+ // Enforce the use of Unicode escapes instead of hexadecimal escapes
1799
+ "unicorn/no-hex-escape": "warn",
1800
+ // Require Array.isArray() instead of instanceof Array
1801
+ "unicorn/no-instanceof-array": "warn",
1802
+ // The removeEventListener function must be called with a reference to the same
1803
+ // function that was passed to addEventListener.
1804
+ "unicorn/no-invalid-remove-event-listener": "error",
1805
+ // Disallow identifiers (var names) starting with new.
1806
+ // Do not check properties and allow "class" so that "className" is allowed.
1807
+ "unicorn/no-keyword-prefix": [
1808
+ "error",
1809
+ { checkProperties: false, disallowedPrefixes: ["new"] }
1810
+ ],
1811
+ // This rule adds onto the built-in no-lonely-if rule, which only forbids if
1812
+ // statements in else, not in if.
1813
+ "unicorn/no-lonely-if": "warn",
1814
+ // This is an improved version of the no-negated-condition ESLint rule that
1815
+ // makes it automatically fixable. ESLint did not want to make it fixable.
1816
+ "unicorn/no-negated-condition": "warn",
1817
+ // Improved version of the no-nested-ternary ESLint rule, which allows cases
1818
+ // where the nested ternary is only one level and wrapped in parens.
1819
+ "unicorn/no-nested-ternary": "warn",
1820
+ // Disallow new Array()
1821
+ "unicorn/no-new-array": "warn",
1822
+ // Enforce the use of Buffer.from() and Buffer.alloc() instead of the
1823
+ // deprecated new Buffer()
1824
+ "unicorn/no-new-buffer": "warn",
1825
+ // Allow the use of the null literal, it useful for React components and empty JSON values.
1826
+ "unicorn/no-null": "off",
1827
+ // Disallow the use of objects as default parameters
1828
+ "unicorn/no-object-as-default-parameter": "error",
1829
+ // Extension to ESLint's no-process-exit rule, that allows process.exit() to
1830
+ // be called in files that start with a hashbang → #!/usr/bin/env node
1831
+ "unicorn/no-process-exit": "error",
1832
+ // A class with only static members could just be an object instead
1833
+ "unicorn/no-static-only-class": "error",
1834
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-thenable.md
1835
+ "unicorn/no-thenable": "error",
1836
+ // Disallow assigning this to a variable
1837
+ "unicorn/no-this-assignment": "error",
1838
+ // Checking if a value is undefined by using typeof value === 'undefined' is needlessly verbose.
1839
+ "unicorn/no-typeof-undefined": "warn",
1840
+ // Disallow awaiting non-promise values
1841
+ "unicorn/no-unnecessary-await": "warn",
1842
+ // Disallow [,, foo], use ignored vars instead
1843
+ "unicorn/no-unreadable-array-destructuring": "error",
1844
+ // IIFE with parenthesized arrow function body is considered unreadable
1845
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md
1846
+ "unicorn/no-unreadable-iife": "error",
1847
+ // Uses safe-regex to disallow potentially catastrophic exponential-time regular expressions.
1848
+ // Turned off for now, even Sindre doesn't like it: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/153
1849
+ "unicorn/no-unsafe-regex": "off",
1850
+ // Recommended config turned this off so I will too
1851
+ "unicorn/no-unused-properties": "off",
1852
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-fallback-in-spread.md
1853
+ "unicorn/no-useless-fallback-in-spread": "warn",
1854
+ // Disallow useless array length check
1855
+ "unicorn/no-useless-length-check": "warn",
1856
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md
1857
+ "unicorn/no-useless-promise-resolve-reject": "warn",
1858
+ // Disallow useless spread
1859
+ "unicorn/no-useless-spread": "warn",
1860
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md
1861
+ "unicorn/no-useless-switch-case": "error",
1862
+ // ❌ let foo = undefined;
1863
+ // ✅ let foo;
1864
+ "unicorn/no-useless-undefined": "warn",
1865
+ // Disallow number literals with zero fractions or dangling dots
1866
+ "unicorn/no-zero-fractions": "warn",
1867
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
1868
+ "unicorn/number-literal-case": "warn",
1869
+ // Enforce the style of numeric separators by correctly grouping digits
1870
+ "unicorn/numeric-separators-style": "warn",
1871
+ // Prefer .addEventListener() and .removeEventListener() over on-functions
1872
+ "unicorn/prefer-add-event-listener": "warn",
1873
+ // Prefer .find(…) over the first element from .filter(…)
1874
+ "unicorn/prefer-array-find": "warn",
1875
+ // Prefer Array#flat() over legacy techniques to flatten arrays
1876
+ "unicorn/prefer-array-flat": "warn",
1877
+ // Prefer .flatMap(…) over .map(…).flat()
1878
+ "unicorn/prefer-array-flat-map": "warn",
1879
+ // Prefer Array#indexOf() over Array#findIndex() when looking for the index of an item
1880
+ "unicorn/prefer-array-index-of": "warn",
1881
+ // Prefer using Array#some over Array#find when ensuring at least one element
1882
+ // in the array passes a given check.
1883
+ "unicorn/prefer-array-some": "error",
1884
+ // Prefer .at() method for index access and String#charAt()
1885
+ "unicorn/prefer-at": "warn",
1886
+ // Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…)
1887
+ "unicorn/prefer-blob-reading-methods": "error",
1888
+ // Prefer String#codePointAt(…) over String#charCodeAt(…)
1889
+ // and String.fromCodePoint(…) over String.fromCharCode(…)
1890
+ "unicorn/prefer-code-point": "error",
1891
+ // Prefer Date.now() to get the number of milliseconds since the Unix Epoch
1892
+ "unicorn/prefer-date-now": "warn",
1893
+ // Prefer default parameters over reassignment
1894
+ "unicorn/prefer-default-parameters": "warn",
1895
+ // Prefer Node#append() over Node#appendChild()
1896
+ "unicorn/prefer-dom-node-append": "warn",
1897
+ // Prefer using .dataset on DOM elements over .setAttribute(…)
1898
+ "unicorn/prefer-dom-node-dataset": "warn",
1899
+ // Prefer node.remove() over parentNode.removeChild(node) and parentElement.removeChild(node)
1900
+ "unicorn/prefer-dom-node-remove": "warn",
1901
+ // Prefer .textContent over .innerText
1902
+ "unicorn/prefer-dom-node-text-content": "warn",
1903
+ // Prefer EventTarget over EventEmitter.
1904
+ "unicorn/prefer-event-target": "error",
1905
+ // Prefer `export…from` when re-exporting
1906
+ "unicorn/prefer-export-from": "warn",
1907
+ // Prefer .includes() over .indexOf() when checking for existence or non-existence
1908
+ "unicorn/prefer-includes": "warn",
1909
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-json-parse-buffer.md
1910
+ "unicorn/prefer-json-parse-buffer": "warn",
1911
+ // Prefer KeyboardEvent#key over KeyboardEvent#keyCode
1912
+ "unicorn/prefer-keyboard-event-key": "warn",
1913
+ // Disallow ternary operators when simpler logical operator alternatives exist.
1914
+ "unicorn/prefer-logical-operator-over-ternary": "warn",
1915
+ // Enforce the use of Math.trunc instead of bitwise operators
1916
+ "unicorn/prefer-math-trunc": "warn",
1917
+ // e.g. foo.insertBefore(baz, bar) -> foo.before(bar, 'baz')
1918
+ "unicorn/prefer-modern-dom-apis": "warn",
1919
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md
1920
+ "unicorn/prefer-modern-math-apis": "warn",
1921
+ // Not ready yet for ESM modules
1922
+ // https://github.com/microsoft/TypeScript/issues/33079
1923
+ "unicorn/prefer-module": "off",
1924
+ // If a function is equivalent to String, Number, BigInt, Boolean, or Symbol,
1925
+ // you should use the built-in one directly. Wrapping the built-in in a function is moot.
1926
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-native-coercion-functions.md
1927
+ "unicorn/prefer-native-coercion-functions": "warn",
1928
+ // Prefer negative index over .length - index
1929
+ // for {String,Array,TypedArray}#slice() and Array#splice()
1930
+ "unicorn/prefer-negative-index": "warn",
1931
+ // Prefer using the node: protocol when importing Node.js builtin modules
1932
+ // TODO seems like this is not well supported by webpack yet
1933
+ "unicorn/prefer-node-protocol": "off",
1934
+ // Prefer Number static properties over global ones
1935
+ "unicorn/prefer-number-properties": "warn",
1936
+ // Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object
1937
+ "unicorn/prefer-object-from-entries": "warn",
1938
+ // Prefer Object.hasOwn(…) over Object.prototype.hasOwnProperty.call(…)
1939
+ "unicorn/prefer-object-has-own": "warn",
1940
+ // Prefer omitting the catch binding parameter
1941
+ "unicorn/prefer-optional-catch-binding": "warn",
1942
+ // Prefer borrowing methods from the prototype instead of methods from an instance
1943
+ "unicorn/prefer-prototype-methods": "warn",
1944
+ // Prefer .querySelector() over .getElementById(),
1945
+ // .querySelectorAll() over .getElementsByClassName() and .getElementsByTagName()
1946
+ "unicorn/prefer-query-selector": "warn",
1947
+ // Prefer Reflect.apply() over Function#apply()
1948
+ "unicorn/prefer-reflect-apply": "warn",
1949
+ // Prefer RegExp#test() over String#match() and RegExp#exec()
1950
+ "unicorn/prefer-regexp-test": "warn",
1951
+ // Prefer Set#has() over Array#includes() when checking for existence or non-existence
1952
+ // Set#has() is faster than Array#includes().
1953
+ "unicorn/prefer-set-has": "warn",
1954
+ // Prefer using Set#size instead of Array#length
1955
+ "unicorn/prefer-set-size": "warn",
1956
+ // Prefer the spread operator over Array.from()
1957
+ "unicorn/prefer-spread": "warn",
1958
+ // Prefer String#replaceAll() over regex searches with the global flag
1959
+ "unicorn/prefer-string-replace-all": "warn",
1960
+ // Prefer String#slice() over String#substr() and String#substring()
1961
+ "unicorn/prefer-string-slice": "warn",
1962
+ // Prefer String#startsWith() & String#endsWith() over more complex alternatives
1963
+ "unicorn/prefer-string-starts-ends-with": "error",
1964
+ // Prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight()
1965
+ "unicorn/prefer-string-trim-start-end": "warn",
1966
+ // Use whatever feels correct in the moment
1967
+ "unicorn/prefer-switch": "off",
1968
+ // Prefer ternary expressions over simple if-else statements
1969
+ "unicorn/prefer-ternary": ["warn", "only-single-line"],
1970
+ // Prefer top-level await over top-level promises and async function calls
1971
+ "unicorn/prefer-top-level-await": "error",
1972
+ // Enforce throwing TypeError in type checking conditions
1973
+ "unicorn/prefer-type-error": "warn",
1974
+ // Using complete words results in more readable code. Not everyone knows all your abbreviations.
1975
+ // Code is written only once, but read many times.
1976
+ "unicorn/prevent-abbreviations": [
1977
+ "warn",
1978
+ {
1979
+ allowList: {
1980
+ "next-env.d": true,
1981
+ "react-app-env.d": true
1982
+ },
1983
+ replacements: {
1984
+ props: false,
1985
+ ref: false,
1986
+ refs: false
1987
+ }
1988
+ }
1989
+ ],
1990
+ // Enforce the use of regex shorthands to improve readability
1991
+ "unicorn/regex-shorthand": "warn",
1992
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/relative-url-style.md
1993
+ "unicorn/relative-url-style": "warn",
1994
+ // Enforce using the separator argument with Array#join()
1995
+ "unicorn/require-array-join-separator": "warn",
1996
+ // Enforce using the digits argument with Number#toFixed()
1997
+ "unicorn/require-number-to-fixed-digits-argument": "warn",
1998
+ // Enforce using the targetOrigin argument with window.postMessage()
1999
+ "unicorn/require-post-message-target-origin": "error",
2000
+ // No swaps needed yet
2001
+ "unicorn/string-content": "off",
2002
+ // Only allow braces when there are variable declaration or function
2003
+ // declaration which requires a scope.
2004
+ "unicorn/switch-case-braces": ["warn", "avoid"],
2005
+ // Fix whitespace-insensitive template indentation
2006
+ "unicorn/template-indent": [
2007
+ "warn",
2008
+ {
2009
+ indent: 2
2010
+ }
2011
+ ],
2012
+ "unicorn/text-encoding-identifier-case": "error",
2013
+ // Require new when throwing an error
2014
+ "unicorn/throw-new-error": "warn"
2015
+ }
2016
+ }
2017
+ ];
2018
+ }
2019
+
2020
+ // src/utils.ts
2021
+ var import_node_fs = require("fs");
2022
+ var import_globby = require("globby");
2023
+ var import_load_json_file = require("load-json-file");
2024
+ function checkEnvironment() {
2025
+ const isGitIgnore = (0, import_node_fs.existsSync)(".gitignore");
2026
+ let isNodeEngine = false;
2027
+ let isPrettier = false;
2028
+ let isTailwind = false;
2029
+ let testingFramework = null;
2030
+ const allPackageJsonPaths = (0, import_globby.globbySync)([
2031
+ "**/package.json",
2032
+ // Could use the `gitIgnore` option but the negative pattern is about 8 times faster.
2033
+ // https://github.com/sindresorhus/globby/issues/50
2034
+ "!**/node_modules"
2035
+ ]);
2036
+ for (const packageJsonPath of allPackageJsonPaths) {
2037
+ const packageJson = (0, import_load_json_file.loadJsonFileSync)(packageJsonPath);
2038
+ if (!testingFramework && Boolean(
2039
+ packageJson.dependencies?.jest || packageJson.devDependencies?.jest
2040
+ ))
2041
+ testingFramework = "jest";
2042
+ if (!isNodeEngine && Boolean(packageJson.engines?.node))
2043
+ isNodeEngine = true;
2044
+ if (!isPrettier && Boolean(
2045
+ packageJson.dependencies?.prettier || packageJson.devDependencies?.prettier
2046
+ ))
2047
+ isPrettier = true;
2048
+ if (!isTailwind && Boolean(
2049
+ packageJson.dependencies?.tailwindcss || packageJson.devDependencies?.tailwindcss
2050
+ ))
2051
+ isTailwind = true;
2052
+ }
2053
+ const isNode = isNodeEngine || (0, import_node_fs.existsSync)(".nvmrc") || (0, import_node_fs.existsSync)(".node-version");
2054
+ return {
2055
+ isGitIgnore,
2056
+ isNode,
2057
+ isPrettier,
2058
+ isTailwind,
2059
+ testingFramework
2060
+ };
2061
+ }
2062
+
2063
+ // src/factory.ts
2064
+ function factory() {
2065
+ const { isGitIgnore, isNode, isPrettier, isTailwind, testingFramework } = checkEnvironment();
2066
+ const configs = [];
2067
+ if (isGitIgnore)
2068
+ configs.push([(0, import_eslint_config_flat_gitignore.default)()]);
2069
+ configs.push(
2070
+ ignores(),
2071
+ base(),
2072
+ imports(),
2073
+ switchCase(),
2074
+ unicorn(),
2075
+ typescript(),
2076
+ astro(),
2077
+ react()
2078
+ );
2079
+ if (isNode)
2080
+ configs.push(node());
2081
+ if (isTailwind)
2082
+ configs.push(node());
2083
+ if (testingFramework === "jest")
2084
+ configs.push(jest());
2085
+ if (isPrettier)
2086
+ configs.push(prettier());
2087
+ const merged = configs.flat();
2088
+ return merged;
2089
+ }