eslint-config-un 0.0.2

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.js ADDED
@@ -0,0 +1,2303 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // node_modules/.pnpm/tsup@8.1.0_postcss@8.4.39_typescript@5.5.3/node_modules/tsup/assets/esm_shims.js
31
+ var init_esm_shims = __esm({
32
+ "node_modules/.pnpm/tsup@8.1.0_postcss@8.4.39_typescript@5.5.3/node_modules/tsup/assets/esm_shims.js"() {
33
+ "use strict";
34
+ }
35
+ });
36
+
37
+ // node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/configs/eslint-all.js
38
+ var require_eslint_all = __commonJS({
39
+ "node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports, module) {
40
+ "use strict";
41
+ init_esm_shims();
42
+ module.exports = Object.freeze({
43
+ "rules": {
44
+ "accessor-pairs": "error",
45
+ "array-callback-return": "error",
46
+ "arrow-body-style": "error",
47
+ "block-scoped-var": "error",
48
+ "camelcase": "error",
49
+ "capitalized-comments": "error",
50
+ "class-methods-use-this": "error",
51
+ "complexity": "error",
52
+ "consistent-return": "error",
53
+ "consistent-this": "error",
54
+ "constructor-super": "error",
55
+ "curly": "error",
56
+ "default-case": "error",
57
+ "default-case-last": "error",
58
+ "default-param-last": "error",
59
+ "dot-notation": "error",
60
+ "eqeqeq": "error",
61
+ "for-direction": "error",
62
+ "func-name-matching": "error",
63
+ "func-names": "error",
64
+ "func-style": "error",
65
+ "getter-return": "error",
66
+ "grouped-accessor-pairs": "error",
67
+ "guard-for-in": "error",
68
+ "id-denylist": "error",
69
+ "id-length": "error",
70
+ "id-match": "error",
71
+ "init-declarations": "error",
72
+ "logical-assignment-operators": "error",
73
+ "max-classes-per-file": "error",
74
+ "max-depth": "error",
75
+ "max-lines": "error",
76
+ "max-lines-per-function": "error",
77
+ "max-nested-callbacks": "error",
78
+ "max-params": "error",
79
+ "max-statements": "error",
80
+ "new-cap": "error",
81
+ "no-alert": "error",
82
+ "no-array-constructor": "error",
83
+ "no-async-promise-executor": "error",
84
+ "no-await-in-loop": "error",
85
+ "no-bitwise": "error",
86
+ "no-caller": "error",
87
+ "no-case-declarations": "error",
88
+ "no-class-assign": "error",
89
+ "no-compare-neg-zero": "error",
90
+ "no-cond-assign": "error",
91
+ "no-console": "error",
92
+ "no-const-assign": "error",
93
+ "no-constant-binary-expression": "error",
94
+ "no-constant-condition": "error",
95
+ "no-constructor-return": "error",
96
+ "no-continue": "error",
97
+ "no-control-regex": "error",
98
+ "no-debugger": "error",
99
+ "no-delete-var": "error",
100
+ "no-div-regex": "error",
101
+ "no-dupe-args": "error",
102
+ "no-dupe-class-members": "error",
103
+ "no-dupe-else-if": "error",
104
+ "no-dupe-keys": "error",
105
+ "no-duplicate-case": "error",
106
+ "no-duplicate-imports": "error",
107
+ "no-else-return": "error",
108
+ "no-empty": "error",
109
+ "no-empty-character-class": "error",
110
+ "no-empty-function": "error",
111
+ "no-empty-pattern": "error",
112
+ "no-empty-static-block": "error",
113
+ "no-eq-null": "error",
114
+ "no-eval": "error",
115
+ "no-ex-assign": "error",
116
+ "no-extend-native": "error",
117
+ "no-extra-bind": "error",
118
+ "no-extra-boolean-cast": "error",
119
+ "no-extra-label": "error",
120
+ "no-fallthrough": "error",
121
+ "no-func-assign": "error",
122
+ "no-global-assign": "error",
123
+ "no-implicit-coercion": "error",
124
+ "no-implicit-globals": "error",
125
+ "no-implied-eval": "error",
126
+ "no-import-assign": "error",
127
+ "no-inline-comments": "error",
128
+ "no-inner-declarations": "error",
129
+ "no-invalid-regexp": "error",
130
+ "no-invalid-this": "error",
131
+ "no-irregular-whitespace": "error",
132
+ "no-iterator": "error",
133
+ "no-label-var": "error",
134
+ "no-labels": "error",
135
+ "no-lone-blocks": "error",
136
+ "no-lonely-if": "error",
137
+ "no-loop-func": "error",
138
+ "no-loss-of-precision": "error",
139
+ "no-magic-numbers": "error",
140
+ "no-misleading-character-class": "error",
141
+ "no-multi-assign": "error",
142
+ "no-multi-str": "error",
143
+ "no-negated-condition": "error",
144
+ "no-nested-ternary": "error",
145
+ "no-new": "error",
146
+ "no-new-func": "error",
147
+ "no-new-native-nonconstructor": "error",
148
+ "no-new-wrappers": "error",
149
+ "no-nonoctal-decimal-escape": "error",
150
+ "no-obj-calls": "error",
151
+ "no-object-constructor": "error",
152
+ "no-octal": "error",
153
+ "no-octal-escape": "error",
154
+ "no-param-reassign": "error",
155
+ "no-plusplus": "error",
156
+ "no-promise-executor-return": "error",
157
+ "no-proto": "error",
158
+ "no-prototype-builtins": "error",
159
+ "no-redeclare": "error",
160
+ "no-regex-spaces": "error",
161
+ "no-restricted-exports": "error",
162
+ "no-restricted-globals": "error",
163
+ "no-restricted-imports": "error",
164
+ "no-restricted-properties": "error",
165
+ "no-restricted-syntax": "error",
166
+ "no-return-assign": "error",
167
+ "no-script-url": "error",
168
+ "no-self-assign": "error",
169
+ "no-self-compare": "error",
170
+ "no-sequences": "error",
171
+ "no-setter-return": "error",
172
+ "no-shadow": "error",
173
+ "no-shadow-restricted-names": "error",
174
+ "no-sparse-arrays": "error",
175
+ "no-template-curly-in-string": "error",
176
+ "no-ternary": "error",
177
+ "no-this-before-super": "error",
178
+ "no-throw-literal": "error",
179
+ "no-undef": "error",
180
+ "no-undef-init": "error",
181
+ "no-undefined": "error",
182
+ "no-underscore-dangle": "error",
183
+ "no-unexpected-multiline": "error",
184
+ "no-unmodified-loop-condition": "error",
185
+ "no-unneeded-ternary": "error",
186
+ "no-unreachable": "error",
187
+ "no-unreachable-loop": "error",
188
+ "no-unsafe-finally": "error",
189
+ "no-unsafe-negation": "error",
190
+ "no-unsafe-optional-chaining": "error",
191
+ "no-unused-expressions": "error",
192
+ "no-unused-labels": "error",
193
+ "no-unused-private-class-members": "error",
194
+ "no-unused-vars": "error",
195
+ "no-use-before-define": "error",
196
+ "no-useless-assignment": "error",
197
+ "no-useless-backreference": "error",
198
+ "no-useless-call": "error",
199
+ "no-useless-catch": "error",
200
+ "no-useless-computed-key": "error",
201
+ "no-useless-concat": "error",
202
+ "no-useless-constructor": "error",
203
+ "no-useless-escape": "error",
204
+ "no-useless-rename": "error",
205
+ "no-useless-return": "error",
206
+ "no-var": "error",
207
+ "no-void": "error",
208
+ "no-warning-comments": "error",
209
+ "no-with": "error",
210
+ "object-shorthand": "error",
211
+ "one-var": "error",
212
+ "operator-assignment": "error",
213
+ "prefer-arrow-callback": "error",
214
+ "prefer-const": "error",
215
+ "prefer-destructuring": "error",
216
+ "prefer-exponentiation-operator": "error",
217
+ "prefer-named-capture-group": "error",
218
+ "prefer-numeric-literals": "error",
219
+ "prefer-object-has-own": "error",
220
+ "prefer-object-spread": "error",
221
+ "prefer-promise-reject-errors": "error",
222
+ "prefer-regex-literals": "error",
223
+ "prefer-rest-params": "error",
224
+ "prefer-spread": "error",
225
+ "prefer-template": "error",
226
+ "radix": "error",
227
+ "require-atomic-updates": "error",
228
+ "require-await": "error",
229
+ "require-unicode-regexp": "error",
230
+ "require-yield": "error",
231
+ "sort-imports": "error",
232
+ "sort-keys": "error",
233
+ "sort-vars": "error",
234
+ "strict": "error",
235
+ "symbol-description": "error",
236
+ "unicode-bom": "error",
237
+ "use-isnan": "error",
238
+ "valid-typeof": "error",
239
+ "vars-on-top": "error",
240
+ "yoda": "error"
241
+ }
242
+ });
243
+ }
244
+ });
245
+
246
+ // node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
247
+ var require_eslint_recommended = __commonJS({
248
+ "node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports, module) {
249
+ "use strict";
250
+ init_esm_shims();
251
+ module.exports = Object.freeze({
252
+ rules: Object.freeze({
253
+ "constructor-super": "error",
254
+ "for-direction": "error",
255
+ "getter-return": "error",
256
+ "no-async-promise-executor": "error",
257
+ "no-case-declarations": "error",
258
+ "no-class-assign": "error",
259
+ "no-compare-neg-zero": "error",
260
+ "no-cond-assign": "error",
261
+ "no-const-assign": "error",
262
+ "no-constant-binary-expression": "error",
263
+ "no-constant-condition": "error",
264
+ "no-control-regex": "error",
265
+ "no-debugger": "error",
266
+ "no-delete-var": "error",
267
+ "no-dupe-args": "error",
268
+ "no-dupe-class-members": "error",
269
+ "no-dupe-else-if": "error",
270
+ "no-dupe-keys": "error",
271
+ "no-duplicate-case": "error",
272
+ "no-empty": "error",
273
+ "no-empty-character-class": "error",
274
+ "no-empty-pattern": "error",
275
+ "no-empty-static-block": "error",
276
+ "no-ex-assign": "error",
277
+ "no-extra-boolean-cast": "error",
278
+ "no-fallthrough": "error",
279
+ "no-func-assign": "error",
280
+ "no-global-assign": "error",
281
+ "no-import-assign": "error",
282
+ "no-invalid-regexp": "error",
283
+ "no-irregular-whitespace": "error",
284
+ "no-loss-of-precision": "error",
285
+ "no-misleading-character-class": "error",
286
+ "no-new-native-nonconstructor": "error",
287
+ "no-nonoctal-decimal-escape": "error",
288
+ "no-obj-calls": "error",
289
+ "no-octal": "error",
290
+ "no-prototype-builtins": "error",
291
+ "no-redeclare": "error",
292
+ "no-regex-spaces": "error",
293
+ "no-self-assign": "error",
294
+ "no-setter-return": "error",
295
+ "no-shadow-restricted-names": "error",
296
+ "no-sparse-arrays": "error",
297
+ "no-this-before-super": "error",
298
+ "no-undef": "error",
299
+ "no-unexpected-multiline": "error",
300
+ "no-unreachable": "error",
301
+ "no-unsafe-finally": "error",
302
+ "no-unsafe-negation": "error",
303
+ "no-unsafe-optional-chaining": "error",
304
+ "no-unused-labels": "error",
305
+ "no-unused-private-class-members": "error",
306
+ "no-unused-vars": "error",
307
+ "no-useless-backreference": "error",
308
+ "no-useless-catch": "error",
309
+ "no-useless-escape": "error",
310
+ "no-with": "error",
311
+ "require-yield": "error",
312
+ "use-isnan": "error",
313
+ "valid-typeof": "error"
314
+ })
315
+ });
316
+ }
317
+ });
318
+
319
+ // node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/index.js
320
+ var require_src = __commonJS({
321
+ "node_modules/.pnpm/@eslint+js@9.6.0/node_modules/@eslint/js/src/index.js"(exports, module) {
322
+ "use strict";
323
+ init_esm_shims();
324
+ module.exports = {
325
+ configs: {
326
+ all: require_eslint_all(),
327
+ recommended: require_eslint_recommended()
328
+ }
329
+ };
330
+ }
331
+ });
332
+
333
+ // src/index.ts
334
+ init_esm_shims();
335
+ import eslintPluginStylistic from "@stylistic/eslint-plugin";
336
+ import eslintConfigPrettier from "eslint-config-prettier";
337
+ import pluginDisableAutofix from "eslint-plugin-disable-autofix";
338
+ import eslintPluginUnicorn2 from "eslint-plugin-unicorn";
339
+ import globals2 from "globals";
340
+ import { getPackageInfoSync, isPackageExists } from "local-pkg";
341
+
342
+ // src/configs/import.ts
343
+ init_esm_shims();
344
+ import eslintPluginImportX from "eslint-plugin-import-x";
345
+
346
+ // src/constants.ts
347
+ init_esm_shims();
348
+ var ERROR = 2;
349
+ var WARNING = 1;
350
+ var OFF = 0;
351
+ var GLOB_JS_TS_EXTENSION = "?([cm])[jt]s?(x)";
352
+ var GLOB_JS_TS = `**/*.${GLOB_JS_TS_EXTENSION}`;
353
+ var GLOB_CONFIG_FILES = [
354
+ `**/*.config.${GLOB_JS_TS_EXTENSION}`,
355
+ `**/.*rc.${GLOB_JS_TS_EXTENSION}`
356
+ ];
357
+ var GLOB_TS = "**/*.?([cm])ts";
358
+ var GLOB_TSX = `${GLOB_TS}x`;
359
+ var GLOB_VUE = "**/*.vue";
360
+
361
+ // src/utils.ts
362
+ init_esm_shims();
363
+ var genFlatConfigEntryName = (name) => `eslint-config-un/${name}`;
364
+ var genRuleOverrideFn = (prefix) => (baseRuleName, severity, ...options) => ({
365
+ [baseRuleName]: OFF,
366
+ [`${prefix}/${baseRuleName}`]: [severity, ...options]
367
+ });
368
+ var disableAutofixForRule = genRuleOverrideFn("disable-autofix");
369
+ var createPluginObjectRenamer = (from, to) => {
370
+ const fromRegex = new RegExp(`^${from}/`);
371
+ return (object) => Object.fromEntries(
372
+ Object.entries(object).map(([ruleName, v]) => [ruleName.replace(fromRegex, `${to}/`), v])
373
+ );
374
+ };
375
+ var assignOptions = (options, key) => ({
376
+ ...typeof options[key] === "object" && options[key]
377
+ });
378
+ var warnUnlessForcedError = (internalOptions, rule, ...options) => {
379
+ const { errorsInsteadOfWarnings } = internalOptions.globalOptions || {};
380
+ const level = errorsInsteadOfWarnings === true || Array.isArray(errorsInsteadOfWarnings) && errorsInsteadOfWarnings.includes(rule) ? ERROR : WARNING;
381
+ return {
382
+ [rule]: [level, ...options]
383
+ };
384
+ };
385
+ var arraify = (value) => Array.isArray(value) ? value : value == null ? [] : [value];
386
+
387
+ // src/configs/import.ts
388
+ var pluginRenamer = createPluginObjectRenamer("import-x", "import");
389
+ var importEslintConfig = (options = {}, internalOptions = {}) => {
390
+ const isTsEnabled = options.tsconfigPath != null;
391
+ const noUnresolvedIgnores = arraify(options.importPatternsToIgnoreWhenTryingToResolve);
392
+ const rules = {
393
+ // 'import/consistent-type-specifier-style': OFF,
394
+ // 'import/default': ERROR,
395
+ // 'import/dynamic-import-chunkname': OFF,
396
+ // 'import/export': ERROR,
397
+ // 'import/exports-last': OFF,
398
+ "import/extensions": [
399
+ options.requireModuleExtensions ? ERROR : OFF,
400
+ typeof options.requireModuleExtensions === "object" && options.requireModuleExtensions["*"] || "ignorePackages",
401
+ {
402
+ ...options.requireModuleExtensions === true && Object.fromEntries(
403
+ ["js", "cjs", "mjs", "ts", "cts", "mts", "jsx", "tsx"].map((ext) => [ext, "always"])
404
+ ),
405
+ ...typeof options.requireModuleExtensions === "object" && options.requireModuleExtensions
406
+ }
407
+ ],
408
+ "import/first": ERROR,
409
+ // 'import/group-exports': OFF,
410
+ // 'import/max-dependencies': OFF,
411
+ // 'import/named': ERROR | OFF, // disabled in TS config
412
+ // 'import/namespace': ERROR,
413
+ "import/newline-after-import": ERROR,
414
+ "import/no-absolute-path": ERROR,
415
+ // 'import/no-amd': OFF,
416
+ // 'import/no-anonymous-default-export': OFF,
417
+ // 'import/no-commonjs': OFF,
418
+ ...warnUnlessForcedError(internalOptions, "import/no-cycle"),
419
+ "import/no-default-export": ERROR,
420
+ ...warnUnlessForcedError(internalOptions, "import/no-deprecated"),
421
+ // 'import/no-duplicates': ERROR,
422
+ // 'import/no-dynamic-require': OFF,
423
+ "import/no-empty-named-blocks": ERROR,
424
+ "import/no-extraneous-dependencies": [ERROR, { peerDependencies: false }],
425
+ // 'import/no-import-module-exports': OFF, // TODO enable?
426
+ // 'import/no-internal-modules': OFF,
427
+ ...warnUnlessForcedError(internalOptions, "import/no-mutable-exports"),
428
+ "import/no-named-as-default-member": OFF,
429
+ "import/no-named-as-default": OFF,
430
+ // Not very useful + false positives for axios@1.6.7?
431
+ // 'import/no-named-default': OFF,
432
+ // 'import/no-named-export': OFF,
433
+ // 'import/no-namespace': OFF,
434
+ // 'import/no-nodejs-modules': OFF, // TODO
435
+ // 'import/no-relative-packages': OFF,
436
+ // 'import/no-relative-parent-imports': OFF,
437
+ // 'import/no-restricted-paths': OFF,
438
+ "import/no-self-import": ERROR,
439
+ // 'import/no-unassigned-import': OFF,
440
+ "import/no-unresolved": [
441
+ ERROR,
442
+ {
443
+ ...noUnresolvedIgnores.length > 0 && { ignore: noUnresolvedIgnores }
444
+ }
445
+ ],
446
+ // 'import/no-unused-modules': OFF,
447
+ ...warnUnlessForcedError(internalOptions, "import/no-useless-path-segments"),
448
+ "import/no-webpack-loader-syntax": ERROR,
449
+ "import/order": [
450
+ ERROR,
451
+ {
452
+ groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
453
+ alphabetize: { order: "asc" }
454
+ }
455
+ ]
456
+ // 'import/prefer-default-export': OFF,
457
+ // 'import/unambiguous': OFF,
458
+ };
459
+ return [
460
+ {
461
+ plugins: {
462
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
463
+ import: eslintPluginImportX
464
+ },
465
+ ...options.files && { files: options.files },
466
+ ...options.ignores && { ignores: options.ignores },
467
+ settings: {
468
+ ...isTsEnabled && eslintPluginImportX.configs.typescript.settings,
469
+ "import-x/resolver": {
470
+ ...isTsEnabled && {
471
+ typescript: {
472
+ project: true,
473
+ alwaysTryTypes: true
474
+ }
475
+ },
476
+ node: true
477
+ // TODO
478
+ },
479
+ ...isTsEnabled && {
480
+ "import-x/parsers": {
481
+ "@typescript-eslint/parser": [".ts", ".cts", ".mts", ".tsx", ".ctsx", ".mtsx"]
482
+ }
483
+ }
484
+ },
485
+ rules: {
486
+ ...pluginRenamer(eslintPluginImportX.configs.recommended.rules),
487
+ ...isTsEnabled && pluginRenamer(eslintPluginImportX.configs.typescript.rules),
488
+ ...rules,
489
+ ...options.overrides
490
+ },
491
+ name: genFlatConfigEntryName("import")
492
+ }
493
+ ];
494
+ };
495
+
496
+ // src/configs/js.ts
497
+ init_esm_shims();
498
+ var import_js = __toESM(require_src(), 1);
499
+ var RULE_CAMELCASE_OPTIONS = {
500
+ properties: "never",
501
+ ignoreGlobals: true,
502
+ allow: [String.raw`\d_\d`]
503
+ };
504
+ var RULE_EQEQEQ_OPTIONS = ["always", { null: "ignore" }];
505
+ var RULE_NO_UNUSED_EXPRESSIONS_OPTIONS = {
506
+ allowShortCircuit: true,
507
+ allowTernary: true,
508
+ allowTaggedTemplates: true
509
+ };
510
+ var RULE_NO_USE_BEFORE_DEFINE_OPTIONS = {
511
+ functions: false
512
+ };
513
+ var RULE_PREFER_DESTRUCTURING_OPTIONS = {
514
+ VariableDeclarator: {
515
+ array: false,
516
+ object: true
517
+ },
518
+ AssignmentExpression: {
519
+ array: false,
520
+ object: false
521
+ }
522
+ };
523
+ var jsEslintConfig = (options = {}, internalOptions = {}) => {
524
+ const rules = {
525
+ // 🔵 Recommended - Possible Problems
526
+ // 'constructor-super': ERROR,
527
+ // 'for-direction': ERROR,
528
+ // 'getter-return': ERROR,
529
+ // 'no-async-promise-executor': ERROR,
530
+ // 'no-class-assign': ERROR,
531
+ // 'no-compare-neg-zero': ERROR,
532
+ // 'no-cond-assign': ERROR,
533
+ // 'no-const-assign': ERROR,
534
+ // 'no-constant-binary-expression': ERROR,
535
+ // 'no-constant-condition': ERROR,
536
+ // 'no-control-regex': ERROR,
537
+ // 'no-debugger': ERROR,
538
+ // 'no-dupe-args': ERROR,
539
+ // 'no-dupe-class-members': ERROR,
540
+ // 'no-dupe-else-if': ERROR,
541
+ // 'no-dupe-keys': ERROR,
542
+ // 'no-duplicate-case': ERROR,
543
+ // 'no-empty-character-class': ERROR,
544
+ // 'no-empty-pattern': ERROR,
545
+ // 'no-ex-assign': ERROR,
546
+ // 'no-fallthrough': ERROR,
547
+ // 'no-func-assign': ERROR,
548
+ // 'no-import-assign': ERROR,
549
+ // 'no-invalid-regexp': ERROR,
550
+ // 'no-irregular-whitespace': ERROR,
551
+ // 'no-loss-of-precision': ERROR,
552
+ // 'no-misleading-character-class': ERROR,
553
+ // 'no-new-native-nonconstructor': ERROR,
554
+ // 'no-obj-calls': ERROR,
555
+ // 'no-prototype-builtins': ERROR,
556
+ // 'no-self-assign': ERROR,
557
+ // 'no-setter-return': ERROR,
558
+ // 'no-sparse-arrays': ERROR,
559
+ // 'no-this-before-super': ERROR,
560
+ // 'no-undef': ERROR,
561
+ // 'no-unexpected-multiline': ERROR,
562
+ // 'no-unreachable': ERROR,
563
+ // 'no-unsafe-finally': ERROR,
564
+ // 'no-unsafe-negation': ERROR,
565
+ // 'no-unsafe-optional-chaining': ERROR,
566
+ // 'no-unused-private-class-members': ERROR,
567
+ // 'no-unused-vars': ERROR,
568
+ // 'no-useless-backreference': ERROR,
569
+ // 'use-isnan': ERROR,
570
+ // 'valid-typeof': ERROR,
571
+ // 🔵 Recommended - Suggestions
572
+ // 'no-case-declarations': ERROR,
573
+ // 'no-delete-var': ERROR,
574
+ // 'no-empty': ERROR,
575
+ // 'no-empty-static-block': ERROR,
576
+ // 'no-extra-boolean-cast': ERROR,
577
+ // 'no-global-assign': ERROR,
578
+ // 'no-nonoctal-decimal-escape': ERROR,
579
+ // 'no-octal': ERROR,
580
+ // 'no-redeclare': ERROR,
581
+ // 'no-regex-spaces': ERROR,
582
+ // 'no-shadow-restricted-names': ERROR,
583
+ // 'no-unused-labels': ERROR,
584
+ // 'no-useless-catch': ERROR,
585
+ // 'no-useless-escape': ERROR,
586
+ // 'no-with': ERROR,
587
+ // 'require-yield': ERROR,
588
+ // 🔵 Not in recommended - Possible Problems
589
+ "array-callback-return": [ERROR, { checkForEach: true }],
590
+ ...warnUnlessForcedError(internalOptions, "no-await-in-loop"),
591
+ ...warnUnlessForcedError(internalOptions, "no-constructor-return"),
592
+ "no-duplicate-imports": ERROR,
593
+ "no-inner-declarations": ERROR,
594
+ "no-promise-executor-return": ERROR,
595
+ "no-self-compare": ERROR,
596
+ "no-template-curly-in-string": ERROR,
597
+ "no-unmodified-loop-condition": ERROR,
598
+ "no-unreachable-loop": ERROR,
599
+ "no-use-before-define": [ERROR, RULE_NO_USE_BEFORE_DEFINE_OPTIONS],
600
+ "no-useless-assignment": ERROR,
601
+ // @ts-expect-error no options typings
602
+ "require-atomic-updates": [ERROR, { allowProperties: true }],
603
+ // 🔵 Not in recommended - Suggestions
604
+ "accessor-pairs": ERROR,
605
+ // 'arrow-body-style': OFF,
606
+ "block-scoped-var": ERROR,
607
+ // @ts-expect-error incorrect typings
608
+ camelcase: [ERROR, RULE_CAMELCASE_OPTIONS],
609
+ // 'capitalized-comments': OFF,
610
+ "class-methods-use-this": ERROR,
611
+ // complexity: OFF,
612
+ "consistent-return": ERROR,
613
+ "consistent-this": [ERROR, "that"],
614
+ curly: [
615
+ ERROR,
616
+ "all"
617
+ /* default */
618
+ ],
619
+ "default-case": ERROR,
620
+ "default-case-last": ERROR,
621
+ "default-param-last": ERROR,
622
+ "dot-notation": ERROR,
623
+ eqeqeq: [ERROR, ...RULE_EQEQEQ_OPTIONS],
624
+ "func-name-matching": [ERROR, { considerPropertyDescriptor: true }],
625
+ // 'func-names': OFF,
626
+ // 'func-style': OFF,
627
+ "grouped-accessor-pairs": [ERROR, "getBeforeSet"],
628
+ "guard-for-in": ERROR,
629
+ // 'id-denylist': OFF,
630
+ // 'id-length': OFF,
631
+ // 'id-match': OFF,
632
+ // 'init-declarations': OFF,
633
+ "logical-assignment-operators": [ERROR, "always", { enforceForIfStatements: true }],
634
+ // @ts-expect-error incorrect typings
635
+ "max-classes-per-file": [ERROR, { ignoreExpressions: true, max: 2 }],
636
+ // 'max-depth': OFF,
637
+ // 'max-lines': OFF,
638
+ // 'max-lines-per-function': OFF,
639
+ // 'max-nested-callbacks': OFF,
640
+ // 'max-params': OFF,
641
+ // 'max-statements': OFF,
642
+ "new-cap": [ERROR, { properties: false, capIsNew: false }],
643
+ ...warnUnlessForcedError(internalOptions, "no-alert"),
644
+ "no-array-constructor": ERROR,
645
+ // 'no-bitwise': OFF,
646
+ "no-caller": ERROR,
647
+ ...warnUnlessForcedError(internalOptions, "no-console", { allow: ["warn", "error"] }),
648
+ // 'no-continue': OFF,
649
+ // 'no-div-regex': OFF,
650
+ "no-else-return": [ERROR, { allowElseIf: false }],
651
+ "no-empty-function": ERROR,
652
+ // 'no-eq-null': OFF,
653
+ "no-eval": ERROR,
654
+ "no-extend-native": ERROR,
655
+ "no-extra-bind": ERROR,
656
+ "no-extra-label": ERROR,
657
+ "no-implicit-coercion": [ERROR, { boolean: true, disallowTemplateShorthand: true }],
658
+ // 'no-implicit-globals': OFF,
659
+ "no-implied-eval": ERROR,
660
+ // 'no-inline-comments': OFF,
661
+ // 'no-invalid-this': OFF,
662
+ "no-iterator": ERROR,
663
+ "no-label-var": ERROR,
664
+ "no-labels": [ERROR, { allowLoop: false }],
665
+ "no-lone-blocks": ERROR,
666
+ "no-lonely-if": ERROR,
667
+ "no-loop-func": ERROR,
668
+ // 'no-magic-numbers': OFF,
669
+ "no-multi-assign": ERROR,
670
+ "no-multi-str": ERROR,
671
+ "no-negated-condition": ERROR,
672
+ // 'no-nested-ternary': OFF,
673
+ ...warnUnlessForcedError(internalOptions, "no-new"),
674
+ "no-new-func": ERROR,
675
+ "no-new-wrappers": ERROR,
676
+ "no-object-constructor": ERROR,
677
+ "no-octal-escape": ERROR,
678
+ ...warnUnlessForcedError(internalOptions, "no-param-reassign"),
679
+ // 'no-plusplus': OFF,
680
+ "no-proto": ERROR,
681
+ // 'no-restricted-exports': OFF,
682
+ "no-restricted-globals": [
683
+ ERROR,
684
+ { name: "global", message: "Use `globalThis` instead" },
685
+ { name: "self", message: "Use `globalThis` instead" },
686
+ { name: "event", message: "Use local parameter instead" }
687
+ ],
688
+ // 'no-restricted-imports': OFF,
689
+ // 'no-restricted-properties': OFF,
690
+ // 'no-restricted-syntax': OFF,
691
+ "no-return-assign": [ERROR, "always"],
692
+ "no-script-url": ERROR,
693
+ "no-sequences": ERROR,
694
+ "no-shadow": ERROR,
695
+ // 'no-ternary': OFF,
696
+ "no-throw-literal": ERROR,
697
+ "no-undef-init": ERROR,
698
+ // 'no-undefined': OFF,
699
+ // Had a potential, but unfortunately reports accesses of object properties starting with _
700
+ // 'no-underscore-dangle': [
701
+ // OFF,
702
+ // {
703
+ // allow: ['__dirname', '__filename'],
704
+ // allowAfterThis: true,
705
+ // allowAfterSuper: true,
706
+ // // @ts-expect-error does not exist in typings
707
+ // allowAfterThisConstructor: true,
708
+ // },
709
+ // ],
710
+ "no-unneeded-ternary": [ERROR, { defaultAssignment: false }],
711
+ "no-unused-expressions": [ERROR, RULE_NO_UNUSED_EXPRESSIONS_OPTIONS],
712
+ "no-useless-call": ERROR,
713
+ "no-useless-computed-key": ERROR,
714
+ "no-useless-concat": ERROR,
715
+ "no-useless-constructor": ERROR,
716
+ "no-useless-rename": ERROR,
717
+ "no-useless-return": ERROR,
718
+ "no-var": ERROR,
719
+ // @ts-expect-error incorrect typings
720
+ "no-void": [ERROR, { allowAsStatement: true }],
721
+ // 'no-warning-comments': OFF,
722
+ "object-shorthand": ERROR,
723
+ "one-var": [ERROR, "never"],
724
+ "operator-assignment": ERROR,
725
+ "prefer-arrow-callback": [
726
+ ERROR,
727
+ {
728
+ allowNamedFunctions: false,
729
+ allowUnboundThis: true
730
+ }
731
+ ],
732
+ "prefer-const": [ERROR, { ignoreReadBeforeAssign: true }],
733
+ "prefer-destructuring": [ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS],
734
+ "prefer-exponentiation-operator": ERROR,
735
+ // 'prefer-named-capture-group': OFF,
736
+ "prefer-numeric-literals": ERROR,
737
+ // TODO disable if ecmaVersion<2022?
738
+ "prefer-object-has-own": ERROR,
739
+ "prefer-object-spread": ERROR,
740
+ "prefer-promise-reject-errors": ERROR,
741
+ "prefer-regex-literals": [ERROR, { disallowRedundantWrapping: true }],
742
+ "prefer-rest-params": ERROR,
743
+ "prefer-spread": ERROR,
744
+ "prefer-template": ERROR,
745
+ radix: ERROR,
746
+ "require-await": ERROR,
747
+ // 'require-unicode-regexp': OFF,
748
+ "sort-imports": [ERROR, { ignoreDeclarationSort: true }],
749
+ // 'sort-keys': OFF,
750
+ // 'sort-vars': OFF,
751
+ strict: [ERROR, "never"],
752
+ "symbol-description": ERROR,
753
+ "vars-on-top": ERROR,
754
+ yoda: ERROR,
755
+ // 🔵 Not in recommended - Layout & Formatting
756
+ "unicode-bom": ERROR,
757
+ // 🔵 Stylistic
758
+ "@stylistic/quotes": [
759
+ ERROR,
760
+ "single",
761
+ // Doesn't matter since `ignoreStringLiterals` is true - BUT will be used in fixes
762
+ {
763
+ ignoreStringLiterals: true,
764
+ avoidEscape: true
765
+ // TODO Doesn't have any effect `ignoreStringLiterals` is true - should propose auto-fix?
766
+ }
767
+ ]
768
+ };
769
+ return [
770
+ {
771
+ ...options.files && { files: options.files },
772
+ ...options.ignores && { ignores: options.ignores },
773
+ // https://eslint.org/docs/latest/rules/
774
+ rules: {
775
+ ...import_js.default.configs.recommended.rules,
776
+ ...rules,
777
+ ...options.overrides
778
+ },
779
+ name: genFlatConfigEntryName("js")
780
+ }
781
+ ];
782
+ };
783
+
784
+ // src/configs/node.ts
785
+ init_esm_shims();
786
+ import eslintPluginNode from "eslint-plugin-n";
787
+ var pluginRenamer2 = createPluginObjectRenamer("n", "node");
788
+ var nodeEslintConfig = (options = {}, internalOptions = {}) => {
789
+ const rules = {
790
+ // 'node/callback-return': OFF,
791
+ "node/exports-style": [
792
+ ERROR,
793
+ "module.exports",
794
+ {
795
+ allowBatchAssign: false
796
+ }
797
+ ],
798
+ // 'node/file-extension-in-import': OFF,
799
+ // 'node/global-require': OFF,
800
+ // 'node/handle-callback-err': OFF,
801
+ // 'node/hashbang': ERROR,
802
+ // 'node/no-callback-literal': OFF,
803
+ // 'node/no-deprecated-api': ERROR,
804
+ // 'node/no-exports-assign': ERROR,
805
+ // TODO only disable when import plugin is enabled?
806
+ "node/no-extraneous-import": OFF,
807
+ // 'node/no-extraneous-require': ERROR, // TODO handled by import plugin too?
808
+ // TODO only disable when import plugin is enabled?
809
+ "node/no-missing-import": OFF,
810
+ // 'node/no-missing-require': ERROR, // TODO handled by import plugin too?
811
+ // 'node/no-mixed-requires': OFF,
812
+ "node/no-new-require": ERROR,
813
+ "node/no-path-concat": ERROR,
814
+ // 'node/no-process-env': OFF,
815
+ "node/no-process-exit": OFF,
816
+ // The corresponding Unicorn rule is better: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/1deb9bb5edf27fdb2f656add11c924dfa59fdac9/docs/rules/no-process-exit.md
817
+ "unicorn/no-process-exit": ERROR,
818
+ // TODO
819
+ // 'node/no-restricted-import': OFF,
820
+ // 'node/no-restricted-require': OFF,
821
+ // 'node/no-sync': OFF,
822
+ // 'node/no-unpublished-bin': ERROR,
823
+ // TODO only disable when import plugin is enabled?
824
+ "node/no-unpublished-import": OFF,
825
+ // 'node/no-unpublished-require': ERROR, // TODO handled by import plugin too?
826
+ // 'node/no-unsupported-features/es-builtins': ERROR,
827
+ // 'node/no-unsupported-features/es-syntax': ERROR,
828
+ // 'node/no-unsupported-features/node-builtins': ERROR,
829
+ "node/prefer-global/buffer": ERROR,
830
+ "node/prefer-global/console": ERROR,
831
+ "node/prefer-global/process": ERROR,
832
+ "node/prefer-global/text-decoder": ERROR,
833
+ "node/prefer-global/text-encoder": ERROR,
834
+ "node/prefer-global/url": ERROR,
835
+ "node/prefer-global/url-search-params": ERROR,
836
+ "node/prefer-node-protocol": ERROR,
837
+ "node/prefer-promises/dns": OFF,
838
+ // TODO enable?
839
+ "node/prefer-promises/fs": OFF
840
+ // TODO enable?
841
+ // Does not report anything, makes ESLint treat `process.exit()` calls as a stop: https://github.com/eslint-community/eslint-plugin-node/blob/c092cd893010f8da894f87da567c07d69be6cc0d/docs/rules/process-exit-as-throw.md
842
+ // 'node/process-exit-as-throw': ERROR,
843
+ };
844
+ return [
845
+ {
846
+ plugins: {
847
+ node: eslintPluginNode
848
+ },
849
+ ...options.files && { files: options.files },
850
+ ...options.ignores && { ignores: options.ignores },
851
+ rules: {
852
+ ...pluginRenamer2(eslintPluginNode.configs["flat/recommended"].rules || {}),
853
+ ...rules,
854
+ ...options.overrides
855
+ },
856
+ name: genFlatConfigEntryName("node")
857
+ }
858
+ ];
859
+ };
860
+
861
+ // src/configs/promise.ts
862
+ init_esm_shims();
863
+ import eslintPluginPromise from "eslint-plugin-promise";
864
+ var promiseEslintConfig = (options = {}, internalOptions = {}) => {
865
+ const rules = {
866
+ "promise/always-return": [ERROR, { ignoreLastCallback: true }],
867
+ // 'avoid-new': OFF,
868
+ "promise/catch-or-return": [
869
+ ERROR,
870
+ {
871
+ allowThen: true,
872
+ allowFinally: true
873
+ }
874
+ ],
875
+ "promise/no-callback-in-promise": ERROR,
876
+ // Default: warn
877
+ ...warnUnlessForcedError(internalOptions, "promise/no-multiple-resolved"),
878
+ // 'promise/no-native': OFF,
879
+ ...warnUnlessForcedError(internalOptions, "promise/no-nesting"),
880
+ // 'promise/no-new-statics': ERROR,
881
+ ...warnUnlessForcedError(internalOptions, "promise/no-promise-in-callback"),
882
+ "promise/no-return-in-finally": ERROR,
883
+ // Default: warn
884
+ "promise/no-return-wrap": [ERROR, { allowReject: true }],
885
+ // 'promise/param-names': ERROR,
886
+ // 'promise/prefer-await-to-callbacks': OFF,
887
+ // 'promise/prefer-await-to-then': OFF,
888
+ "promise/valid-params": ERROR
889
+ // Default: warn
890
+ };
891
+ return [
892
+ {
893
+ plugins: {
894
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
895
+ promise: eslintPluginPromise
896
+ },
897
+ ...options.files && { files: options.files },
898
+ ...options.ignores && { ignores: options.ignores },
899
+ rules: {
900
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
901
+ ...eslintPluginPromise.configs.recommended.rules,
902
+ ...rules,
903
+ ...options.overrides
904
+ },
905
+ name: genFlatConfigEntryName("promise")
906
+ }
907
+ ];
908
+ };
909
+
910
+ // src/configs/regexp.ts
911
+ init_esm_shims();
912
+ import * as eslintPluginRegexp from "eslint-plugin-regexp";
913
+ var overrideBaseRule = genRuleOverrideFn("regexp");
914
+ var regexpEslintConfig = (options = {}, internalOptions = {}) => {
915
+ const rules = {
916
+ // Possible Errors
917
+ // 'regexp/no-contradiction-with-assertion': ERROR,
918
+ // "This rule is inspired by the no-control-regex rule. The positions of reports are improved over the core rule and suggestions are provided in some cases"
919
+ "no-control-regex": OFF,
920
+ "regexp/no-control-character": ERROR,
921
+ // 'regexp/no-dupe-disjunctions': ERROR,
922
+ "regexp/no-empty-alternative": ERROR,
923
+ // Default: warn
924
+ // 'regexp/no-empty-capturing-group': ERROR,
925
+ // "The reports for this rule include reports for the ESLint core no-empty-character-class rule. That is, if you use this rule, you can turn off the ESLint core no-empty-character-class rule"
926
+ ...overrideBaseRule("no-empty-character-class", ERROR),
927
+ // 'regexp/no-empty-group': ERROR,
928
+ // 'regexp/no-empty-lookarounds-assertion': ERROR,
929
+ // 'regexp/no-escape-backspace': ERROR,
930
+ // 'regexp/no-invalid-regexp': ERROR,
931
+ "regexp/no-lazy-ends": ERROR,
932
+ // Default: warn
933
+ // 'regexp/no-misleading-capturing-group': ERROR,
934
+ // 'regexp/no-misleading-unicode-character': ERROR,
935
+ // 'regexp/no-missing-g-flag': ERROR,
936
+ // 'regexp/no-optional-assertion': ERROR,
937
+ ...warnUnlessForcedError(internalOptions, "regexp/no-potentially-useless-backreference"),
938
+ // 'regexp/no-super-linear-backtracking': ERROR,
939
+ // 'regexp/no-super-linear-move': OFF,
940
+ // 'regexp/no-useless-assertions': ERROR,
941
+ // "This rule is a based on the ESLint core no-useless-backreference rule. It reports all the ESLint core rule reports and some more"
942
+ ...overrideBaseRule("no-useless-backreference", ERROR),
943
+ // 'regexp/no-useless-dollar-replacements': ERROR,
944
+ // 'regexp/strict': ERROR,
945
+ // Best Practices
946
+ "regexp/confusing-quantifier": ERROR,
947
+ // Default: warn
948
+ // 'regexp/control-character-escape': ERROR,
949
+ // 'regexp/negation': ERROR,
950
+ // 'regexp/no-dupe-characters-character-class': ERROR,
951
+ // 'regexp/no-empty-string-literal': ERROR,
952
+ // 'regexp/no-extra-lookaround-assertions': ERROR,
953
+ // 'regexp/no-invisible-character': ERROR,
954
+ // 'regexp/no-legacy-features': ERROR,
955
+ // 'regexp/no-non-standard-flag': ERROR,
956
+ ...warnUnlessForcedError(internalOptions, "regexp/no-obscure-range"),
957
+ "regexp/no-octal": ERROR,
958
+ "regexp/no-standalone-backslash": ERROR,
959
+ // 'regexp/no-trivially-nested-assertion': ERROR,
960
+ // 'regexp/no-trivially-nested-quantifier': ERROR,
961
+ // 'regexp/no-unused-capturing-group': ERROR,
962
+ // 'regexp/no-useless-character-class': ERROR,
963
+ "regexp/no-useless-flag": ERROR,
964
+ // Default: warn
965
+ // 'regexp/no-useless-lazy': ERROR,
966
+ // 'regexp/no-useless-quantifier': ERROR,
967
+ // 'regexp/no-useless-range': ERROR,
968
+ // 'regexp/no-useless-set-operand': ERROR,
969
+ // 'regexp/no-useless-string-literal': ERROR,
970
+ // 'regexp/no-useless-two-nums-quantifier': ERROR,
971
+ // 'regexp/no-zero-quantifier': ERROR,
972
+ "regexp/optimal-lookaround-quantifier": ERROR,
973
+ // Default: warn
974
+ // 'regexp/optimal-quantifier-concatenation': ERROR,
975
+ // 'regexp/prefer-escape-replacement-dollar-char': OFF,
976
+ // 'regexp/prefer-predefined-assertion': ERROR,
977
+ "regexp/prefer-quantifier": ERROR,
978
+ // Default: off
979
+ // 'regexp/prefer-range': ERROR,
980
+ // Same (?) as `@typescript-eslint/prefer-regexp-exec` which is turned off by default
981
+ // 'regexp/prefer-regexp-exec': OFF,
982
+ "unicorn/prefer-regexp-test": OFF,
983
+ "regexp/prefer-regexp-test": ERROR,
984
+ // TODO better than the unicorn rule? Off by default
985
+ // 'regexp/prefer-set-operation': ERROR,
986
+ // "This rule is inspired by the require-unicode-regexp rule. The position of the report is improved over the core rule and arguments of new RegExp() are also checked"
987
+ // Yes, still off - we just want to show that it's a better replacement for the core rule
988
+ ...overrideBaseRule("require-unicode-regexp", OFF),
989
+ // 'regexp/require-unicode-sets-regexp': OFF,
990
+ // 'regexp/simplify-set-operations': ERROR,
991
+ // 'regexp/sort-alternatives': OFF,
992
+ // 'regexp/use-ignore-case': ERROR,
993
+ // Stylistic Issues
994
+ // 'regexp/grapheme-string-literal': OFF, // TODO
995
+ "regexp/hexadecimal-escape": [ERROR, "never"],
996
+ // 'regexp/letter-case': ERROR,
997
+ // 'regexp/match-any': ERROR,
998
+ // 'regexp/no-useless-escape': ERROR,
999
+ // 'regexp/no-useless-non-capturing-group': ERROR,
1000
+ // 'regexp/prefer-character-class': ERROR,
1001
+ // 'regexp/prefer-d': ERROR,
1002
+ "regexp/prefer-lookaround": [ERROR, { lookbehind: false }],
1003
+ // Default: off
1004
+ // 'regexp/prefer-named-backreference': OFF,
1005
+ // "This rule is inspired by the prefer-named-capture-group rule. The positions of reports are improved over the core rule and arguments of new RegExp() are also checked"
1006
+ // Yes, still off - we just want to show that it's a better replacement for the core rule
1007
+ ...overrideBaseRule("prefer-named-capture-group", OFF),
1008
+ // 'regexp/prefer-named-replacement': OFF,
1009
+ // 'regexp/prefer-plus-quantifier': ERROR,
1010
+ // 'regexp/prefer-question-quantifier': ERROR,
1011
+ // 'regexp/prefer-result-array-groups': OFF,
1012
+ // 'regexp/prefer-star-quantifier': ERROR,
1013
+ // 'regexp/prefer-unicode-codepoint-escapes': ERROR,
1014
+ // 'regexp/prefer-w': ERROR,
1015
+ "regexp/sort-character-class-elements": ERROR,
1016
+ // Default: off
1017
+ // 'regexp/sort-flags': ERROR,
1018
+ // 'regexp/unicode-escape': OFF,
1019
+ "regexp/unicode-property": ERROR
1020
+ // ...warnUnlessForcedError(internalOptions, 'regexp/'),
1021
+ };
1022
+ return [
1023
+ {
1024
+ ...options.files && { files: options.files },
1025
+ ...options.ignores && { ignores: options.ignores },
1026
+ plugins: {
1027
+ regexp: eslintPluginRegexp
1028
+ },
1029
+ rules: {
1030
+ ...eslintPluginRegexp.configs["flat/recommended"].rules,
1031
+ ...rules,
1032
+ ...options.overrides
1033
+ },
1034
+ name: genFlatConfigEntryName("regexp")
1035
+ }
1036
+ ];
1037
+ };
1038
+
1039
+ // src/configs/security.ts
1040
+ init_esm_shims();
1041
+ import eslintPluginSecurity from "eslint-plugin-security";
1042
+ var securityEslintConfig = (options = {}, internalOptions = {}) => {
1043
+ const rules = {
1044
+ "security/detect-bidi-characters": ERROR,
1045
+ "security/detect-buffer-noassert": ERROR,
1046
+ ...warnUnlessForcedError(internalOptions, "security/detect-child-process"),
1047
+ "security/detect-disable-mustache-escape": ERROR,
1048
+ "security/detect-eval-with-expression": ERROR,
1049
+ "security/detect-new-buffer": ERROR,
1050
+ ...warnUnlessForcedError(internalOptions, "security/detect-no-csrf-before-method-override"),
1051
+ "security/detect-non-literal-fs-filename": OFF,
1052
+ "security/detect-non-literal-regexp": OFF,
1053
+ "security/detect-non-literal-require": OFF,
1054
+ "security/detect-object-injection": OFF,
1055
+ "security/detect-possible-timing-attacks": OFF,
1056
+ ...warnUnlessForcedError(internalOptions, "security/detect-pseudoRandomBytes"),
1057
+ ...warnUnlessForcedError(internalOptions, "security/detect-unsafe-regex")
1058
+ };
1059
+ return [
1060
+ {
1061
+ ...options.files && { files: options.files },
1062
+ ...options.ignores && { ignores: options.ignores },
1063
+ plugins: {
1064
+ security: eslintPluginSecurity
1065
+ },
1066
+ rules: {
1067
+ ...eslintPluginSecurity.configs.recommended.rules,
1068
+ ...rules,
1069
+ ...options.overrides
1070
+ },
1071
+ name: genFlatConfigEntryName("security")
1072
+ }
1073
+ ];
1074
+ };
1075
+
1076
+ // src/configs/sonar.ts
1077
+ init_esm_shims();
1078
+ import eslingPluginSonar from "eslint-plugin-sonarjs";
1079
+ var sonarEslintConfig = (options = {}, internalOptions = {}) => {
1080
+ const rules = {
1081
+ // Bug Detection
1082
+ // 'sonarjs/no-all-duplicated-branches': ERROR,
1083
+ // 'sonarjs/no-element-overwrite': ERROR,
1084
+ // 'sonarjs/no-empty-collection': ERROR,
1085
+ // 'sonarjs/no-extra-arguments': ERROR,
1086
+ // 'sonarjs/no-identical-conditions': ERROR,
1087
+ // 'sonarjs/no-identical-expressions': ERROR,
1088
+ // 'sonarjs/no-ignored-return': ERROR,
1089
+ // 'sonarjs/no-one-iteration-loop': ERROR,
1090
+ // 'sonarjs/no-use-of-empty-return-value': ERROR,
1091
+ // 'sonarjs/non-existent-operator': ERROR,
1092
+ // Code Smell Detection
1093
+ // 'sonarjs/cognitive-complexity': OFF,
1094
+ // 'sonarjs/elseif-without-else': OFF,
1095
+ // 'sonarjs/max-switch-cases': OFF,
1096
+ // 'sonarjs/no-collapsible-if': ERROR,
1097
+ // 'sonarjs/no-collection-size-mischeck': ERROR, // TODO disable autofix?
1098
+ "sonarjs/no-duplicate-string": OFF,
1099
+ // 'sonarjs/no-duplicated-branches': ERROR,
1100
+ // 'sonarjs/no-gratuitous-expressions': ERROR,
1101
+ // 'sonarjs/no-identical-functions': ERROR,
1102
+ // 'sonarjs/no-inverted-boolean-check': ERROR,
1103
+ "sonarjs/no-nested-switch": OFF,
1104
+ "sonarjs/no-nested-template-literals": OFF,
1105
+ // 'sonarjs/no-redundant-boolean': ERROR,
1106
+ // 'sonarjs/no-redundant-jump': ERROR,
1107
+ // 'sonarjs/no-same-line-conditional': ERROR, // TODO disable autofix?
1108
+ // 'sonarjs/no-small-switch': ERROR,
1109
+ "sonarjs/no-unused-collection": OFF,
1110
+ // 'sonarjs/no-useless-catch': ERROR,
1111
+ "sonarjs/prefer-immediate-return": OFF
1112
+ // 'sonarjs/prefer-object-literal': ERROR,
1113
+ // 'sonarjs/prefer-single-boolean-return': ERROR,
1114
+ // 'sonarjs/prefer-while': ERROR,
1115
+ };
1116
+ return [
1117
+ {
1118
+ plugins: {
1119
+ sonarjs: eslingPluginSonar
1120
+ },
1121
+ ...options.files && { files: options.files },
1122
+ ...options.ignores && { ignores: options.ignores },
1123
+ rules: {
1124
+ ...eslingPluginSonar.configs.recommended.rules,
1125
+ ...rules,
1126
+ ...options.overrides
1127
+ },
1128
+ name: genFlatConfigEntryName("sonar")
1129
+ }
1130
+ ];
1131
+ };
1132
+
1133
+ // src/configs/tailwind.ts
1134
+ init_esm_shims();
1135
+ import eslingPluginTailwind from "eslint-plugin-tailwindcss";
1136
+ var tailwindEslintConfig = (options = {}, internalOptions = {}) => {
1137
+ const rules = {
1138
+ ...warnUnlessForcedError(internalOptions, "tailwindcss/classnames-order"),
1139
+ ...warnUnlessForcedError(internalOptions, "tailwindcss/enforces-negative-arbitrary-values"),
1140
+ ...warnUnlessForcedError(internalOptions, "tailwindcss/enforces-shorthand"),
1141
+ ...warnUnlessForcedError(internalOptions, "tailwindcss/migration-from-tailwind-2"),
1142
+ // 'tailwindcss/no-arbitrary-value': OFF,
1143
+ // 'tailwindcss/no-contradicting-classname': ERROR,
1144
+ "tailwindcss/no-custom-classname": OFF,
1145
+ ...warnUnlessForcedError(internalOptions, "tailwindcss/no-unnecessary-arbitrary-value")
1146
+ };
1147
+ return [
1148
+ {
1149
+ plugins: {
1150
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1151
+ tailwindcss: eslingPluginTailwind
1152
+ },
1153
+ ...options.files && { files: options.files },
1154
+ ...options.ignores && { ignores: options.ignores },
1155
+ rules: {
1156
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1157
+ ...eslingPluginTailwind.configs.recommended.rules,
1158
+ ...rules,
1159
+ ...options.overrides
1160
+ },
1161
+ name: genFlatConfigEntryName("tailwind")
1162
+ }
1163
+ ];
1164
+ };
1165
+
1166
+ // src/configs/ts.ts
1167
+ init_esm_shims();
1168
+ import eslintPluginNoTypeAssertion from "eslint-plugin-no-type-assertion";
1169
+ import { parser as parserTs, plugin as pluginTs } from "typescript-eslint";
1170
+ var overrideBaseRule2 = genRuleOverrideFn("@typescript-eslint");
1171
+ var tsEslintConfig = (options = {}, internalOptions = {}) => {
1172
+ const onlyTsFiles = [GLOB_TS, GLOB_TSX];
1173
+ const allExtraFiles = (options.extraFileExtensions || []).map((ext) => `**/*.${ext}`);
1174
+ const extraFiles = internalOptions.vueOptions?.enforceTypescriptInScriptSection ? allExtraFiles.filter((pattern) => pattern.endsWith(".vue")) : [];
1175
+ const filesNonTypeAware = options.files || [...onlyTsFiles, ...extraFiles];
1176
+ const filesTypeAware = options.filesTypeAware === true || options.filesTypeAware == null ? [...onlyTsFiles, ...extraFiles] : options.filesTypeAware || [];
1177
+ const filesAll = [...onlyTsFiles, ...filesTypeAware];
1178
+ const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
1179
+ const generateBaseOptions = (isTypeAware) => ({
1180
+ languageOptions: {
1181
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
1182
+ parser: parserTs,
1183
+ parserOptions: {
1184
+ extraFileExtensions: options.extraFileExtensions?.map((ext) => `.${ext}`),
1185
+ sourceType: "module",
1186
+ ...isTypeAware && {
1187
+ project: arraify(options.tsconfigPath),
1188
+ tsconfigRootDir: process.cwd()
1189
+ },
1190
+ ...options.parserOptions
1191
+ }
1192
+ }
1193
+ });
1194
+ const typescriptRulesRegular = {
1195
+ ...pluginTs.configs?.strict?.rules,
1196
+ ...pluginTs.configs?.stylistic?.rules,
1197
+ // 🔵 Strict - overrides
1198
+ // '@typescript-eslint/ban-ts-comment': ERROR,
1199
+ "@typescript-eslint/ban-types": [ERROR, { types: { object: false, "{}": false } }],
1200
+ ...overrideBaseRule2("no-array-constructor", ERROR),
1201
+ // '@typescript-eslint/no-duplicate-enum-values': ERROR,
1202
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-dynamic-delete"),
1203
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-explicit-any", {
1204
+ ignoreRestArgs: true
1205
+ }),
1206
+ // '@typescript-eslint/no-extra-non-null-assertion': ERROR,
1207
+ // '@typescript-eslint/no-extraneous-class': ERROR,
1208
+ // '@typescript-eslint/no-invalid-void-type': ERROR,
1209
+ ...overrideBaseRule2("no-loss-of-precision", ERROR),
1210
+ // '@typescript-eslint/no-misused-new': ERROR,
1211
+ // '@typescript-eslint/no-namespace': ERROR,
1212
+ // '@typescript-eslint/no-non-null-asserted-nullish-coalescing': ERROR,
1213
+ // '@typescript-eslint/no-non-null-asserted-optional-chain': ERROR,
1214
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-non-null-assertion"),
1215
+ // '@typescript-eslint/no-this-alias': ERROR,
1216
+ // '@typescript-eslint/no-unnecessary-type-constraint': ERROR,
1217
+ // '@typescript-eslint/no-unsafe-declaration-merging': ERROR,
1218
+ ...overrideBaseRule2("no-unused-vars", ERROR, { ignoreRestSiblings: true }),
1219
+ ...overrideBaseRule2("no-useless-constructor", ERROR),
1220
+ // '@typescript-eslint/no-var-requires': ERROR,
1221
+ // '@typescript-eslint/prefer-as-const': ERROR,
1222
+ "@typescript-eslint/prefer-literal-enum-member": [ERROR, { allowBitwiseExpressions: true }],
1223
+ // '@typescript-eslint/triple-slash-reference': ERROR,
1224
+ // '@typescript-eslint/unified-signatures': ERROR,
1225
+ // 🔵 Stylistic - overrides
1226
+ // '@typescript-eslint/adjacent-overload-signatures': ERROR,
1227
+ // '@typescript-eslint/array-type': ERROR,
1228
+ // '@typescript-eslint/ban-tslint-comment': ERROR,
1229
+ // '@typescript-eslint/class-literal-property-style': ERROR,
1230
+ // '@typescript-eslint/consistent-generic-constructors': ERROR,
1231
+ // '@typescript-eslint/consistent-indexed-object-style': ERROR,
1232
+ // '@typescript-eslint/consistent-type-assertions': ERROR,
1233
+ // '@typescript-eslint/consistent-type-definitions': ERROR,
1234
+ // '@typescript-eslint/no-confusing-non-null-assertion': ERROR,
1235
+ ...overrideBaseRule2("no-empty-function", ERROR),
1236
+ "@typescript-eslint/no-empty-interface": [ERROR, { allowSingleExtends: true }],
1237
+ // '@typescript-eslint/no-inferrable-types': ERROR,
1238
+ // '@typescript-eslint/prefer-for-of': ERROR,
1239
+ // '@typescript-eslint/prefer-function-type': ERROR,
1240
+ // '@typescript-eslint/prefer-namespace-keyword': ERROR,
1241
+ // 🔵 Additional rules
1242
+ ...overrideBaseRule2("class-methods-use-this", ERROR, {
1243
+ ignoreOverrideMethods: true,
1244
+ ignoreClassesThatImplementAnInterface: true
1245
+ }),
1246
+ "@typescript-eslint/consistent-type-imports": [
1247
+ ERROR,
1248
+ {
1249
+ ...tsVersion && tsVersion >= 4.5 && { fixStyle: "inline-type-imports" },
1250
+ disallowTypeAnnotations: false
1251
+ }
1252
+ ],
1253
+ ...overrideBaseRule2("default-param-last", ERROR),
1254
+ // '@typescript-eslint/explicit-function-return-type': OFF,
1255
+ // '@typescript-eslint/explicit-member-accessibility': OFF,
1256
+ "@typescript-eslint/explicit-module-boundary-types": OFF,
1257
+ // ...overrideBaseRule('init-declarations', OFF),
1258
+ // ...overrideBaseRule('max-params', OFF),
1259
+ // '@typescript-eslint/member-ordering': OFF, // ❄️
1260
+ "@typescript-eslint/method-signature-style": ERROR,
1261
+ // ...overrideBaseRule('no-dupe-class-members', OFF), // 👍
1262
+ "@typescript-eslint/no-empty-object-type": [
1263
+ ERROR,
1264
+ {
1265
+ allowInterfaces: "with-single-extends",
1266
+ allowObjectTypes: "always"
1267
+ }
1268
+ ],
1269
+ "@typescript-eslint/no-import-type-side-effects": ERROR,
1270
+ // ...overrideBaseRule('no-invalid-this', OFF), // 👍
1271
+ ...overrideBaseRule2("no-loop-func", ERROR),
1272
+ // ...overrideBaseRule('no-magic-numbers', OFF),
1273
+ "no-redeclare": OFF,
1274
+ // '@typescript-eslint/no-redeclare': OFF, // 👍
1275
+ // '@typescript-eslint/no-require-imports': OFF,
1276
+ // ...overrideBaseRule('no-restricted-imports', OFF),
1277
+ ...overrideBaseRule2("no-shadow", ERROR),
1278
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": ERROR,
1279
+ ...overrideBaseRule2("no-unused-expressions", ERROR, RULE_NO_UNUSED_EXPRESSIONS_OPTIONS),
1280
+ ...overrideBaseRule2("no-use-before-define", ERROR, RULE_NO_USE_BEFORE_DEFINE_OPTIONS),
1281
+ "@typescript-eslint/no-useless-empty-export": ERROR,
1282
+ // '@typescript-eslint/parameter-properties': OFF,
1283
+ // '@typescript-eslint/prefer-enum-initializers': OFF,
1284
+ // '@typescript-eslint/typedef': OFF,
1285
+ // 🔵 Disable conflicting rules
1286
+ "no-useless-constructor": OFF,
1287
+ "dot-notation": OFF,
1288
+ ...options.overrides
1289
+ };
1290
+ const typescriptRulesTypeAware = {
1291
+ ...pluginTs.configs?.["strict-type-checked-only"]?.rules,
1292
+ ...pluginTs.configs?.["stylistic-type-checked-only"]?.rules,
1293
+ // 🔵 Strict - overrides
1294
+ // '@typescript-eslint/await-thenable': ERROR,
1295
+ // '@typescript-eslint/no-array-delete': ERROR,
1296
+ // '@typescript-eslint/no-base-to-string': ERROR,
1297
+ "@typescript-eslint/no-confusing-void-expression": [
1298
+ ERROR,
1299
+ {
1300
+ ignoreArrowShorthand: true
1301
+ }
1302
+ ],
1303
+ // '@typescript-eslint/no-duplicate-type-constituents': ERROR,
1304
+ "@typescript-eslint/no-floating-promises": [
1305
+ ERROR,
1306
+ {
1307
+ checkThenables: true,
1308
+ ignoreVoid: true
1309
+ // Default
1310
+ }
1311
+ ],
1312
+ // '@typescript-eslint/no-for-in-array': ERROR,
1313
+ ...overrideBaseRule2("no-implied-eval", ERROR),
1314
+ // '@typescript-eslint/no-meaningless-void-operator': ERROR,
1315
+ // '@typescript-eslint/no-misused-promises': ERROR,
1316
+ // '@typescript-eslint/no-mixed-enums': ERROR,
1317
+ // '@typescript-eslint/no-redundant-type-constituents': ERROR,
1318
+ // '@typescript-eslint/no-unnecessary-boolean-literal-compare': ERROR,
1319
+ ...disableAutofixForRule("@typescript-eslint/no-unnecessary-condition", ERROR, {
1320
+ allowConstantLoopConditions: true
1321
+ }),
1322
+ // '@typescript-eslint/no-unnecessary-template-expression': ERROR,
1323
+ // Reason for disabling autofix: could remove type aliases
1324
+ ...disableAutofixForRule("@typescript-eslint/no-unnecessary-type-arguments", ERROR),
1325
+ // '@typescript-eslint/no-unnecessary-type-assertion': ERROR,
1326
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-argument"),
1327
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-assignment"),
1328
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-call"),
1329
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-enum-comparison"),
1330
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-member-access"),
1331
+ ...warnUnlessForcedError(internalOptions, "@typescript-eslint/no-unsafe-return"),
1332
+ "no-throw-literal": OFF,
1333
+ // Note: has different name
1334
+ "@typescript-eslint/only-throw-error": [
1335
+ ERROR,
1336
+ {
1337
+ allowThrowingUnknown: true
1338
+ }
1339
+ ],
1340
+ "unicorn/prefer-includes": OFF,
1341
+ // Note: in Unicorn
1342
+ "@typescript-eslint/prefer-includes": ERROR,
1343
+ ...overrideBaseRule2("prefer-promise-reject-errors", ERROR),
1344
+ // '@typescript-eslint/prefer-reduce-type-parameter': ERROR,
1345
+ // '@typescript-eslint/prefer-return-this-type': ERROR,
1346
+ ...overrideBaseRule2("require-await", ERROR),
1347
+ // '@typescript-eslint/restrict-plus-operands': ERROR,
1348
+ "@typescript-eslint/restrict-template-expressions": [
1349
+ ERROR,
1350
+ { allowAny: false, allowRegExp: false }
1351
+ ],
1352
+ // '@typescript-eslint/unbound-method': ERROR,
1353
+ // '@typescript-eslint/use-unknown-in-catch-callback-variable': ERROR,
1354
+ // 🔵 Stylistic - overrides
1355
+ ...overrideBaseRule2("dot-notation", ERROR, {
1356
+ allowIndexSignaturePropertyAccess: true
1357
+ }),
1358
+ // '@typescript-eslint/non-nullable-type-assertion-style': ERROR,
1359
+ "@typescript-eslint/prefer-nullish-coalescing": OFF,
1360
+ // '@typescript-eslint/prefer-optional-chain': ERROR,
1361
+ "@typescript-eslint/prefer-string-starts-ends-with": [
1362
+ ERROR,
1363
+ {
1364
+ allowSingleElementEquality: "always"
1365
+ }
1366
+ ],
1367
+ // 🔵 Additional rules
1368
+ // ...overrideBaseRule('consistent-return', OFF),
1369
+ "@typescript-eslint/consistent-type-exports": [
1370
+ ERROR,
1371
+ { fixMixedExportsWithInlineTypeSpecifier: true }
1372
+ ],
1373
+ // '@typescript-eslint/naming-convention': OFF, // ❄️
1374
+ // '@typescript-eslint/no-unnecessary-qualifier': OFF,
1375
+ "@typescript-eslint/no-unsafe-unary-minus": ERROR,
1376
+ ...overrideBaseRule2("prefer-destructuring", ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS),
1377
+ "unicorn/prefer-array-find": OFF,
1378
+ // Note: in Unicorn
1379
+ "@typescript-eslint/prefer-find": ERROR,
1380
+ "@typescript-eslint/prefer-readonly": ERROR,
1381
+ // '@typescript-eslint/prefer-readonly-parameter-types': OFF,
1382
+ // '@typescript-eslint/prefer-regexp-exec': OFF,
1383
+ // '@typescript-eslint/promise-function-async': OFF,
1384
+ // '@typescript-eslint/require-array-sort-compare': OFF,
1385
+ // Note: has different name. Also note that the original rule is deprecated and not included in this config, but we disable it anyway just for safety
1386
+ "no-return-await": OFF,
1387
+ "@typescript-eslint/return-await": [ERROR, "always"],
1388
+ // '@typescript-eslint/strict-boolean-expressions': OFF,
1389
+ "@typescript-eslint/switch-exhaustiveness-check": ERROR,
1390
+ ...options.overridesTypeAware
1391
+ };
1392
+ return [
1393
+ {
1394
+ plugins: {
1395
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
1396
+ "@typescript-eslint": pluginTs
1397
+ },
1398
+ name: genFlatConfigEntryName("ts/setup")
1399
+ },
1400
+ {
1401
+ ...generateBaseOptions(false),
1402
+ files: filesNonTypeAware,
1403
+ ...options.ignores && { ignores: options.ignores },
1404
+ rules: typescriptRulesRegular,
1405
+ name: genFlatConfigEntryName("ts/regular-rules")
1406
+ },
1407
+ filesTypeAware.length > 0 && {
1408
+ ...generateBaseOptions(true),
1409
+ files: filesTypeAware,
1410
+ ...options.ignoresTypeAware && {
1411
+ ignores: options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware
1412
+ },
1413
+ rules: typescriptRulesTypeAware,
1414
+ name: genFlatConfigEntryName("ts/type-aware-rules")
1415
+ },
1416
+ // Handled by TS compiler
1417
+ {
1418
+ files: filesAll,
1419
+ rules: {
1420
+ "constructor-super": OFF,
1421
+ "getter-return": OFF,
1422
+ "no-const-assign": OFF,
1423
+ "no-dupe-args": OFF,
1424
+ "no-dupe-class-members": OFF,
1425
+ "no-dupe-keys": OFF,
1426
+ "no-func-assign": OFF,
1427
+ // "Note that the compiler will not catch the Object.assign() case. Thus, if you use Object.assign() in your codebase, this rule will still provide some value." - https://eslint.org/docs/latest/rules/no-import-assign#handled_by_typescript
1428
+ // 'no-import-assign': OFF,
1429
+ // "Note that, technically, TypeScript will only catch this if you have the strict or noImplicitThis flags enabled. These are enabled in most TypeScript projects, since they are considered to be best practice." - https://eslint.org/docs/latest/rules/no-invalid-this#rule-details
1430
+ // 'no-invalid-this': OFF,
1431
+ "no-new-native-nonconstructor": OFF,
1432
+ // successor of no-new-symbol
1433
+ "no-obj-calls": OFF,
1434
+ // "Note that while TypeScript will catch let redeclares and const redeclares, it will not catch var redeclares. Thus, if you use the legacy var keyword in your TypeScript codebase, this rule will still provide some value." - https://eslint.org/docs/latest/rules/no-redeclare#handled_by_typescript
1435
+ // 'no-redeclare': OFF,
1436
+ "no-setter-return": OFF,
1437
+ "no-this-before-super": OFF,
1438
+ "no-undef": OFF,
1439
+ // "TypeScript must be configured with allowUnreachableCode: false for it to consider unreachable code an error." - https://eslint.org/docs/latest/rules/no-unreachable#handled_by_typescript
1440
+ // 'no-unreachable': OFF,
1441
+ "no-unsafe-negation": OFF,
1442
+ // Does not work correctly when type-only imports are present because you can't combine such an import with a default import.
1443
+ "no-duplicate-imports": OFF
1444
+ },
1445
+ name: genFlatConfigEntryName("ts/disable-handled-by-ts-compiler-rules")
1446
+ },
1447
+ {
1448
+ files: ["**/*.d.?([cm])ts"],
1449
+ rules: {
1450
+ "@typescript-eslint/consistent-indexed-object-style": OFF,
1451
+ "@typescript-eslint/no-explicit-any": OFF,
1452
+ "@typescript-eslint/no-use-before-define": OFF,
1453
+ "@typescript-eslint/no-unused-vars": OFF,
1454
+ "@typescript-eslint/no-shadow": OFF,
1455
+ "@typescript-eslint/method-signature-style": OFF,
1456
+ "import/no-default-export": OFF,
1457
+ "import/newline-after-import": OFF
1458
+ },
1459
+ name: genFlatConfigEntryName("ts/dts")
1460
+ },
1461
+ options.noTypeAssertion && {
1462
+ plugins: {
1463
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1464
+ "no-type-assertion": eslintPluginNoTypeAssertion
1465
+ },
1466
+ rules: {
1467
+ "no-type-assertion/no-type-assertion": options.noTypeAssertion === "warning" ? WARNING : ERROR
1468
+ },
1469
+ name: genFlatConfigEntryName("ts/no-type-assertion")
1470
+ }
1471
+ ].flat().filter((v) => !!v);
1472
+ };
1473
+
1474
+ // src/configs/unicorn.ts
1475
+ init_esm_shims();
1476
+ import eslintPluginUnicorn from "eslint-plugin-unicorn";
1477
+ var unicornEslintConfig = (options = {}, internalOptions = {}) => {
1478
+ const rules = {
1479
+ // 'unicorn/better-regex': ERROR,
1480
+ "unicorn/catch-error-name": OFF,
1481
+ ...warnUnlessForcedError(internalOptions, "disable-autofix/unicorn/catch-error-name"),
1482
+ // 'unicorn/catch-error-name': ERROR, // TODO warning & disable autofix?
1483
+ // 'unicorn/consistent-destructuring': OFF, // 🔴
1484
+ // 'unicorn/consistent-empty-array-spread': ERROR,
1485
+ // 'unicorn/consistent-function-scoping': ERROR,
1486
+ "unicorn/custom-error-definition": ERROR,
1487
+ // 🔴
1488
+ // 'unicorn/empty-brace-spaces': ERROR, // 💅
1489
+ // 'unicorn/error-message': ERROR,
1490
+ // 'unicorn/escape-case': ERROR,
1491
+ // 'unicorn/expiring-todo-comments': ERROR,
1492
+ // Reason for disabling autofix: wrong auto-fixes
1493
+ ...disableAutofixForRule("unicorn/explicit-length-check", ERROR),
1494
+ "unicorn/filename-case": OFF,
1495
+ // 'unicorn/import-style': ERROR,
1496
+ // 'unicorn/new-for-builtins': ERROR,
1497
+ // 'unicorn/no-abusive-eslint-disable': ERROR,
1498
+ "unicorn/no-anonymous-default-export": OFF,
1499
+ // Note: there's the same rule in import plugin
1500
+ "unicorn/no-array-callback-reference": OFF,
1501
+ "unicorn/no-array-for-each": OFF,
1502
+ // 'unicorn/no-array-method-this-argument': ERROR,
1503
+ // 'unicorn/no-array-push-push': ERROR,
1504
+ "unicorn/no-array-reduce": OFF,
1505
+ "unicorn/no-await-expression-member": OFF,
1506
+ // 'unicorn/no-await-in-promise-methods': ERROR,
1507
+ // 'unicorn/no-console-spaces': ERROR,
1508
+ // 'unicorn/no-document-cookie': ERROR,
1509
+ // 'unicorn/no-empty-file': ERROR,
1510
+ "unicorn/no-for-loop": OFF,
1511
+ // 'unicorn/no-hex-escape': ERROR,
1512
+ // 'unicorn/no-instanceof-array': ERROR,
1513
+ // 'unicorn/no-invalid-fetch-options': ERROR,
1514
+ // 'unicorn/no-invalid-remove-event-listener': ERROR,
1515
+ // 'unicorn/no-keyword-prefix': OFF, // 🔴
1516
+ // 'unicorn/no-lonely-if': ERROR,
1517
+ // 'unicorn/no-magic-array-flat-depth': ERROR,
1518
+ // "This is an improved version of the no-negated-condition ESLint rule that makes it automatically fixable" - Unicorn docs
1519
+ // 'no-negated-condition': OFF,
1520
+ // 'unicorn/no-negated-condition': ERROR,
1521
+ // 'unicorn/no-negation-in-equality-check': ERROR,
1522
+ "unicorn/no-nested-ternary": OFF,
1523
+ // 'unicorn/no-new-array': ERROR,
1524
+ // 'unicorn/no-new-buffer': ERROR,
1525
+ "unicorn/no-null": OFF,
1526
+ // 'unicorn/no-object-as-default-parameter': ERROR,
1527
+ "unicorn/no-process-exit": OFF,
1528
+ // Used in `node` config
1529
+ // 'unicorn/no-single-promise-in-promise-methods': ERROR,
1530
+ // 'unicorn/no-static-only-class': ERROR,
1531
+ // 'unicorn/no-thenable': ERROR,
1532
+ // 'unicorn/no-this-assignment': ERROR,
1533
+ // 'unicorn/no-typeof-undefined': ERROR,
1534
+ // 'unicorn/no-unnecessary-await': ERROR,
1535
+ // 'unicorn/no-unnecessary-polyfills': ERROR,
1536
+ "unicorn/no-unreadable-array-destructuring": OFF,
1537
+ // 'unicorn/no-unreadable-iife': ERROR,
1538
+ // 'unicorn/no-unused-properties': OFF, // 🔴
1539
+ // 'unicorn/no-useless-fallback-in-spread': ERROR,
1540
+ // 'unicorn/no-useless-length-check': ERROR,
1541
+ // 'unicorn/no-useless-promise-resolve-reject': ERROR,
1542
+ // 'unicorn/no-useless-spread': ERROR,
1543
+ // 'unicorn/no-useless-switch-case': ERROR,
1544
+ // TODO reason for disabling autofix
1545
+ ...disableAutofixForRule("unicorn/no-useless-undefined", ERROR, {
1546
+ checkArguments: false
1547
+ }),
1548
+ // 'unicorn/no-zero-fractions': ERROR,
1549
+ // 'unicorn/number-literal-case': ERROR,
1550
+ "unicorn/numeric-separators-style": [
1551
+ ERROR,
1552
+ {
1553
+ onlyIfContainsSeparator: true
1554
+ }
1555
+ ],
1556
+ // 'unicorn/prefer-add-event-listener': ERROR,
1557
+ // 'unicorn/prefer-array-find': ERROR,
1558
+ // 'unicorn/prefer-array-flat-map': ERROR,
1559
+ // 'unicorn/prefer-array-flat': ERROR,
1560
+ // 'unicorn/prefer-array-index-of': ERROR,
1561
+ // 'unicorn/prefer-array-some': ERROR,
1562
+ // 'unicorn/prefer-at': ERROR,
1563
+ // 'unicorn/prefer-blob-reading-methods': ERROR,
1564
+ // 'unicorn/prefer-code-point': ERROR,
1565
+ // 'unicorn/prefer-date-now': ERROR,
1566
+ // 'unicorn/prefer-default-parameters': ERROR,
1567
+ // 'unicorn/prefer-dom-node-append': ERROR,
1568
+ // 'unicorn/prefer-dom-node-dataset': ERROR,
1569
+ // 'unicorn/prefer-dom-node-remove': ERROR,
1570
+ "unicorn/prefer-dom-node-text-content": OFF,
1571
+ // 'unicorn/prefer-event-target': ERROR,
1572
+ "unicorn/prefer-export-from": [ERROR, { ignoreUsedVariables: true }],
1573
+ // 'unicorn/prefer-includes': ERROR,
1574
+ // 'unicorn/prefer-json-parse-buffer': ERROR,
1575
+ // 'unicorn/prefer-keyboard-event-key': ERROR,
1576
+ // 'unicorn/prefer-logical-operator-over-ternary': ERROR,
1577
+ // 'unicorn/prefer-math-trunc': ERROR,
1578
+ // 'unicorn/prefer-modern-dom-apis': ERROR,
1579
+ // 'unicorn/prefer-modern-math-apis': ERROR,
1580
+ "unicorn/prefer-module": OFF,
1581
+ // 'unicorn/prefer-native-coercion-functions': ERROR,
1582
+ // 'unicorn/prefer-negative-index': ERROR,
1583
+ "unicorn/prefer-node-protocol": OFF,
1584
+ // `n/prefer-node-protocol` seem to be better as it checks supported node versions
1585
+ // 'unicorn/prefer-number-properties': ERROR,
1586
+ // 'unicorn/prefer-object-from-entries': ERROR,
1587
+ // 'unicorn/prefer-optional-catch-binding': ERROR,
1588
+ // 'unicorn/prefer-prototype-methods': ERROR,
1589
+ "unicorn/prefer-query-selector": OFF,
1590
+ // 'unicorn/prefer-reflect-apply': ERROR,
1591
+ // 'unicorn/prefer-regexp-test': ERROR,
1592
+ // 'unicorn/prefer-set-has': ERROR,
1593
+ // 'unicorn/prefer-set-size': ERROR,
1594
+ ...disableAutofixForRule("unicorn/prefer-spread", ERROR),
1595
+ // 'unicorn/prefer-string-raw': ERROR,
1596
+ // 'unicorn/prefer-string-replace-all': ERROR,
1597
+ // 'unicorn/prefer-string-slice': ERROR,
1598
+ // 'unicorn/prefer-string-starts-ends-with': ERROR,
1599
+ // 'unicorn/prefer-string-trim-start-end': ERROR,
1600
+ // 'unicorn/prefer-structured-clone': ERROR,
1601
+ "unicorn/prefer-switch": [
1602
+ ERROR,
1603
+ {
1604
+ minimumCases: 4,
1605
+ emptyDefaultCase: "do-nothing-comment"
1606
+ }
1607
+ ],
1608
+ // 'unicorn/prefer-ternary': ERROR,
1609
+ // 'unicorn/prefer-top-level-await': ERROR,
1610
+ // 'unicorn/prefer-type-error': ERROR,
1611
+ "unicorn/prevent-abbreviations": OFF,
1612
+ "unicorn/relative-url-style": [ERROR, "always"]
1613
+ // 'unicorn/require-array-join-separator': ERROR,
1614
+ // 'unicorn/require-number-to-fixed-digits-argument': ERROR,
1615
+ // 'unicorn/require-post-message-target-origin': OFF, // 🔴
1616
+ // 'unicorn/string-content': OFF, // 🔴
1617
+ // 'unicorn/switch-case-braces': ERROR,
1618
+ // 'unicorn/template-indent': ERROR,
1619
+ // 'unicorn/text-encoding-identifier-case': ERROR,
1620
+ // 'unicorn/throw-new-error': ERROR,
1621
+ };
1622
+ return [
1623
+ {
1624
+ ...options.files && { files: options.files },
1625
+ ...options.ignores && { ignores: options.ignores },
1626
+ rules: {
1627
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1628
+ ...eslintPluginUnicorn.configs["flat/recommended"].rules,
1629
+ ...rules,
1630
+ ...options.overrides
1631
+ },
1632
+ name: genFlatConfigEntryName("unicorn")
1633
+ }
1634
+ ];
1635
+ };
1636
+
1637
+ // src/configs/vue.ts
1638
+ init_esm_shims();
1639
+ import eslintPluginPinia from "eslint-plugin-pinia";
1640
+ import eslintPluginVue from "eslint-plugin-vue";
1641
+ import eslintPluginVueA11y from "eslint-plugin-vuejs-accessibility";
1642
+ import globals from "globals";
1643
+ import parserVue from "vue-eslint-parser";
1644
+ var DEPRECATED_HTML_TAGS = [
1645
+ "acronym",
1646
+ "big",
1647
+ "center",
1648
+ "content",
1649
+ "dir",
1650
+ "font",
1651
+ "frame",
1652
+ "frameset",
1653
+ "image",
1654
+ "marquee",
1655
+ "menuitem",
1656
+ "nobr",
1657
+ "noembed",
1658
+ "noframes",
1659
+ "param",
1660
+ "plaintext",
1661
+ "rb",
1662
+ "rtc",
1663
+ "shadow",
1664
+ "strike",
1665
+ "tt",
1666
+ "xmp"
1667
+ ];
1668
+ var vueEslintConfig = (options, internalOptions = {}) => {
1669
+ const { majorVersion, enforceTypescriptInScriptSection, a11y = true } = options;
1670
+ const files = options.files || [GLOB_VUE];
1671
+ const vueMajorAndMinorVersion = Number.parseFloat(options.fullVersion || "");
1672
+ const isVue2 = majorVersion === 2;
1673
+ const isVue3 = majorVersion === 3;
1674
+ const isMin3_3 = isVue3 && vueMajorAndMinorVersion >= 3.3;
1675
+ const isMin3_4 = isVue3 && vueMajorAndMinorVersion >= 3.4;
1676
+ const isLess2_5 = isVue2 && vueMajorAndMinorVersion < 2.5;
1677
+ const isLess2_6 = isVue2 && vueMajorAndMinorVersion < 2.6;
1678
+ const isLess3_1 = vueMajorAndMinorVersion < 3.1;
1679
+ const recommendedRules = (
1680
+ // TODO report to Prettier?
1681
+ // prettier-ignore
1682
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1683
+ eslintPluginVue.configs[isVue3 ? "flat/recommended" : "flat/vue2-recommended"].find(
1684
+ (entry) => entry.name === "vue:recommended:rules" || entry.name === "vue:vue2-recommended:rules"
1685
+ )?.rules
1686
+ );
1687
+ const rules = {
1688
+ // 🔵 Disable deprecated rules from Recommended
1689
+ "vue/component-tags-order": OFF,
1690
+ // 🔵 Base
1691
+ "vue/comment-directive": [
1692
+ ERROR,
1693
+ { reportUnusedDisableDirectives: true }
1694
+ // false by default
1695
+ ],
1696
+ // 'vue/jsx-uses-vars': ERROR,
1697
+ // 🔵 Priority A: Essential
1698
+ // 'vue/multi-word-component-names': ERROR,
1699
+ // 'vue/no-arrow-functions-in-watch': ERROR,
1700
+ // 'vue/no-async-in-computed-properties': ERROR,
1701
+ // 'vue/no-child-content': ERROR,
1702
+ // 'vue/no-computed-properties-in-data': ERROR,
1703
+ // 'vue/no-deprecated-data-object-declaration': ERROR, // 3️⃣
1704
+ // 'vue/no-deprecated-destroyed-lifecycle': ERROR, // 3️⃣
1705
+ // 'vue/no-deprecated-dollar-listeners-api': ERROR, // 3️⃣
1706
+ // 'vue/no-deprecated-dollar-scopedslots-api': ERROR, // 3️⃣
1707
+ // 'vue/no-deprecated-events-api': ERROR, // 3️⃣
1708
+ // 'vue/no-deprecated-filter': ERROR, // 3️⃣
1709
+ // 'vue/no-deprecated-functional-template': ERROR, // 3️⃣
1710
+ // 'vue/no-deprecated-html-element-is': ERROR, // 3️⃣
1711
+ // 'vue/no-deprecated-inline-template': ERROR, // 3️⃣
1712
+ // 'vue/no-deprecated-props-default-this': ERROR, // 3️⃣
1713
+ // 'vue/no-deprecated-router-link-tag-prop': ERROR, // 3️⃣
1714
+ "vue/no-deprecated-scope-attribute": isLess2_5 ? OFF : ERROR,
1715
+ // 3️⃣ deprecated in 2.5.0
1716
+ "vue/no-deprecated-slot-attribute": isLess2_6 ? OFF : ERROR,
1717
+ // 3️⃣ deprecated in 2.6.0
1718
+ "vue/no-deprecated-slot-scope-attribute": isLess2_6 ? OFF : ERROR,
1719
+ // 3️⃣ deprecated in 2.6.0
1720
+ // 'vue/no-deprecated-v-bind-sync': ERROR, // 3️⃣
1721
+ "vue/no-deprecated-v-is": isLess3_1 ? OFF : ERROR,
1722
+ // 3️⃣ deprecated in 3.1.0
1723
+ // 'vue/no-deprecated-v-on-native-modifier': ERROR, // 3️⃣
1724
+ // 'vue/no-deprecated-v-on-number-modifiers': ERROR, // 3️⃣
1725
+ // 'vue/no-deprecated-vue-config-keycodes': ERROR, // 3️⃣
1726
+ // 'vue/no-dupe-keys': ERROR,
1727
+ // 'vue/no-dupe-v-else-if': ERROR,
1728
+ // 'vue/no-duplicate-attributes': ERROR,
1729
+ // 'vue/no-export-in-script-setup': ERROR,
1730
+ // 'vue/no-expose-after-await': ERROR, // 3️⃣
1731
+ // 'vue/no-lifecycle-after-await': ERROR, // 3️⃣
1732
+ // 'vue/no-mutating-props': ERROR,
1733
+ // 'vue/no-parsing-error': ERROR,
1734
+ // 'vue/no-ref-as-operand': ERROR,
1735
+ // 'vue/no-reserved-component-names': ERROR,
1736
+ // 'vue/no-reserved-keys': ERROR,
1737
+ // 'vue/no-reserved-props': ERROR,
1738
+ // 'vue/no-shared-component-data': ERROR,
1739
+ // 'vue/no-side-effects-in-computed-properties': ERROR,
1740
+ // 'vue/no-template-key': ERROR,
1741
+ // 'vue/no-textarea-mustache': ERROR,
1742
+ // 'vue/no-unused-components': ERROR,
1743
+ // 'vue/no-unused-vars': ERROR,
1744
+ // 'vue/no-use-computed-property-like-method': ERROR,
1745
+ // 'vue/no-use-v-if-with-v-for': ERROR,
1746
+ // 'vue/no-useless-template-attributes': ERROR,
1747
+ // 'vue/no-v-for-template-key-on-child': ERROR, // 3️⃣
1748
+ // 'vue/no-v-text-v-html-on-component': ERROR,
1749
+ // 'vue/no-watch-after-await': ERROR, // 3️⃣
1750
+ // 'vue/prefer-import-from-vue': ERROR, // 3️⃣
1751
+ // 'vue/require-component-is': ERROR,
1752
+ // 'vue/require-prop-type-constructor': ERROR,
1753
+ // 'vue/require-render-return': ERROR,
1754
+ // 'vue/require-slots-as-functions': ERROR, // 3️⃣
1755
+ // 'vue/require-toggle-inside-transition': ERROR, // 3️⃣
1756
+ // 'vue/require-v-for-key': ERROR,
1757
+ // 'vue/require-valid-default-prop': ERROR,
1758
+ // 'vue/return-in-computed-property': ERROR,
1759
+ // 'vue/return-in-emits-validator': ERROR,
1760
+ // 'vue/use-v-on-exact': ERROR,
1761
+ // 'vue/valid-attribute-name': ERROR,
1762
+ // 'vue/valid-define-emits': ERROR,
1763
+ // 'vue/valid-define-props': ERROR,
1764
+ // 'vue/valid-next-tick': ERROR,
1765
+ // 'vue/valid-template-root': ERROR,
1766
+ // 'vue/valid-v-bind': ERROR,
1767
+ // 'vue/valid-v-cloak': ERROR,
1768
+ // 'vue/valid-v-else-if': ERROR,
1769
+ // 'vue/valid-v-else': ERROR,
1770
+ // 'vue/valid-v-for': ERROR,
1771
+ // 'vue/valid-v-html': ERROR,
1772
+ // 'vue/valid-v-if': ERROR,
1773
+ // 'vue/valid-v-is': ERROR, // 3️⃣
1774
+ // 'vue/valid-v-memo': ERROR, // 3️⃣
1775
+ // 'vue/valid-v-model': ERROR,
1776
+ // 'vue/valid-v-on': ERROR,
1777
+ // 'vue/valid-v-once': ERROR,
1778
+ // 'vue/valid-v-pre': ERROR,
1779
+ // 'vue/valid-v-show': ERROR,
1780
+ // 'vue/valid-v-slot': ERROR,
1781
+ // 'vue/valid-v-text': ERROR,
1782
+ // 🔵 Priority B: Strongly Recommended
1783
+ // 'vue/attribute-hyphenation': ERROR,
1784
+ // 'vue/component-definition-name-casing': ERROR,
1785
+ // 'vue/first-attribute-linebreak': ERROR,
1786
+ // 'vue/html-closing-bracket-newline': ERROR,
1787
+ // 'vue/html-closing-bracket-spacing': ERROR,
1788
+ // 'vue/html-end-tags': ERROR,
1789
+ // 'vue/html-indent': ERROR,
1790
+ // 'vue/html-quotes': ERROR,
1791
+ "vue/html-self-closing": [
1792
+ ERROR,
1793
+ {
1794
+ html: {
1795
+ void: "any",
1796
+ // TODO Setting other value here for `void` would conflict with Prettier, default is `never`
1797
+ normal: "never",
1798
+ component: "never"
1799
+ }
1800
+ }
1801
+ ],
1802
+ // 'vue/max-attributes-per-line': ERROR,
1803
+ // 'vue/multiline-html-element-content-newline': ERROR,
1804
+ // 'vue/mustache-interpolation-spacing': ERROR,
1805
+ // 'vue/no-multi-spaces': ERROR,
1806
+ // 'vue/no-spaces-around-equal-signs-in-attribute': ERROR,
1807
+ // 'vue/no-template-shadow': ERROR,
1808
+ // 'vue/one-component-per-file': ERROR,
1809
+ // 'vue/prop-name-casing': ERROR,
1810
+ "vue/require-default-prop": OFF,
1811
+ // 'vue/require-explicit-emits': ERROR, // 3️⃣
1812
+ // 'vue/require-prop-types': ERROR,
1813
+ // 'vue/singleline-html-element-content-newline': ERROR,
1814
+ "vue/v-bind-style": [
1815
+ ERROR,
1816
+ "shorthand",
1817
+ {
1818
+ ...isMin3_4 && { sameNameShorthand: "always" }
1819
+ }
1820
+ ],
1821
+ // 'vue/v-on-event-hyphenation': ERROR, // 3️⃣
1822
+ // 'vue/v-on-style': ERROR,
1823
+ // 'vue/v-slot-style': ERROR,
1824
+ // 🔵 Priority C: Recommended
1825
+ // 'vue/attributes-order': ERROR,
1826
+ // 'vue/no-lone-template': ERROR,
1827
+ // 'vue/no-multiple-slot-args': ERROR,
1828
+ // 'vue/no-v-html': ERROR,
1829
+ // 'vue/order-in-components': ERROR,
1830
+ // 'vue/this-in-template': ERROR,
1831
+ // 🔵 Uncategorized
1832
+ "vue/block-lang": [
1833
+ ERROR,
1834
+ {
1835
+ script: {
1836
+ lang: "ts",
1837
+ ...!enforceTypescriptInScriptSection && { allowNoLang: true }
1838
+ }
1839
+ }
1840
+ ],
1841
+ "vue/block-order": [
1842
+ ERROR,
1843
+ {
1844
+ order: [
1845
+ ...Array.isArray(options.sfcBlockOrder) ? options.sfcBlockOrder : options.sfcBlockOrder === "script-first" ? ["script:not([setup])", "script[setup]", "template"] : ["template", "script:not([setup])", "script[setup]"],
1846
+ "style:not([scoped])",
1847
+ // TODO move to top?
1848
+ "style[scoped]"
1849
+ ]
1850
+ }
1851
+ ],
1852
+ // 'vue/block-tag-newline': OFF,
1853
+ ...options.enforceApiStyle != null && {
1854
+ "vue/component-api-style": [
1855
+ ERROR,
1856
+ [
1857
+ options.enforceApiStyle === "setup" ? "script-setup" : "options",
1858
+ // allows Composition API (not <script setup>)
1859
+ isVue2 ? "composition-vue2" : "composition"
1860
+ ]
1861
+ ]
1862
+ },
1863
+ "vue/component-name-in-template-casing": [
1864
+ ERROR,
1865
+ "kebab-case",
1866
+ {
1867
+ registeredComponentsOnly: false,
1868
+ ignores: [
1869
+ "/^[A-Z][a-z]+$/"
1870
+ /* Single word components must start with a capital letter */
1871
+ ]
1872
+ }
1873
+ ],
1874
+ "vue/component-options-name-casing": [
1875
+ ERROR,
1876
+ "PascalCase"
1877
+ /* default */
1878
+ ],
1879
+ "vue/custom-event-name-casing": [
1880
+ ERROR,
1881
+ "kebab-case"
1882
+ /* default is `camelCase` */
1883
+ ],
1884
+ "vue/define-emits-declaration": [
1885
+ ERROR,
1886
+ isMin3_3 ? "type-literal" : "type-based"
1887
+ ],
1888
+ "vue/define-macros-order": [
1889
+ ERROR,
1890
+ {
1891
+ order: ["defineOptions", "defineModel", "defineProps", "defineEmits", "defineSlots"],
1892
+ ...isMin3_4 && { defineExposeLast: true }
1893
+ }
1894
+ ],
1895
+ "vue/define-props-declaration": [ERROR, options.enforcePropsDeclarationStyle ?? "runtime"],
1896
+ // 'vue/enforce-style-attribute': OFF,
1897
+ "vue/html-button-has-type": ERROR,
1898
+ // 'vue/html-comment-content-newline': OFF,
1899
+ // 'vue/html-comment-content-spacing': OFF,
1900
+ // 'vue/html-comment-indent': OFF,
1901
+ // 'vue/match-component-file-name': OFF,
1902
+ // 'vue/match-component-import-name': OFF,
1903
+ // 'vue/max-lines-per-block': OFF,
1904
+ // 'vue/new-line-between-multi-line-property': OFF,
1905
+ // 'vue/next-tick-style': OFF,
1906
+ // 'vue/no-bare-strings-in-template': OFF,
1907
+ // For explicitness (Vue uses `false` as default value automatically)
1908
+ "vue/no-boolean-default": [ERROR, "default-false"],
1909
+ ...isVue3 && { "vue/no-deprecated-model-definition": ERROR },
1910
+ "vue/no-duplicate-attr-inheritance": ERROR,
1911
+ "vue/no-empty-component-block": ERROR,
1912
+ "vue/no-multiple-objects-in-class": ERROR,
1913
+ "vue/no-potential-component-option-typo": ERROR,
1914
+ "vue/no-ref-object-reactivity-loss": ERROR,
1915
+ "vue/no-required-prop-with-default": ERROR,
1916
+ // 'vue/no-restricted-block': OFF,
1917
+ // 'vue/no-restricted-call-after-await': OFF,
1918
+ // 'vue/no-restricted-class': OFF,
1919
+ // 'vue/no-restricted-component-names': OFF,
1920
+ // 'vue/no-restricted-component-options': OFF,
1921
+ // 'vue/no-restricted-custom-event': OFF,
1922
+ "vue/no-restricted-html-elements": [ERROR, ...DEPRECATED_HTML_TAGS],
1923
+ // 'vue/no-restricted-props': OFF,
1924
+ // 'vue/no-restricted-static-attribute': OFF,
1925
+ // 'vue/no-restricted-v-bind': OFF,
1926
+ // 'vue/no-restricted-v-on': OFF,
1927
+ // 'vue/no-root-v-if': OFF,
1928
+ "vue/no-setup-props-reactivity-loss": ERROR,
1929
+ // 'vue/no-static-inline-styles': OFF,
1930
+ // 'vue/no-template-target-blank': OFF,
1931
+ "vue/no-this-in-before-route-enter": ERROR,
1932
+ "vue/no-undef-components": [
1933
+ ERROR,
1934
+ {
1935
+ ignorePatterns: [...options.knownComponentNames || []]
1936
+ }
1937
+ ],
1938
+ // TODO enable if script setup is enforced?
1939
+ // 'vue/no-undef-properties': OFF,
1940
+ "vue/no-unsupported-features": [ERROR, { version: `^${options.fullVersion || majorVersion}` }],
1941
+ "vue/no-unused-emit-declarations": ERROR,
1942
+ // 'vue/no-unused-properties': OFF,
1943
+ "vue/no-unused-refs": ERROR,
1944
+ "vue/no-use-v-else-with-v-for": ERROR,
1945
+ "vue/no-useless-mustaches": ERROR,
1946
+ "vue/no-useless-v-bind": ERROR,
1947
+ // 'vue/no-v-text': OFF,
1948
+ "vue/padding-line-between-blocks": ERROR,
1949
+ // 'vue/padding-line-between-tags': OFF,
1950
+ "vue/padding-lines-in-component-definition": [
1951
+ ERROR,
1952
+ {
1953
+ withinOption: {
1954
+ // TODO understand the difference between `betweenItems` and `withinEach`: https://eslint.vuejs.org/rules/padding-lines-in-component-definition.html
1955
+ props: "ignore"
1956
+ }
1957
+ }
1958
+ ],
1959
+ ...isMin3_3 && {
1960
+ "vue/prefer-define-options": ERROR
1961
+ },
1962
+ "vue/prefer-prop-type-boolean-first": ERROR,
1963
+ "vue/prefer-separate-static-class": ERROR,
1964
+ "vue/prefer-true-attribute-shorthand": ERROR,
1965
+ "vue/require-direct-export": ERROR,
1966
+ // 'vue/require-emit-validator': OFF,
1967
+ ...isMin3_3 && {
1968
+ "vue/require-explicit-slots": ERROR
1969
+ },
1970
+ // 'vue/require-expose': OFF,
1971
+ "vue/require-macro-variable-name": ERROR,
1972
+ // 'vue/require-name-property': OFF,
1973
+ // 'vue/require-prop-comment': OFF,
1974
+ "vue/require-typed-object-prop": ERROR,
1975
+ "vue/require-typed-ref": ERROR,
1976
+ // 'vue/script-indent': OFF,
1977
+ // 'vue/sort-keys': OFF,
1978
+ // 'vue/static-class-names-order': OFF,
1979
+ "vue/v-for-delimiter-style": [
1980
+ ERROR,
1981
+ "in"
1982
+ /* default */
1983
+ ],
1984
+ // This rule is not required in Vue 3, as the key is automatically assigned to the elements.
1985
+ ...isVue2 && {
1986
+ "vue/v-for-delimiter-style": ERROR
1987
+ },
1988
+ // TODO change to [inline, inline-function] once this is landed: https://github.com/vuejs/eslint-plugin-vue/issues/2460
1989
+ "vue/v-on-handler-style": [ERROR, "inline"],
1990
+ ...isMin3_3 && {
1991
+ "vue/valid-define-options": ERROR
1992
+ },
1993
+ // 🔵 Extension Rules
1994
+ // 'vue/array-bracket-newline': OFF,
1995
+ // 'vue/array-bracket-spacing': OFF,
1996
+ // 'vue/array-element-newline': OFF,
1997
+ // 'vue/arrow-spacing': OFF,
1998
+ // 'vue/block-spacing': OFF,
1999
+ // 'vue/brace-style': OFF,
2000
+ "vue/camelcase": [ERROR, RULE_CAMELCASE_OPTIONS],
2001
+ // 'vue/comma-dangle': OFF,
2002
+ // 'vue/comma-spacing': OFF,
2003
+ // 'vue/comma-style': OFF,
2004
+ // 'vue/dot-location': OFF,
2005
+ ...!options.noPropertyAccessFromIndexSignatureSetInTsconfigForVueFiles && {
2006
+ "vue/dot-notation": ERROR
2007
+ },
2008
+ "vue/eqeqeq": [ERROR, ...RULE_EQEQEQ_OPTIONS],
2009
+ // 'vue/func-call-spacing': OFF,
2010
+ // 'vue/key-spacing': OFF,
2011
+ // 'vue/keyword-spacing': OFF,
2012
+ // 'vue/max-len': OFF,
2013
+ // 'vue/multiline-ternary': OFF,
2014
+ "vue/no-console": ERROR,
2015
+ ...warnUnlessForcedError(internalOptions, "vue/no-constant-condition"),
2016
+ "vue/no-empty-pattern": ERROR,
2017
+ // 'vue/no-extra-parens': OFF,
2018
+ "vue/no-irregular-whitespace": ERROR,
2019
+ "vue/no-loss-of-precision": ERROR,
2020
+ // 'vue/no-restricted-syntax': OFF,
2021
+ "vue/no-sparse-arrays": ERROR,
2022
+ "vue/no-useless-concat": ERROR,
2023
+ // 'vue/object-curly-newline': OFF,
2024
+ // 'vue/object-curly-spacing': OFF,
2025
+ // 'vue/object-property-newline': OFF,
2026
+ "vue/object-shorthand": ERROR,
2027
+ // 'vue/operator-linebreak': OFF,
2028
+ "vue/prefer-template": ERROR,
2029
+ // 'vue/quote-props': OFF,
2030
+ // 'vue/space-in-parens': OFF,
2031
+ // 'vue/space-infix-ops': OFF,
2032
+ // 'vue/space-unary-ops': OFF,
2033
+ // 'vue/template-curly-spacing': OFF,
2034
+ // 🔵 Not working great in Vue files
2035
+ "@typescript-eslint/prefer-function-type": OFF,
2036
+ "@typescript-eslint/unified-signatures": OFF,
2037
+ "import/first": OFF,
2038
+ // May be wrong if multiple <script> blocks are present
2039
+ "import/no-default-export": OFF,
2040
+ "no-useless-assignment": OFF,
2041
+ // False positives in script setup
2042
+ ...options.overrides
2043
+ };
2044
+ const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
2045
+ const nuxtLayoutsFiles = `${options.nuxtOrVueProjectDir}layouts/**/*.vue`;
2046
+ return [
2047
+ {
2048
+ plugins: {
2049
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2050
+ vue: eslintPluginVue
2051
+ },
2052
+ name: genFlatConfigEntryName("vue/setup")
2053
+ },
2054
+ {
2055
+ files: [GLOB_VUE, ...files],
2056
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
2057
+ processor: eslintPluginVue.processors[".vue"],
2058
+ languageOptions: {
2059
+ globals: globals.browser,
2060
+ parser: parserVue,
2061
+ parserOptions: {
2062
+ ecmaFeatures: {
2063
+ jsx: true
2064
+ },
2065
+ extraFileExtensions: [".vue"],
2066
+ parser: internalOptions.isTypescriptEnabled ? "@typescript-eslint/parser" : void 0,
2067
+ sourceType: "module"
2068
+ }
2069
+ },
2070
+ name: genFlatConfigEntryName("vue/setup")
2071
+ },
2072
+ {
2073
+ files,
2074
+ ...options.ignores && { ignores: options.ignores },
2075
+ rules: {
2076
+ ...recommendedRules,
2077
+ ...rules,
2078
+ ...options.overrides
2079
+ },
2080
+ name: genFlatConfigEntryName("vue")
2081
+ },
2082
+ {
2083
+ files: [
2084
+ `${options.nuxtOrVueProjectDir}pages/**/*.vue`,
2085
+ `${options.nuxtOrVueProjectDir}views/**/*.vue`,
2086
+ isNuxtEnabled && [nuxtLayoutsFiles, "app.vue", "error.vue"],
2087
+ ...arraify(options.doNotRequireComponentNamesToBeMultiWordForPatterns)
2088
+ ].filter((v) => v !== false),
2089
+ rules: {
2090
+ "vue/multi-word-component-names": OFF
2091
+ },
2092
+ name: genFlatConfigEntryName("vue/allow-single-word-component-names")
2093
+ },
2094
+ isNuxtEnabled && {
2095
+ files: [nuxtLayoutsFiles],
2096
+ rules: {
2097
+ "vue/require-explicit-slots": OFF
2098
+ },
2099
+ name: genFlatConfigEntryName("vue/allow-implicit-slots")
2100
+ },
2101
+ {
2102
+ files: [
2103
+ GLOB_VUE,
2104
+ isNuxtEnabled && [
2105
+ `${options.nuxtOrVueProjectDir}plugins/**/*.*`,
2106
+ `${options.nuxtOrVueProjectDir}server/**/*.*`
2107
+ ]
2108
+ ].filter((v) => v !== false),
2109
+ rules: {
2110
+ "import/no-default-export": OFF
2111
+ },
2112
+ name: genFlatConfigEntryName("vue/allow-default-export")
2113
+ },
2114
+ a11y && [
2115
+ ...eslintPluginVueA11y.configs["flat/recommended"],
2116
+ {
2117
+ files,
2118
+ rules: {
2119
+ // 'vuejs-accessibility/alt-text': ERROR,
2120
+ // 'vuejs-accessibility/anchor-has-content': ERROR,
2121
+ // 'vuejs-accessibility/aria-props': ERROR,
2122
+ // 'vuejs-accessibility/aria-role': ERROR,
2123
+ // 'vuejs-accessibility/aria-unsupported-elements': ERROR,
2124
+ // 'vuejs-accessibility/click-events-have-key-events': ERROR,
2125
+ // 'vuejs-accessibility/form-control-has-label': ERROR,
2126
+ // 'vuejs-accessibility/heading-has-content': ERROR,
2127
+ // 'vuejs-accessibility/iframe-has-title': ERROR,
2128
+ // 'vuejs-accessibility/interactive-supports-focus': ERROR,
2129
+ // 'vuejs-accessibility/label-has-for': ERROR,
2130
+ // 'vuejs-accessibility/media-has-caption': ERROR,
2131
+ // 'vuejs-accessibility/mouse-events-have-key-events': ERROR,
2132
+ // 'vuejs-accessibility/no-access-key': ERROR,
2133
+ // 'vuejs-accessibility/no-autofocus': ERROR,
2134
+ // 'vuejs-accessibility/no-distracting-elements': ERROR,
2135
+ // 'vuejs-accessibility/no-onchange': ERROR,
2136
+ // 'vuejs-accessibility/no-redundant-roles': ERROR,
2137
+ // 'vuejs-accessibility/no-static-element-interactions': ERROR,
2138
+ // 'vuejs-accessibility/role-has-required-aria-props': ERROR,
2139
+ // 'vuejs-accessibility/tabindex-no-positive': ERROR,
2140
+ ...options.overridesA11y
2141
+ },
2142
+ name: genFlatConfigEntryName("vue/a11y")
2143
+ }
2144
+ ],
2145
+ options.pinia && {
2146
+ plugins: {
2147
+ pinia: eslintPluginPinia
2148
+ },
2149
+ rules: {
2150
+ ...eslintPluginPinia.configs.recommended.rules,
2151
+ // 'pinia/never-export-initialized-store': ERROR,
2152
+ // 'pinia/no-duplicate-store-ids': ERROR,
2153
+ // 'pinia/no-return-global-properties': ERROR,
2154
+ "pinia/prefer-single-store-per-file": ERROR,
2155
+ "pinia/prefer-use-store-naming-convention": [
2156
+ ERROR,
2157
+ {
2158
+ checkStoreNameMismatch: true
2159
+ }
2160
+ ],
2161
+ // 'pinia/require-setup-store-properties-export': ERROR,
2162
+ ...options.overridesPinia
2163
+ },
2164
+ name: genFlatConfigEntryName("pinia")
2165
+ }
2166
+ ].flat().filter((v) => !!v);
2167
+ };
2168
+
2169
+ // src/index.ts
2170
+ var RULES_NOT_TO_DISABLE_IN_CONFIG_PRETTIER = /* @__PURE__ */ new Set(["curly", "unicorn/template-indent"]);
2171
+ var eslintConfig = (options = {}) => {
2172
+ const configsOptions = options.configs || {};
2173
+ const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || isPackageExists("vue"));
2174
+ const typescriptPackageInfo = getPackageInfoSync("typescript");
2175
+ const isTypescriptEnabled = configsOptions.ts !== false && Boolean(configsOptions.ts || typescriptPackageInfo);
2176
+ const jsOptions = {
2177
+ ...assignOptions(configsOptions, "js")
2178
+ };
2179
+ const tsOptions = {
2180
+ extraFileExtensions: [isVueEnabled && "vue"].filter((v) => v !== false),
2181
+ typescriptVersion: typescriptPackageInfo?.version,
2182
+ ...assignOptions(configsOptions, "ts")
2183
+ };
2184
+ tsOptions.tsconfigPath ||= "./**/tsconfig*.json";
2185
+ const vueFullVersion = getPackageInfoSync("vue")?.version;
2186
+ const vueMajorVersionStr = vueFullVersion?.split(".")[0];
2187
+ const vueMajorVersion = vueMajorVersionStr === "2" ? 2 : vueMajorVersionStr === "3" ? 3 : void 0;
2188
+ const nuxtMajorVersionStr = getPackageInfoSync("nuxt")?.version?.split(".")[0];
2189
+ const nuxtMajorVersion = nuxtMajorVersionStr === "3" ? 3 : void 0;
2190
+ const vueOptions = {
2191
+ majorVersion: vueMajorVersion ?? 3,
2192
+ fullVersion: vueFullVersion,
2193
+ nuxtMajorVersion,
2194
+ pinia: isPackageExists("pinia"),
2195
+ enforceTypescriptInScriptSection: isTypescriptEnabled,
2196
+ ...assignOptions(configsOptions, "vue")
2197
+ };
2198
+ const isUnicornEnabled = Boolean(configsOptions.unicorn ?? true);
2199
+ const unicornOptions = {
2200
+ ...assignOptions(configsOptions, "unicorn")
2201
+ };
2202
+ const isImportEnabled = Boolean(configsOptions.import ?? true);
2203
+ const importOptions = {
2204
+ ...isTypescriptEnabled && { tsconfigPath: tsOptions.tsconfigPath },
2205
+ ...assignOptions(configsOptions, "import")
2206
+ };
2207
+ const isNodeEnabled = Boolean(configsOptions.node ?? true);
2208
+ const nodeOptions = {
2209
+ ...assignOptions(configsOptions, "node")
2210
+ };
2211
+ const isPromiseEnabled = Boolean(configsOptions.promise ?? true);
2212
+ const promiseOptions = {
2213
+ ...assignOptions(configsOptions, "promise")
2214
+ };
2215
+ const isSonarEnabled = Boolean(configsOptions.sonar ?? true);
2216
+ const sonarOptions = {
2217
+ ...assignOptions(configsOptions, "sonar")
2218
+ };
2219
+ const isTailwindEnabled = configsOptions.tailwind === false ? false : configsOptions.tailwind ? true : isPackageExists("tailwindcss");
2220
+ const tailwindOptions = {
2221
+ ...assignOptions(configsOptions, "tailwind")
2222
+ };
2223
+ const isRegexpEnabled = Boolean(configsOptions.regexp ?? true);
2224
+ const regexpOptions = {
2225
+ ...assignOptions(configsOptions, "regexp")
2226
+ };
2227
+ const isSecurityEnabled = Boolean(configsOptions.security ?? false);
2228
+ const securityOptions = {
2229
+ ...assignOptions(configsOptions, "security")
2230
+ };
2231
+ const internalOptions = {
2232
+ globalOptions: options,
2233
+ isTypescriptEnabled,
2234
+ vueOptions
2235
+ };
2236
+ return [
2237
+ // According to ESLint docs: "If `ignores` is used without any other keys in the configuration object, then the patterns act as global ignores <...> Patterns are added after the default patterns, which are ["**/node_modules/", ".git/"]." - https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
2238
+ {
2239
+ ignores: options.ignores || ["**/dist"],
2240
+ name: genFlatConfigEntryName("global-ignores")
2241
+ },
2242
+ {
2243
+ plugins: {
2244
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2245
+ "disable-autofix": pluginDisableAutofix,
2246
+ // Used in multiple configs and we can't define plugin multiple times
2247
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2248
+ unicorn: eslintPluginUnicorn2,
2249
+ "@stylistic": eslintPluginStylistic
2250
+ },
2251
+ languageOptions: {
2252
+ ecmaVersion: "latest",
2253
+ sourceType: "module",
2254
+ parserOptions: {
2255
+ ecmaVersion: "latest",
2256
+ ecmaFeatures: {
2257
+ jsx: true
2258
+ },
2259
+ sourceType: "module"
2260
+ },
2261
+ globals: {
2262
+ ...isNodeEnabled && globals2.node
2263
+ }
2264
+ },
2265
+ name: genFlatConfigEntryName("global-setup")
2266
+ },
2267
+ jsEslintConfig(jsOptions, internalOptions),
2268
+ isUnicornEnabled && unicornEslintConfig(unicornOptions, internalOptions),
2269
+ isImportEnabled && importEslintConfig(importOptions, internalOptions),
2270
+ isNodeEnabled && nodeEslintConfig(nodeOptions, internalOptions),
2271
+ isPromiseEnabled && promiseEslintConfig(promiseOptions, internalOptions),
2272
+ isSonarEnabled && sonarEslintConfig(sonarOptions, internalOptions),
2273
+ isTailwindEnabled && tailwindEslintConfig(tailwindOptions, internalOptions),
2274
+ isRegexpEnabled && regexpEslintConfig(regexpOptions, internalOptions),
2275
+ isSecurityEnabled && securityEslintConfig(securityOptions, internalOptions),
2276
+ isTypescriptEnabled && tsEslintConfig(tsOptions, internalOptions),
2277
+ // Must come after all rulesets for vanilla JS
2278
+ isVueEnabled && vueEslintConfig(vueOptions, internalOptions),
2279
+ // Must come after ts
2280
+ {
2281
+ files: GLOB_CONFIG_FILES,
2282
+ rules: {
2283
+ "import/no-default-export": OFF,
2284
+ "import/no-extraneous-dependencies": OFF,
2285
+ "n/no-unpublished-require": OFF
2286
+ },
2287
+ name: genFlatConfigEntryName("config-files")
2288
+ },
2289
+ ...options.extraConfigs || [],
2290
+ // MUST be last
2291
+ !options.disablePrettierIncompatibleRules && {
2292
+ rules: Object.fromEntries(
2293
+ Object.entries(eslintConfigPrettier.rules).filter(
2294
+ ([k]) => !RULES_NOT_TO_DISABLE_IN_CONFIG_PRETTIER.has(k)
2295
+ )
2296
+ ),
2297
+ name: genFlatConfigEntryName("eslint-config-prettier")
2298
+ }
2299
+ ].filter((v) => !!v).flat();
2300
+ };
2301
+ export {
2302
+ eslintConfig
2303
+ };