@debbl/eslint-config 3.10.2 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,1889 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
- GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
35
- GLOB_CSS: () => GLOB_CSS,
36
- GLOB_EXCLUDE: () => GLOB_EXCLUDE,
37
- GLOB_HTML: () => GLOB_HTML,
38
- GLOB_JS: () => GLOB_JS,
39
- GLOB_JSON: () => GLOB_JSON,
40
- GLOB_JSON5: () => GLOB_JSON5,
41
- GLOB_JSONC: () => GLOB_JSONC,
42
- GLOB_JSX: () => GLOB_JSX,
43
- GLOB_LESS: () => GLOB_LESS,
44
- GLOB_MARKDOWN: () => GLOB_MARKDOWN,
45
- GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
46
- GLOB_MDX: () => GLOB_MDX,
47
- GLOB_POSTCSS: () => GLOB_POSTCSS,
48
- GLOB_SCSS: () => GLOB_SCSS,
49
- GLOB_SRC: () => GLOB_SRC,
50
- GLOB_SRC_EXT: () => GLOB_SRC_EXT,
51
- GLOB_STYLE: () => GLOB_STYLE,
52
- GLOB_TESTS: () => GLOB_TESTS,
53
- GLOB_TOML: () => GLOB_TOML,
54
- GLOB_TS: () => GLOB_TS,
55
- GLOB_TSX: () => GLOB_TSX,
56
- GLOB_VUE: () => GLOB_VUE,
57
- GLOB_YAML: () => GLOB_YAML,
58
- combine: () => combine,
59
- comments: () => comments,
60
- default: () => index_default,
61
- defineConfig: () => defineConfig,
62
- getConfigOptions: () => getConfigOptions,
63
- ignores: () => ignores,
64
- imports: () => imports,
65
- interopDefault: () => interopDefault,
66
- javascript: () => javascript,
67
- jsdoc: () => jsdoc,
68
- jsonc: () => jsonc,
69
- markdown: () => markdown,
70
- node: () => node,
71
- parserPlain: () => parserPlain,
72
- perfectionist: () => perfectionist,
73
- prettier: () => prettier,
74
- sortPackageJson: () => sortPackageJson,
75
- sortTsconfig: () => sortTsconfig,
76
- test: () => test,
77
- toml: () => toml,
78
- typescript: () => typescript,
79
- unicorn: () => unicorn,
80
- vue: () => vue,
81
- yml: () => yml
82
- });
83
- module.exports = __toCommonJS(index_exports);
84
-
85
- // src/utils.ts
86
- var parserPlain = {
87
- meta: {
88
- name: "parser-plain"
89
- },
90
- parseForESLint: (code) => ({
91
- ast: {
92
- body: [],
93
- comments: [],
94
- loc: { end: code.length, start: 0 },
95
- range: [0, code.length],
96
- tokens: [],
97
- type: "Program"
98
- },
99
- scopeManager: null,
100
- services: { isPlain: true },
101
- visitorKeys: {
102
- Program: []
103
- }
104
- })
105
- };
106
- async function combine(...configs) {
107
- const resolved = await Promise.all(configs);
108
- return resolved.flat();
109
- }
110
- async function interopDefault(m) {
111
- const resolved = await m;
112
- return resolved.default || resolved;
113
- }
114
- function getConfigOptions(options) {
115
- return options ? typeof options !== "boolean" ? options : {} : {};
116
- }
117
-
118
- // src/configs/comments.ts
119
- async function comments() {
120
- const pluginComments = await interopDefault(
121
- // @ts-expect-error missing types
122
- import("@eslint-community/eslint-plugin-eslint-comments")
123
- );
124
- return [
125
- {
126
- name: "eslint/eslint-comments/rules",
127
- plugins: {
128
- "eslint-comments": pluginComments
129
- },
130
- rules: {
131
- "eslint-comments/no-aggregating-enable": "error",
132
- "eslint-comments/no-duplicate-disable": "error",
133
- "eslint-comments/no-unlimited-disable": "error",
134
- "eslint-comments/no-unused-enable": "error"
135
- }
136
- }
137
- ];
138
- }
139
-
140
- // src/globs.ts
141
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
142
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
143
- var GLOB_JS = "**/*.?([cm])js";
144
- var GLOB_JSX = "**/*.?([cm])jsx";
145
- var GLOB_TS = "**/*.?([cm])ts";
146
- var GLOB_TSX = "**/*.?([cm])tsx";
147
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
148
- var GLOB_CSS = "**/*.css";
149
- var GLOB_POSTCSS = "**/*.{p,post}css";
150
- var GLOB_LESS = "**/*.less";
151
- var GLOB_SCSS = "**/*.scss";
152
- var GLOB_JSON = "**/*.json";
153
- var GLOB_JSON5 = "**/*.json5";
154
- var GLOB_JSONC = "**/*.jsonc";
155
- var GLOB_MARKDOWN = "**/*.md";
156
- var GLOB_MDX = "**/*.mdx";
157
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
158
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
159
- var GLOB_VUE = "**/*.vue";
160
- var GLOB_YAML = "**/*.y?(a)ml";
161
- var GLOB_TOML = "**/*.toml";
162
- var GLOB_HTML = "**/*.htm?(l)";
163
- var GLOB_TESTS = [
164
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
165
- `**/*.spec.${GLOB_SRC_EXT}`,
166
- `**/*.test.${GLOB_SRC_EXT}`,
167
- `**/*.bench.${GLOB_SRC_EXT}`,
168
- `**/*.benchmark.${GLOB_SRC_EXT}`
169
- ];
170
- var GLOB_ALL_SRC = [
171
- GLOB_SRC,
172
- GLOB_STYLE,
173
- GLOB_JSON,
174
- GLOB_JSON5,
175
- GLOB_MARKDOWN,
176
- GLOB_VUE,
177
- GLOB_YAML,
178
- GLOB_HTML
179
- ];
180
- var GLOB_EXCLUDE = [
181
- "**/node_modules",
182
- "**/dist",
183
- "**/package-lock.json",
184
- "**/yarn.lock",
185
- "**/pnpm-lock.yaml",
186
- "**/bun.lockb",
187
- "**/public",
188
- "**/output",
189
- "**/coverage",
190
- "**/temp",
191
- "**/.vitepress/cache",
192
- "**/.nuxt",
193
- "**/.next",
194
- "**/.vercel",
195
- "**/.changeset",
196
- "**/.idea",
197
- "**/.cache",
198
- "**/.output",
199
- "**/.vite-inspect",
200
- "**/CHANGELOG*.md",
201
- "**/*.min.*",
202
- "**/LICENSE*",
203
- "**/__snapshots__",
204
- "**/auto-import?(s).d.ts",
205
- "**/components.d.ts"
206
- ];
207
-
208
- // src/configs/ignores.ts
209
- var ignores = async (options) => {
210
- const { enableGitignore = true, files = [] } = options;
211
- const gitIgnores = [];
212
- if (enableGitignore) {
213
- const gitignore = await interopDefault(
214
- import("eslint-config-flat-gitignore")
215
- );
216
- gitIgnores.push(...gitignore(getConfigOptions(enableGitignore)).ignores);
217
- }
218
- let ignores2 = [...GLOB_EXCLUDE, ...gitIgnores];
219
- if (typeof files === "function") {
220
- ignores2 = files(ignores2);
221
- } else {
222
- ignores2 = [...ignores2, ...files];
223
- }
224
- return [
225
- {
226
- name: "eslint/ignores",
227
- ignores: [...GLOB_EXCLUDE, ...ignores2]
228
- }
229
- ];
230
- };
231
-
232
- // src/configs/imports.ts
233
- async function imports() {
234
- const pluginImport = await interopDefault(import("eslint-plugin-import-x"));
235
- return [
236
- {
237
- name: "eslint/imports/rules",
238
- plugins: {
239
- import: pluginImport
240
- },
241
- rules: {
242
- "import/first": "error",
243
- "import/no-duplicates": "error",
244
- "import/no-mutable-exports": "error",
245
- "import/no-named-default": "error",
246
- "import/no-self-import": "error",
247
- "import/no-webpack-loader-syntax": "error",
248
- "import/newline-after-import": ["error", { count: 1 }],
249
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"]
250
- }
251
- }
252
- ];
253
- }
254
-
255
- // src/configs/javascript.ts
256
- var import_globals = __toESM(require("globals"), 1);
257
- var javascript = async (options) => {
258
- const { overrides = {} } = options;
259
- const pluginUnusedImports = await interopDefault(
260
- import("eslint-plugin-unused-imports")
261
- );
262
- return [
263
- {
264
- name: "eslint/javascript/rules",
265
- languageOptions: {
266
- ecmaVersion: 2022,
267
- globals: {
268
- ...import_globals.default.browser,
269
- ...import_globals.default.es2021,
270
- ...import_globals.default.node,
271
- document: "readonly",
272
- navigator: "readonly",
273
- window: "readonly"
274
- },
275
- parserOptions: {
276
- ecmaFeatures: {
277
- jsx: true
278
- },
279
- ecmaVersion: 2022,
280
- sourceType: "module"
281
- },
282
- sourceType: "module"
283
- },
284
- linterOptions: {
285
- reportUnusedDisableDirectives: true
286
- },
287
- plugins: {
288
- "unused-imports": pluginUnusedImports
289
- },
290
- rules: {
291
- "accessor-pairs": [
292
- "error",
293
- { enforceForClassMembers: true, setWithoutGet: true }
294
- ],
295
- "array-callback-return": "error",
296
- "block-scoped-var": "error",
297
- "constructor-super": "error",
298
- "default-case-last": "error",
299
- "dot-notation": ["error", { allowKeywords: true }],
300
- "eqeqeq": ["error", "smart"],
301
- "new-cap": [
302
- "error",
303
- { capIsNew: false, newIsCap: true, properties: true }
304
- ],
305
- "no-alert": "error",
306
- "no-array-constructor": "error",
307
- "no-async-promise-executor": "error",
308
- "no-caller": "error",
309
- "no-case-declarations": "error",
310
- "no-class-assign": "error",
311
- "no-compare-neg-zero": "error",
312
- "no-cond-assign": ["error", "always"],
313
- "no-console": ["error", { allow: ["warn", "error"] }],
314
- "no-const-assign": "error",
315
- "no-control-regex": "error",
316
- "no-debugger": "error",
317
- "no-delete-var": "error",
318
- "no-dupe-args": "error",
319
- "no-dupe-class-members": "error",
320
- "no-dupe-keys": "error",
321
- "no-duplicate-case": "error",
322
- "no-empty": ["error", { allowEmptyCatch: true }],
323
- "no-empty-character-class": "error",
324
- "no-empty-pattern": "error",
325
- "no-eval": "error",
326
- "no-ex-assign": "error",
327
- "no-extend-native": "error",
328
- "no-extra-bind": "error",
329
- "no-extra-boolean-cast": "error",
330
- "no-fallthrough": "error",
331
- "no-func-assign": "error",
332
- "no-global-assign": "error",
333
- "no-implied-eval": "error",
334
- "no-import-assign": "error",
335
- "no-invalid-regexp": "error",
336
- "no-invalid-this": "error",
337
- "no-irregular-whitespace": "error",
338
- "no-iterator": "error",
339
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
340
- "no-lone-blocks": "error",
341
- "no-loss-of-precision": "error",
342
- "no-misleading-character-class": "error",
343
- "no-multi-str": "error",
344
- "no-new": "error",
345
- "no-new-func": "error",
346
- "no-new-native-nonconstructor": "error",
347
- "no-new-wrappers": "error",
348
- "no-obj-calls": "error",
349
- "no-octal": "error",
350
- "no-octal-escape": "error",
351
- "no-proto": "error",
352
- "no-prototype-builtins": "error",
353
- "no-redeclare": ["error", { builtinGlobals: false }],
354
- "no-regex-spaces": "error",
355
- "no-restricted-globals": [
356
- "error",
357
- { message: "Use `globalThis` instead.", name: "global" },
358
- { message: "Use `globalThis` instead.", name: "self" }
359
- ],
360
- "no-restricted-properties": [
361
- "error",
362
- {
363
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
364
- property: "__proto__"
365
- },
366
- {
367
- message: "Use `Object.defineProperty` instead.",
368
- property: "__defineGetter__"
369
- },
370
- {
371
- message: "Use `Object.defineProperty` instead.",
372
- property: "__defineSetter__"
373
- },
374
- {
375
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
376
- property: "__lookupGetter__"
377
- },
378
- {
379
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
380
- property: "__lookupSetter__"
381
- }
382
- ],
383
- "no-restricted-syntax": [
384
- "error",
385
- "TSEnumDeclaration[const=true]",
386
- "TSExportAssignment"
387
- ],
388
- "no-self-assign": ["error", { props: true }],
389
- "no-self-compare": "error",
390
- "no-sequences": "error",
391
- "no-shadow-restricted-names": "error",
392
- "no-sparse-arrays": "error",
393
- "no-template-curly-in-string": "error",
394
- "no-this-before-super": "error",
395
- "no-throw-literal": "error",
396
- "no-undef": "error",
397
- "no-undef-init": "error",
398
- "no-unexpected-multiline": "error",
399
- "no-unmodified-loop-condition": "error",
400
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
401
- "no-unreachable": "error",
402
- "no-unreachable-loop": "error",
403
- "no-unsafe-finally": "error",
404
- "no-unsafe-negation": "error",
405
- "no-unused-expressions": [
406
- "error",
407
- {
408
- allowShortCircuit: true,
409
- allowTaggedTemplates: true,
410
- allowTernary: true
411
- }
412
- ],
413
- "no-unused-vars": [
414
- "error",
415
- {
416
- args: "none",
417
- caughtErrors: "none",
418
- ignoreRestSiblings: true,
419
- vars: "all"
420
- }
421
- ],
422
- "no-use-before-define": [
423
- "error",
424
- { classes: false, functions: false, variables: true }
425
- ],
426
- "no-useless-backreference": "error",
427
- "no-useless-call": "error",
428
- "no-useless-catch": "error",
429
- "no-useless-computed-key": "error",
430
- "no-useless-constructor": "error",
431
- "no-useless-rename": "error",
432
- "no-useless-return": "error",
433
- "no-var": "error",
434
- "no-with": "error",
435
- "object-shorthand": [
436
- "error",
437
- "always",
438
- {
439
- avoidQuotes: true,
440
- ignoreConstructors: false
441
- }
442
- ],
443
- "one-var": ["error", { initialized: "never" }],
444
- "prefer-arrow-callback": [
445
- "error",
446
- {
447
- allowNamedFunctions: false,
448
- allowUnboundThis: true
449
- }
450
- ],
451
- "prefer-const": [
452
- "error",
453
- {
454
- destructuring: "all",
455
- ignoreReadBeforeAssign: true
456
- }
457
- ],
458
- "prefer-exponentiation-operator": "error",
459
- "prefer-promise-reject-errors": "error",
460
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
461
- "prefer-rest-params": "error",
462
- "prefer-spread": "error",
463
- "prefer-template": "error",
464
- "symbol-description": "error",
465
- "unicode-bom": ["error", "never"],
466
- "unused-imports/no-unused-imports": "warn",
467
- "unused-imports/no-unused-vars": [
468
- "error",
469
- {
470
- args: "after-used",
471
- argsIgnorePattern: "^_",
472
- vars: "all",
473
- varsIgnorePattern: "^_"
474
- }
475
- ],
476
- "use-isnan": [
477
- "error",
478
- { enforceForIndexOf: true, enforceForSwitchCase: true }
479
- ],
480
- "valid-typeof": ["error", { requireStringLiterals: true }],
481
- "vars-on-top": "error",
482
- "yoda": ["error", "never"],
483
- ...overrides
484
- }
485
- },
486
- {
487
- name: "eslint/scripts-overrides/disables/cli",
488
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
489
- rules: {
490
- "no-console": "off"
491
- }
492
- }
493
- ];
494
- };
495
-
496
- // src/configs/jsdoc.ts
497
- async function jsdoc() {
498
- return [
499
- {
500
- name: "eslint/jsdoc/rules",
501
- plugins: {
502
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
503
- },
504
- rules: {
505
- "jsdoc/check-access": "warn",
506
- "jsdoc/check-param-names": "warn",
507
- "jsdoc/check-property-names": "warn",
508
- "jsdoc/check-types": "warn",
509
- "jsdoc/empty-tags": "warn",
510
- "jsdoc/implements-on-classes": "warn",
511
- "jsdoc/no-defaults": "warn",
512
- "jsdoc/no-multi-asterisks": "warn",
513
- "jsdoc/require-param-name": "warn",
514
- "jsdoc/require-property": "warn",
515
- "jsdoc/require-property-description": "warn",
516
- "jsdoc/require-property-name": "warn",
517
- "jsdoc/require-returns-check": "warn",
518
- "jsdoc/require-returns-description": "warn",
519
- "jsdoc/require-yields-check": "warn",
520
- "jsdoc/check-alignment": "warn",
521
- "jsdoc/multiline-blocks": "warn"
522
- }
523
- }
524
- ];
525
- }
526
-
527
- // src/configs/jsonc.ts
528
- var jsonc = async (options) => {
529
- const { overrides = {} } = options;
530
- const [pluginJsonc, parserJsonc] = await Promise.all([
531
- interopDefault(import("eslint-plugin-jsonc")),
532
- interopDefault(import("jsonc-eslint-parser"))
533
- ]);
534
- return [
535
- {
536
- name: "eslint/jsonc/setup",
537
- plugins: {
538
- jsonc: pluginJsonc
539
- }
540
- },
541
- {
542
- name: "eslint/jsonc/rules",
543
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
544
- languageOptions: {
545
- parser: parserJsonc
546
- },
547
- rules: {
548
- "jsonc/no-bigint-literals": "error",
549
- "jsonc/no-binary-expression": "error",
550
- "jsonc/no-binary-numeric-literals": "error",
551
- "jsonc/no-dupe-keys": "error",
552
- "jsonc/no-escape-sequence-in-identifier": "error",
553
- "jsonc/no-floating-decimal": "error",
554
- "jsonc/no-hexadecimal-numeric-literals": "error",
555
- "jsonc/no-infinity": "error",
556
- "jsonc/no-multi-str": "error",
557
- "jsonc/no-nan": "error",
558
- "jsonc/no-number-props": "error",
559
- "jsonc/no-numeric-separators": "error",
560
- "jsonc/no-octal": "error",
561
- "jsonc/no-octal-escape": "error",
562
- "jsonc/no-octal-numeric-literals": "error",
563
- "jsonc/no-parenthesized": "error",
564
- "jsonc/no-plus-sign": "error",
565
- "jsonc/no-regexp-literals": "error",
566
- "jsonc/no-sparse-arrays": "error",
567
- "jsonc/no-template-literals": "error",
568
- "jsonc/no-undefined-value": "error",
569
- "jsonc/no-unicode-codepoint-escapes": "error",
570
- "jsonc/no-useless-escape": "error",
571
- "jsonc/space-unary-ops": "error",
572
- "jsonc/valid-json-number": "error",
573
- "jsonc/vue-custom-block/no-parsing-error": "error",
574
- "jsonc/array-bracket-spacing": ["error", "never"],
575
- "jsonc/comma-style": ["error", "last"],
576
- "jsonc/key-spacing": [
577
- "error",
578
- { afterColon: true, beforeColon: false }
579
- ],
580
- "jsonc/object-curly-newline": [
581
- "error",
582
- { consistent: true, multiline: true }
583
- ],
584
- "jsonc/object-curly-spacing": ["error", "always"],
585
- "jsonc/object-property-newline": [
586
- "error",
587
- { allowMultiplePropertiesPerLine: true }
588
- ],
589
- "jsonc/quote-props": "error",
590
- "jsonc/quotes": "error",
591
- ...overrides
592
- }
593
- }
594
- ];
595
- };
596
-
597
- // src/configs/markdown.ts
598
- var markdown = async (options) => {
599
- const {
600
- mdx: _enableMdx = false,
601
- componentExts = [],
602
- overrides = {}
603
- } = options;
604
- const pluginMarkdown = await interopDefault(import("@eslint/markdown"));
605
- const _markdown = [
606
- {
607
- name: "eslint/markdown/setup",
608
- plugins: {
609
- markdown: pluginMarkdown
610
- }
611
- },
612
- {
613
- name: "eslint/markdown/processor",
614
- files: [GLOB_MARKDOWN],
615
- languageOptions: {
616
- ecmaVersion: "latest",
617
- parser: parserPlain,
618
- sourceType: "module"
619
- }
620
- },
621
- {
622
- name: "eslint/markdown/disables",
623
- files: [
624
- GLOB_MARKDOWN_CODE,
625
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
626
- ],
627
- languageOptions: {
628
- parserOptions: {
629
- ecmaFeatures: {
630
- impliedStrict: true
631
- }
632
- }
633
- },
634
- rules: {
635
- "no-alert": "off",
636
- "no-console": "off",
637
- "no-undef": "off",
638
- "no-unused-expressions": "off",
639
- "no-unused-vars": "off",
640
- "node/prefer-global/process": "off",
641
- "@typescript-eslint/consistent-type-imports": "off",
642
- "@typescript-eslint/no-namespace": "off",
643
- "@typescript-eslint/no-redeclare": "off",
644
- "@typescript-eslint/no-require-imports": "off",
645
- "@typescript-eslint/no-unused-vars": "off",
646
- "@typescript-eslint/no-use-before-define": "off",
647
- "@typescript-eslint/no-var-requires": "off",
648
- "unicode-bom": "off",
649
- "unused-imports/no-unused-imports": "off",
650
- "unused-imports/no-unused-vars": "off",
651
- "@typescript-eslint/await-thenable": "off",
652
- "@typescript-eslint/dot-notation": "off",
653
- "@typescript-eslint/no-floating-promises": "off",
654
- "@typescript-eslint/no-for-in-array": "off",
655
- "@typescript-eslint/no-implied-eval": "off",
656
- "@typescript-eslint/no-misused-promises": "off",
657
- "@typescript-eslint/no-throw-literal": "off",
658
- "@typescript-eslint/no-unnecessary-type-assertion": "off",
659
- "@typescript-eslint/no-unsafe-argument": "off",
660
- "@typescript-eslint/no-unsafe-assignment": "off",
661
- "@typescript-eslint/no-unsafe-call": "off",
662
- "@typescript-eslint/no-unsafe-member-access": "off",
663
- "@typescript-eslint/no-unsafe-return": "off",
664
- "@typescript-eslint/restrict-plus-operands": "off",
665
- "@typescript-eslint/restrict-template-expressions": "off",
666
- "@typescript-eslint/unbound-method": "off",
667
- ...overrides
668
- }
669
- }
670
- ];
671
- return _markdown;
672
- };
673
-
674
- // src/configs/node.ts
675
- async function node() {
676
- const pluginNode = await interopDefault(import("eslint-plugin-n"));
677
- return [
678
- {
679
- name: "eslint/node/rules",
680
- plugins: {
681
- n: pluginNode
682
- },
683
- rules: {
684
- "n/handle-callback-err": ["error", "^(err|error)$"],
685
- "n/no-deprecated-api": "error",
686
- "n/no-exports-assign": "error",
687
- "n/no-new-require": "error",
688
- "n/no-path-concat": "error",
689
- "n/prefer-global/buffer": ["error", "never"],
690
- "n/prefer-global/process": ["error", "never"],
691
- "n/process-exit-as-throw": "error"
692
- }
693
- }
694
- ];
695
- }
696
-
697
- // src/configs/perfectionist.ts
698
- async function perfectionist() {
699
- const pluginPerfectionist = await interopDefault(
700
- import("eslint-plugin-perfectionist")
701
- );
702
- return [
703
- {
704
- name: "eslint/perfectionist/setup",
705
- plugins: {
706
- perfectionist: pluginPerfectionist
707
- },
708
- rules: {
709
- "perfectionist/sort-exports": [
710
- "error",
711
- { order: "asc", type: "natural" }
712
- ],
713
- "perfectionist/sort-imports": [
714
- "error",
715
- {
716
- groups: [
717
- "builtin",
718
- "external",
719
- "internal",
720
- "parent",
721
- "sibling",
722
- "side-effect",
723
- "side-effect-style",
724
- "index",
725
- "object",
726
- "style",
727
- "builtin-type",
728
- "external-type",
729
- "internal-type",
730
- "parent-type",
731
- "sibling-type",
732
- "index-type",
733
- "type",
734
- "unknown"
735
- ],
736
- newlinesBetween: "never",
737
- order: "asc",
738
- type: "natural"
739
- }
740
- ],
741
- "perfectionist/sort-named-exports": [
742
- "error",
743
- { order: "asc", type: "natural" }
744
- ],
745
- "perfectionist/sort-named-imports": [
746
- "error",
747
- { order: "asc", type: "natural" }
748
- ]
749
- }
750
- }
751
- ];
752
- }
753
-
754
- // src/configs/prettier.ts
755
- var prettier = async ({ tailwindcss: tailwindcss2, ...options }) => {
756
- const [pluginPrettier, configPrettier] = await Promise.all([
757
- interopDefault(import("eslint-plugin-prettier")),
758
- interopDefault(import("eslint-config-prettier"))
759
- ]);
760
- const defaultPrettierOptions = {
761
- quoteProps: "consistent"
762
- };
763
- const plainFileRules = [
764
- {
765
- name: "eslint/prettier/markdown",
766
- files: [GLOB_MARKDOWN],
767
- parser: "markdown"
768
- },
769
- {
770
- name: "eslint/prettier/mdx",
771
- files: [GLOB_MDX],
772
- parser: "mdx"
773
- },
774
- {
775
- name: "eslint/prettier/html",
776
- files: ["**/*.html"],
777
- parser: "html"
778
- },
779
- {
780
- name: "eslint/prettier/css",
781
- files: [GLOB_CSS, GLOB_POSTCSS],
782
- parser: "css"
783
- },
784
- {
785
- name: "eslint/prettier/scss",
786
- files: [GLOB_SCSS],
787
- parser: "scss"
788
- },
789
- {
790
- name: "eslint/prettier/less",
791
- files: [GLOB_LESS],
792
- parser: "less"
793
- },
794
- {
795
- name: "eslint/prettier/yaml",
796
- files: [GLOB_YAML],
797
- parser: "yaml"
798
- },
799
- {
800
- name: "eslint/prettier/graphql",
801
- files: ["**/*.graphql"],
802
- parser: "graphql"
803
- }
804
- ].map((rule) => ({
805
- name: rule.name,
806
- files: rule.files,
807
- languageOptions: {
808
- parser: parserPlain
809
- },
810
- rules: {
811
- "prettier/prettier": [
812
- "warn",
813
- {
814
- parser: rule.parser,
815
- ...defaultPrettierOptions,
816
- ...options
817
- }
818
- ]
819
- }
820
- }));
821
- return [
822
- {
823
- name: "eslint/prettier/setup",
824
- plugins: {
825
- prettier: pluginPrettier
826
- }
827
- },
828
- {
829
- name: "eslint/prettier/rules",
830
- ignores: [GLOB_TOML],
831
- rules: {
832
- // disable rules with prettier conflicts
833
- ...configPrettier.rules,
834
- // eslint-plugin-prettier recommended rules
835
- ...{
836
- "prettier/prettier": "error",
837
- "arrow-body-style": "off",
838
- "prefer-arrow-callback": "off"
839
- },
840
- "prettier/prettier": [
841
- "warn",
842
- {
843
- plugins: tailwindcss2 ? ["prettier-plugin-tailwindcss"] : [],
844
- ...defaultPrettierOptions,
845
- ...options
846
- }
847
- ]
848
- }
849
- },
850
- ...plainFileRules
851
- ];
852
- };
853
-
854
- // src/configs/sort.ts
855
- async function sortPackageJson() {
856
- return [
857
- {
858
- name: "eslint/sort/package-json",
859
- files: ["**/package.json"],
860
- rules: {
861
- "jsonc/sort-array-values": [
862
- "error",
863
- {
864
- order: { type: "asc" },
865
- pathPattern: "^files$"
866
- }
867
- ],
868
- "jsonc/sort-keys": [
869
- "error",
870
- {
871
- order: [
872
- "publisher",
873
- "name",
874
- "displayName",
875
- "type",
876
- "version",
877
- "private",
878
- "packageManager",
879
- "description",
880
- "author",
881
- "license",
882
- "funding",
883
- "homepage",
884
- "repository",
885
- "bugs",
886
- "keywords",
887
- "categories",
888
- "sideEffects",
889
- "exports",
890
- "main",
891
- "module",
892
- "unpkg",
893
- "jsdelivr",
894
- "types",
895
- "typesVersions",
896
- "bin",
897
- "icon",
898
- "files",
899
- "engines",
900
- "activationEvents",
901
- "contributes",
902
- "scripts",
903
- "peerDependencies",
904
- "peerDependenciesMeta",
905
- "dependencies",
906
- "optionalDependencies",
907
- "devDependencies",
908
- "pnpm",
909
- "overrides",
910
- "resolutions",
911
- "husky",
912
- "simple-git-hooks",
913
- "lint-staged",
914
- "eslintConfig"
915
- ],
916
- pathPattern: "^$"
917
- },
918
- {
919
- order: { type: "asc" },
920
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
921
- },
922
- {
923
- order: { type: "asc" },
924
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
925
- },
926
- {
927
- order: ["types", "import", "require", "default"],
928
- pathPattern: "^exports.*$"
929
- }
930
- ]
931
- }
932
- }
933
- ];
934
- }
935
- async function sortTsconfig() {
936
- return [
937
- {
938
- name: "eslint/sort/tsconfig-json",
939
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
940
- rules: {
941
- "jsonc/sort-keys": [
942
- "error",
943
- {
944
- order: [
945
- "extends",
946
- "compilerOptions",
947
- "references",
948
- "files",
949
- "include",
950
- "exclude"
951
- ],
952
- pathPattern: "^$"
953
- },
954
- {
955
- order: [
956
- /* Projects */
957
- "incremental",
958
- "composite",
959
- "tsBuildInfoFile",
960
- "disableSourceOfProjectReferenceRedirect",
961
- "disableSolutionSearching",
962
- "disableReferencedProjectLoad",
963
- /* Language and Environment */
964
- "target",
965
- "jsx",
966
- "jsxFactory",
967
- "jsxFragmentFactory",
968
- "jsxImportSource",
969
- "lib",
970
- "moduleDetection",
971
- "noLib",
972
- "reactNamespace",
973
- "useDefineForClassFields",
974
- "emitDecoratorMetadata",
975
- "experimentalDecorators",
976
- /* Modules */
977
- "baseUrl",
978
- "rootDir",
979
- "rootDirs",
980
- "customConditions",
981
- "module",
982
- "moduleResolution",
983
- "moduleSuffixes",
984
- "noResolve",
985
- "paths",
986
- "resolveJsonModule",
987
- "resolvePackageJsonExports",
988
- "resolvePackageJsonImports",
989
- "typeRoots",
990
- "types",
991
- "allowArbitraryExtensions",
992
- "allowImportingTsExtensions",
993
- "allowUmdGlobalAccess",
994
- /* JavaScript Support */
995
- "allowJs",
996
- "checkJs",
997
- "maxNodeModuleJsDepth",
998
- /* Type Checking */
999
- "strict",
1000
- "strictBindCallApply",
1001
- "strictFunctionTypes",
1002
- "strictNullChecks",
1003
- "strictPropertyInitialization",
1004
- "allowUnreachableCode",
1005
- "allowUnusedLabels",
1006
- "alwaysStrict",
1007
- "exactOptionalPropertyTypes",
1008
- "noFallthroughCasesInSwitch",
1009
- "noImplicitAny",
1010
- "noImplicitOverride",
1011
- "noImplicitReturns",
1012
- "noImplicitThis",
1013
- "noPropertyAccessFromIndexSignature",
1014
- "noUncheckedIndexedAccess",
1015
- "noUnusedLocals",
1016
- "noUnusedParameters",
1017
- "useUnknownInCatchVariables",
1018
- /* Emit */
1019
- "declaration",
1020
- "declarationDir",
1021
- "declarationMap",
1022
- "downlevelIteration",
1023
- "emitBOM",
1024
- "emitDeclarationOnly",
1025
- "importHelpers",
1026
- "importsNotUsedAsValues",
1027
- "inlineSourceMap",
1028
- "inlineSources",
1029
- "mapRoot",
1030
- "newLine",
1031
- "noEmit",
1032
- "noEmitHelpers",
1033
- "noEmitOnError",
1034
- "outDir",
1035
- "outFile",
1036
- "preserveConstEnums",
1037
- "preserveValueImports",
1038
- "removeComments",
1039
- "sourceMap",
1040
- "sourceRoot",
1041
- "stripInternal",
1042
- /* Interop Constraints */
1043
- "allowSyntheticDefaultImports",
1044
- "esModuleInterop",
1045
- "forceConsistentCasingInFileNames",
1046
- "isolatedModules",
1047
- "preserveSymlinks",
1048
- "verbatimModuleSyntax",
1049
- /* Completeness */
1050
- "skipDefaultLibCheck",
1051
- "skipLibCheck"
1052
- ],
1053
- pathPattern: "^compilerOptions$"
1054
- }
1055
- ]
1056
- }
1057
- }
1058
- ];
1059
- }
1060
-
1061
- // src/configs/test.ts
1062
- var test = async (options) => {
1063
- const { overrides = {} } = options;
1064
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1065
- interopDefault(import("@vitest/eslint-plugin")),
1066
- // @ts-expect-error missing types
1067
- interopDefault(import("eslint-plugin-no-only-tests"))
1068
- ]);
1069
- return [
1070
- {
1071
- name: "eslint/test/setup",
1072
- plugins: {
1073
- test: {
1074
- ...pluginVitest,
1075
- rules: {
1076
- ...pluginVitest.rules,
1077
- // extend `test/no-only-tests` rule
1078
- ...pluginNoOnlyTests.rules
1079
- }
1080
- }
1081
- }
1082
- },
1083
- {
1084
- name: "eslint/test/rules",
1085
- files: GLOB_TESTS,
1086
- rules: {
1087
- "node/prefer-global/process": "off",
1088
- "test/consistent-test-it": [
1089
- "error",
1090
- { fn: "it", withinDescribe: "it" }
1091
- ],
1092
- "test/no-identical-title": "error",
1093
- "test/no-import-node-test": "error",
1094
- "test/no-only-tests": "error",
1095
- "test/prefer-hooks-in-order": "error",
1096
- "test/prefer-lowercase-title": "error",
1097
- "@typescript-eslint/explicit-function-return-type": "off",
1098
- ...overrides
1099
- }
1100
- }
1101
- ];
1102
- };
1103
-
1104
- // src/configs/toml.ts
1105
- var toml = async (options) => {
1106
- const { overrides = {} } = options;
1107
- const [pluginToml, parserToml] = await Promise.all([
1108
- interopDefault(import("eslint-plugin-toml")),
1109
- interopDefault(import("toml-eslint-parser"))
1110
- ]);
1111
- return [
1112
- {
1113
- name: "eslint/toml/setup",
1114
- plugins: {
1115
- toml: pluginToml
1116
- }
1117
- },
1118
- {
1119
- name: "eslint/toml/rules",
1120
- files: [GLOB_TOML],
1121
- languageOptions: {
1122
- parser: parserToml
1123
- },
1124
- rules: {
1125
- "toml/comma-style": "error",
1126
- "toml/keys-order": "error",
1127
- "toml/no-space-dots": "error",
1128
- "toml/no-unreadable-number-separator": "error",
1129
- "toml/precision-of-fractional-seconds": "error",
1130
- "toml/precision-of-integer": "error",
1131
- "toml/tables-order": "error",
1132
- "toml/vue-custom-block/no-parsing-error": "error",
1133
- "toml/array-bracket-newline": "error",
1134
- "toml/array-bracket-spacing": "error",
1135
- "toml/array-element-newline": "error",
1136
- "toml/indent": ["error", 2],
1137
- "toml/inline-table-curly-spacing": "error",
1138
- "toml/key-spacing": "error",
1139
- "toml/padding-line-between-pairs": "error",
1140
- "toml/padding-line-between-tables": "error",
1141
- "toml/quoted-keys": "error",
1142
- "toml/spaced-comment": "error",
1143
- "toml/table-bracket-spacing": "error",
1144
- ...overrides
1145
- }
1146
- }
1147
- ];
1148
- };
1149
-
1150
- // src/configs/typescript.ts
1151
- var import_node_process = __toESM(require("process"), 1);
1152
- var typeAwareRules = {
1153
- "dot-notation": "off",
1154
- "no-implied-eval": "off",
1155
- "@typescript-eslint/await-thenable": "error",
1156
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
1157
- "@typescript-eslint/no-floating-promises": "error",
1158
- "@typescript-eslint/no-for-in-array": "error",
1159
- "@typescript-eslint/no-implied-eval": "error",
1160
- "@typescript-eslint/no-misused-promises": "error",
1161
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
1162
- "@typescript-eslint/no-unsafe-argument": "error",
1163
- "@typescript-eslint/no-unsafe-assignment": "error",
1164
- "@typescript-eslint/no-unsafe-call": "error",
1165
- "@typescript-eslint/no-unsafe-member-access": "error",
1166
- "@typescript-eslint/no-unsafe-return": "error",
1167
- "@typescript-eslint/promise-function-async": "error",
1168
- "@typescript-eslint/restrict-plus-operands": "error",
1169
- "@typescript-eslint/restrict-template-expressions": "error",
1170
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
1171
- "@typescript-eslint/strict-boolean-expressions": [
1172
- "error",
1173
- { allowNullableBoolean: true, allowNullableObject: true }
1174
- ],
1175
- "@typescript-eslint/switch-exhaustiveness-check": "error",
1176
- "@typescript-eslint/unbound-method": "error"
1177
- };
1178
- var typescript = async (options) => {
1179
- const {
1180
- overrides = {},
1181
- componentExts = [],
1182
- parserOptions = {},
1183
- tsconfigPath,
1184
- enableSolid = false
1185
- } = options ?? {};
1186
- const isTypeAware = !!tsconfigPath;
1187
- const [pluginTs, parserTs] = await Promise.all([
1188
- interopDefault(import("@typescript-eslint/eslint-plugin")),
1189
- interopDefault(import("@typescript-eslint/parser"))
1190
- ]);
1191
- return [
1192
- {
1193
- // Install the plugins without globs, so they can be configured separately.
1194
- name: "eslint/typescript/setup",
1195
- plugins: {
1196
- "@typescript-eslint": pluginTs,
1197
- ...enableSolid ? {
1198
- solid: await interopDefault(import("eslint-plugin-solid"))
1199
- } : {}
1200
- }
1201
- },
1202
- {
1203
- name: "eslint/typescript/rules",
1204
- files: [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)],
1205
- languageOptions: {
1206
- parser: parserTs,
1207
- parserOptions: {
1208
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1209
- sourceType: "module",
1210
- ...tsconfigPath ? {
1211
- project: [tsconfigPath],
1212
- tsconfigRootDir: import_node_process.default.cwd()
1213
- } : {},
1214
- ...parserOptions
1215
- }
1216
- },
1217
- rules: {
1218
- ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
1219
- ...pluginTs.configs.strict.rules,
1220
- ...enableSolid ? {
1221
- "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
1222
- "solid/no-unknown-namespaces": "off"
1223
- } : {},
1224
- "no-dupe-class-members": "off",
1225
- "no-redeclare": "off",
1226
- "no-use-before-define": "off",
1227
- "no-useless-constructor": "off",
1228
- "@typescript-eslint/ban-ts-comment": [
1229
- "error",
1230
- { "ts-expect-error": "allow-with-description" }
1231
- ],
1232
- "@typescript-eslint/consistent-type-definitions": [
1233
- "error",
1234
- "interface"
1235
- ],
1236
- "@typescript-eslint/consistent-type-imports": [
1237
- "error",
1238
- {
1239
- disallowTypeAnnotations: false,
1240
- fixStyle: "separate-type-imports",
1241
- prefer: "type-imports"
1242
- }
1243
- ],
1244
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1245
- "@typescript-eslint/method-signature-style": ["error", "property"],
1246
- "@typescript-eslint/no-dupe-class-members": "error",
1247
- "@typescript-eslint/no-dynamic-delete": "off",
1248
- "@typescript-eslint/no-empty-object-type": [
1249
- "error",
1250
- { allowInterfaces: "always" }
1251
- ],
1252
- "@typescript-eslint/no-explicit-any": "off",
1253
- "@typescript-eslint/no-extraneous-class": "off",
1254
- "@typescript-eslint/no-import-type-side-effects": "error",
1255
- "@typescript-eslint/no-invalid-void-type": "off",
1256
- "@typescript-eslint/no-non-null-assertion": "off",
1257
- "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
1258
- "@typescript-eslint/no-require-imports": "error",
1259
- "@typescript-eslint/no-unused-expressions": [
1260
- "error",
1261
- {
1262
- allowShortCircuit: true,
1263
- allowTaggedTemplates: true,
1264
- allowTernary: true
1265
- }
1266
- ],
1267
- "@typescript-eslint/no-unused-vars": "off",
1268
- "@typescript-eslint/no-use-before-define": [
1269
- "error",
1270
- { classes: false, functions: false, variables: true }
1271
- ],
1272
- "@typescript-eslint/no-useless-constructor": "off",
1273
- "@typescript-eslint/no-wrapper-object-types": "error",
1274
- "@typescript-eslint/triple-slash-reference": "off",
1275
- "@typescript-eslint/unified-signatures": "off",
1276
- ...overrides
1277
- }
1278
- },
1279
- ...isTypeAware ? [
1280
- {
1281
- name: "eslint/typescript/rules-type-aware",
1282
- files: [GLOB_TS, GLOB_TSX],
1283
- ignores: [`${GLOB_MARKDOWN}/**`, `${GLOB_ASTRO_TS}/**`],
1284
- rules: {
1285
- ...typeAwareRules
1286
- }
1287
- }
1288
- ] : [],
1289
- {
1290
- name: "eslint/typescript/dts-overrides",
1291
- files: ["**/*.d.ts"],
1292
- rules: {
1293
- "eslint-comments/no-unlimited-disable": "off",
1294
- "import/no-duplicates": "off",
1295
- "no-restricted-syntax": "off",
1296
- "unused-imports/no-unused-vars": "off"
1297
- }
1298
- },
1299
- {
1300
- name: "eslint/typescript/disables/test",
1301
- files: ["**/*.{test,spec}.ts?(x)"],
1302
- rules: {
1303
- "no-unused-expressions": "off"
1304
- }
1305
- },
1306
- {
1307
- name: "eslint/typescript/disables/cjs",
1308
- files: ["**/*.js", "**/*.cjs"],
1309
- rules: {
1310
- "@typescript-eslint/no-require-imports": "off",
1311
- "@typescript-eslint/no-var-requires": "off"
1312
- }
1313
- }
1314
- ];
1315
- };
1316
-
1317
- // src/configs/unicorn.ts
1318
- async function unicorn() {
1319
- const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
1320
- return [
1321
- {
1322
- name: "eslint/unicorn/rules",
1323
- plugins: {
1324
- unicorn: pluginUnicorn
1325
- },
1326
- rules: {
1327
- "unicorn/consistent-empty-array-spread": "error",
1328
- "unicorn/escape-case": "error",
1329
- "unicorn/new-for-builtins": "error",
1330
- // Pass error message when throwing errors
1331
- "unicorn/error-message": "error",
1332
- // Uppercase regex escapes
1333
- "unicorn/consistent-function-scoping": [
1334
- "error",
1335
- { checkArrowFunctions: false }
1336
- ],
1337
- "unicorn/no-instanceof-builtins": "error",
1338
- // Ban `new Array` as `Array` constructor's params are ambiguous
1339
- "unicorn/no-new-array": "error",
1340
- // Prevent deprecated `new Buffer()`
1341
- "unicorn/no-new-buffer": "error",
1342
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1343
- "unicorn/number-literal-case": "error",
1344
- // textContent instead of innerText
1345
- "unicorn/prefer-dom-node-text-content": "error",
1346
- // includes over indexOf when checking for existence
1347
- "unicorn/prefer-includes": "error",
1348
- // Prefer using the node: protocol
1349
- "unicorn/prefer-node-protocol": "error",
1350
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1351
- "unicorn/prefer-number-properties": "error",
1352
- // String methods startsWith/endsWith instead of more complicated stuff
1353
- "unicorn/prefer-string-starts-ends-with": "error",
1354
- // Enforce throwing type error when throwing error while checking typeof
1355
- "unicorn/prefer-type-error": "error",
1356
- // Use new when throwing error
1357
- "unicorn/throw-new-error": "error"
1358
- }
1359
- }
1360
- ];
1361
- }
1362
-
1363
- // src/configs/vue.ts
1364
- var vue = async (options = {}) => {
1365
- const { overrides = {}, typescript: isTypescript } = options;
1366
- const [pluginVue, parserVue] = await Promise.all([
1367
- interopDefault(import("eslint-plugin-vue")),
1368
- interopDefault(import("vue-eslint-parser"))
1369
- ]);
1370
- return [
1371
- {
1372
- name: "eslint/vue/setup",
1373
- plugins: {
1374
- vue: pluginVue
1375
- }
1376
- },
1377
- {
1378
- name: "eslint/vue/rules",
1379
- files: [GLOB_VUE],
1380
- languageOptions: {
1381
- parser: parserVue,
1382
- parserOptions: {
1383
- ecmaFeatures: {
1384
- jsx: true
1385
- },
1386
- extraFileExtensions: [".vue"],
1387
- parser: isTypescript ? await interopDefault(
1388
- import("@typescript-eslint/parser")
1389
- ) : null,
1390
- sourceType: "module"
1391
- }
1392
- },
1393
- processor: pluginVue.processors[".vue"],
1394
- rules: {
1395
- ...pluginVue.configs.base.rules,
1396
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
1397
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
1398
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
1399
- "node/prefer-global/process": "off",
1400
- "vue/block-order": [
1401
- "error",
1402
- {
1403
- order: ["script", "template", "style"]
1404
- }
1405
- ],
1406
- "vue/component-name-in-template-casing": [
1407
- "error",
1408
- "PascalCase",
1409
- {
1410
- registeredComponentsOnly: false
1411
- }
1412
- ],
1413
- "vue/component-options-name-casing": ["error", "PascalCase"],
1414
- "vue/custom-event-name-casing": ["error", "camelCase"],
1415
- "vue/define-macros-order": [
1416
- "error",
1417
- {
1418
- order: [
1419
- "defineOptions",
1420
- "defineProps",
1421
- "defineEmits",
1422
- "defineSlots"
1423
- ]
1424
- }
1425
- ],
1426
- "vue/dot-location": ["error", "property"],
1427
- "vue/dot-notation": ["error", { allowKeywords: true }],
1428
- "vue/eqeqeq": ["error", "smart"],
1429
- "vue/html-indent": ["error", 2],
1430
- "vue/html-quotes": ["error", "double"],
1431
- "vue/max-attributes-per-line": "off",
1432
- "vue/multi-word-component-names": "off",
1433
- "vue/no-dupe-keys": "off",
1434
- "vue/no-empty-pattern": "error",
1435
- "vue/no-irregular-whitespace": "error",
1436
- "vue/no-loss-of-precision": "error",
1437
- "vue/no-restricted-syntax": [
1438
- "error",
1439
- "DebuggerStatement",
1440
- "LabeledStatement",
1441
- "WithStatement"
1442
- ],
1443
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1444
- "vue/no-setup-props-reactivity-loss": "off",
1445
- "vue/no-sparse-arrays": "error",
1446
- "vue/no-unused-refs": "error",
1447
- "vue/no-useless-v-bind": "error",
1448
- "vue/no-v-html": "off",
1449
- "vue/object-shorthand": [
1450
- "error",
1451
- "always",
1452
- {
1453
- avoidQuotes: true,
1454
- ignoreConstructors: false
1455
- }
1456
- ],
1457
- "vue/prefer-separate-static-class": "error",
1458
- "vue/prefer-template": "error",
1459
- "vue/require-default-prop": "off",
1460
- "vue/require-prop-types": "off",
1461
- "vue/space-infix-ops": "error",
1462
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1463
- "vue/array-bracket-spacing": ["error", "never"],
1464
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1465
- "vue/block-spacing": ["error", "always"],
1466
- "vue/block-tag-newline": [
1467
- "error",
1468
- {
1469
- multiline: "always",
1470
- singleline: "always"
1471
- }
1472
- ],
1473
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1474
- "vue/comma-dangle": ["error", "always-multiline"],
1475
- "vue/comma-spacing": ["error", { after: true, before: false }],
1476
- "vue/comma-style": ["error", "last"],
1477
- "vue/html-comment-content-spacing": [
1478
- "error",
1479
- "always",
1480
- {
1481
- exceptions: ["-"]
1482
- }
1483
- ],
1484
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1485
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1486
- "vue/object-curly-newline": "off",
1487
- "vue/object-curly-spacing": ["error", "always"],
1488
- "vue/object-property-newline": [
1489
- "error",
1490
- { allowMultiplePropertiesPerLine: true }
1491
- ],
1492
- "vue/operator-linebreak": ["error", "before"],
1493
- "vue/padding-line-between-blocks": ["error", "always"],
1494
- "vue/quote-props": ["error", "consistent-as-needed"],
1495
- "vue/space-in-parens": ["error", "never"],
1496
- "vue/template-curly-spacing": "error",
1497
- ...overrides
1498
- }
1499
- }
1500
- ];
1501
- };
1502
-
1503
- // src/configs/yml.ts
1504
- var yml = async (options) => {
1505
- const { overrides = {} } = options;
1506
- const [pluginYml, parserYml] = await Promise.all([
1507
- interopDefault(import("eslint-plugin-yml")),
1508
- interopDefault(import("yaml-eslint-parser"))
1509
- ]);
1510
- return [
1511
- {
1512
- name: "eslint/yaml/setup",
1513
- plugins: {
1514
- yml: pluginYml
1515
- }
1516
- },
1517
- {
1518
- name: "eslint/yaml/rules",
1519
- files: [GLOB_YAML],
1520
- languageOptions: {
1521
- parser: parserYml
1522
- },
1523
- rules: {
1524
- ...pluginYml.configs.standard.rules,
1525
- ...pluginYml.configs.prettier.rules,
1526
- "yml/block-mapping": "error",
1527
- "yml/block-sequence": "error",
1528
- "yml/no-empty-key": "error",
1529
- "yml/no-empty-sequence-entry": "error",
1530
- "yml/no-irregular-whitespace": "error",
1531
- "yml/plain-scalar": "error",
1532
- "yml/vue-custom-block/no-parsing-error": "error",
1533
- "yml/spaced-comment": "error",
1534
- ...overrides
1535
- }
1536
- }
1537
- ];
1538
- };
1539
-
1540
- // src/configs/react.ts
1541
- async function next() {
1542
- const pluginNext = await interopDefault(import("@next/eslint-plugin-next"));
1543
- return [
1544
- {
1545
- name: "eslint/next/setup",
1546
- plugins: {
1547
- "@next/next": pluginNext
1548
- }
1549
- },
1550
- {
1551
- name: "eslint/next/rules",
1552
- files: [GLOB_TSX, GLOB_JSX],
1553
- languageOptions: {
1554
- parserOptions: {
1555
- sourceType: "module",
1556
- ecmaFeatures: {
1557
- jsx: true
1558
- }
1559
- }
1560
- },
1561
- settings: {
1562
- react: {
1563
- version: "detect"
1564
- }
1565
- },
1566
- rules: {
1567
- ...pluginNext.configs.recommended.rules,
1568
- ...pluginNext.configs["core-web-vitals"].rules,
1569
- "react-refresh/only-export-components": [
1570
- "warn",
1571
- {
1572
- allowExportNames: [
1573
- "dynamic",
1574
- "dynamicParams",
1575
- "revalidate",
1576
- "fetchCache",
1577
- "runtime",
1578
- "preferredRegion",
1579
- "maxDuration",
1580
- "config",
1581
- "generateStaticParams",
1582
- "metadata",
1583
- "generateMetadata",
1584
- "viewport",
1585
- "generateViewport"
1586
- ]
1587
- }
1588
- ]
1589
- }
1590
- }
1591
- ];
1592
- }
1593
- var react = async (options) => {
1594
- const {
1595
- next: enableNext = false,
1596
- compiler: enableCompiler = false,
1597
- overrides = {}
1598
- } = options;
1599
- const [pluginsReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1600
- interopDefault(import("@eslint-react/eslint-plugin")),
1601
- interopDefault(import("eslint-plugin-react-hooks")),
1602
- interopDefault(import("eslint-plugin-react-refresh"))
1603
- ]);
1604
- const plugins = pluginsReact.configs.all.plugins;
1605
- const {
1606
- "@eslint-react": pluginReactX,
1607
- "@eslint-react/dom": pluginReactDom,
1608
- "@eslint-react/hooks-extra": pluginReactHooksExtra,
1609
- "@eslint-react/naming-convention": pluginReactNamingConvention,
1610
- "@eslint-react/web-api": pluginReactWebApi
1611
- } = plugins;
1612
- const _react = [
1613
- {
1614
- name: "eslint/react/setup",
1615
- plugins: {
1616
- "react": pluginReactX,
1617
- "react-dom": pluginReactDom,
1618
- "react-hooks-extra": pluginReactHooksExtra,
1619
- "react-naming-convention": pluginReactNamingConvention,
1620
- "react-web-api": pluginReactWebApi,
1621
- "react-hooks": pluginReactHooks,
1622
- "react-refresh": pluginReactRefresh,
1623
- ...enableCompiler ? {
1624
- "react-compiler": await interopDefault(
1625
- // @ts-expect-error missing types
1626
- import("eslint-plugin-react-compiler")
1627
- )
1628
- } : {}
1629
- }
1630
- },
1631
- {
1632
- name: "eslint/react/rules",
1633
- files: [GLOB_TSX, GLOB_JSX],
1634
- languageOptions: {
1635
- parserOptions: {
1636
- sourceType: "module",
1637
- ecmaFeatures: {
1638
- jsx: true
1639
- }
1640
- }
1641
- },
1642
- settings: {
1643
- react: {
1644
- version: "detect"
1645
- }
1646
- },
1647
- rules: {
1648
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1649
- "react/jsx-no-duplicate-props": "warn",
1650
- "react/jsx-uses-vars": "warn",
1651
- "react/no-access-state-in-setstate": "error",
1652
- "react/no-array-index-key": "warn",
1653
- "react/no-children-count": "warn",
1654
- "react/no-children-for-each": "warn",
1655
- "react/no-children-map": "warn",
1656
- "react/no-children-only": "warn",
1657
- "react/no-children-to-array": "warn",
1658
- "react/no-clone-element": "warn",
1659
- "react/no-comment-textnodes": "warn",
1660
- "react/no-component-will-mount": "error",
1661
- "react/no-component-will-receive-props": "error",
1662
- "react/no-component-will-update": "error",
1663
- "react/no-context-provider": "warn",
1664
- "react/no-create-ref": "error",
1665
- "react/no-default-props": "error",
1666
- "react/no-direct-mutation-state": "error",
1667
- "react/no-duplicate-key": "warn",
1668
- "react/no-forward-ref": "warn",
1669
- "react/no-implicit-key": "warn",
1670
- "react/no-missing-key": "error",
1671
- "react/no-nested-component-definitions": "error",
1672
- "react/no-prop-types": "error",
1673
- "react/no-redundant-should-component-update": "error",
1674
- "react/no-set-state-in-component-did-mount": "warn",
1675
- "react/no-set-state-in-component-did-update": "warn",
1676
- "react/no-set-state-in-component-will-update": "warn",
1677
- "react/no-string-refs": "error",
1678
- "react/no-unsafe-component-will-mount": "warn",
1679
- "react/no-unsafe-component-will-receive-props": "warn",
1680
- "react/no-unsafe-component-will-update": "warn",
1681
- "react/no-unstable-context-value": "warn",
1682
- "react/no-unstable-default-props": "warn",
1683
- "react/no-unused-class-component-members": "warn",
1684
- "react/no-unused-state": "warn",
1685
- "react/no-use-context": "warn",
1686
- "react/no-useless-forward-ref": "warn",
1687
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1688
- "react-dom/no-dangerously-set-innerhtml": "warn",
1689
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1690
- "react-dom/no-find-dom-node": "error",
1691
- "react-dom/no-flush-sync": "error",
1692
- "react-dom/no-hydrate": "error",
1693
- "react-dom/no-missing-button-type": "warn",
1694
- "react-dom/no-missing-iframe-sandbox": "warn",
1695
- "react-dom/no-namespace": "error",
1696
- "react-dom/no-render": "error",
1697
- "react-dom/no-render-return-value": "error",
1698
- "react-dom/no-script-url": "warn",
1699
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1700
- "react-dom/no-unsafe-target-blank": "warn",
1701
- "react-dom/no-use-form-state": "error",
1702
- "react-dom/no-void-elements-with-children": "error",
1703
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1704
- "react-hooks/exhaustive-deps": "warn",
1705
- "react-hooks/rules-of-hooks": "error",
1706
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1707
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1708
- "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1709
- "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1710
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1711
- "react-web-api/no-leaked-event-listener": "warn",
1712
- "react-web-api/no-leaked-interval": "warn",
1713
- "react-web-api/no-leaked-resize-observer": "warn",
1714
- "react-web-api/no-leaked-timeout": "warn",
1715
- // React Refresh
1716
- "react-refresh/only-export-components": "warn",
1717
- // React Compiler
1718
- ...enableCompiler ? {
1719
- "react-compiler/react-compiler": "error"
1720
- } : {},
1721
- "jsx-quotes": ["error", "prefer-double"],
1722
- "react/react-in-jsx-scope": "off",
1723
- "react/jsx-indent": [1, 2],
1724
- "react/jsx-indent-props": [1, 2],
1725
- "react/jsx-closing-bracket-location": [
1726
- 1,
1727
- { selfClosing: "tag-aligned", nonEmpty: "tag-aligned" }
1728
- ],
1729
- ...overrides
1730
- }
1731
- }
1732
- ];
1733
- return combine(_react, enableNext ? next() : []);
1734
- };
1735
-
1736
- // src/configs/tailwindcss.ts
1737
- async function tailwindcss() {
1738
- const pluginTailwindcss = await interopDefault(
1739
- // @ts-expect-error missing types
1740
- import("eslint-plugin-tailwindcss")
1741
- );
1742
- return [
1743
- {
1744
- name: "eslint/tailwindcss/rules",
1745
- plugins: {
1746
- tailwindcss: pluginTailwindcss
1747
- },
1748
- rules: {
1749
- ...pluginTailwindcss.configs.recommended.rules
1750
- }
1751
- }
1752
- ];
1753
- }
1754
-
1755
- // src/factory.ts
1756
- function defineConfig(options = {}, ...userConfigs) {
1757
- const {
1758
- ignores: enableIgnores = true,
1759
- vue: enableVue,
1760
- react: enableReact,
1761
- solid: enableSolid,
1762
- typescript: enableTypeScript,
1763
- tailwindcss: enableTailwindcss,
1764
- componentExts = []
1765
- } = options;
1766
- const configs = [];
1767
- configs.push(
1768
- ignores(getConfigOptions(enableIgnores)),
1769
- javascript(options.javascript ?? {}),
1770
- comments(),
1771
- node(),
1772
- jsdoc(),
1773
- imports(),
1774
- unicorn(),
1775
- perfectionist()
1776
- );
1777
- if (enableVue) componentExts.push("vue");
1778
- if (enableTypeScript) {
1779
- configs.push(
1780
- typescript({
1781
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1782
- enableSolid,
1783
- componentExts
1784
- })
1785
- );
1786
- }
1787
- if (options.test ?? true) {
1788
- configs.push(test(getConfigOptions(options.test)));
1789
- }
1790
- if (enableVue) {
1791
- configs.push(
1792
- vue({
1793
- ...getConfigOptions(options.vue),
1794
- typescript: !!enableTypeScript
1795
- })
1796
- );
1797
- }
1798
- if (enableReact) {
1799
- configs.push(react(getConfigOptions(enableReact)));
1800
- }
1801
- if (options.jsonc ?? true) {
1802
- configs.push(
1803
- jsonc(getConfigOptions(options.jsonc)),
1804
- sortPackageJson(),
1805
- sortTsconfig()
1806
- );
1807
- }
1808
- if (options.yml ?? true) {
1809
- configs.push(yml(getConfigOptions(options.yml)));
1810
- }
1811
- if (options.toml ?? true) {
1812
- configs.push(toml(getConfigOptions(options.toml)));
1813
- }
1814
- if (options.markdown ?? true) {
1815
- configs.push(
1816
- markdown({
1817
- ...getConfigOptions(options.markdown),
1818
- componentExts
1819
- })
1820
- );
1821
- }
1822
- if (typeof enableTailwindcss === "boolean" && enableTailwindcss) {
1823
- configs.push(tailwindcss());
1824
- }
1825
- if (options.prettier ?? true) {
1826
- configs.push(
1827
- prettier({
1828
- ...getConfigOptions(options.prettier),
1829
- tailwindcss: enableTailwindcss === "prettier"
1830
- })
1831
- );
1832
- }
1833
- const merged = combine(...configs, ...userConfigs);
1834
- return merged;
1835
- }
1836
-
1837
- // src/index.ts
1838
- var index_default = defineConfig;
1839
- // Annotate the CommonJS export names for ESM import in node:
1840
- 0 && (module.exports = {
1841
- GLOB_ALL_SRC,
1842
- GLOB_ASTRO_TS,
1843
- GLOB_CSS,
1844
- GLOB_EXCLUDE,
1845
- GLOB_HTML,
1846
- GLOB_JS,
1847
- GLOB_JSON,
1848
- GLOB_JSON5,
1849
- GLOB_JSONC,
1850
- GLOB_JSX,
1851
- GLOB_LESS,
1852
- GLOB_MARKDOWN,
1853
- GLOB_MARKDOWN_CODE,
1854
- GLOB_MDX,
1855
- GLOB_POSTCSS,
1856
- GLOB_SCSS,
1857
- GLOB_SRC,
1858
- GLOB_SRC_EXT,
1859
- GLOB_STYLE,
1860
- GLOB_TESTS,
1861
- GLOB_TOML,
1862
- GLOB_TS,
1863
- GLOB_TSX,
1864
- GLOB_VUE,
1865
- GLOB_YAML,
1866
- combine,
1867
- comments,
1868
- defineConfig,
1869
- getConfigOptions,
1870
- ignores,
1871
- imports,
1872
- interopDefault,
1873
- javascript,
1874
- jsdoc,
1875
- jsonc,
1876
- markdown,
1877
- node,
1878
- parserPlain,
1879
- perfectionist,
1880
- prettier,
1881
- sortPackageJson,
1882
- sortTsconfig,
1883
- test,
1884
- toml,
1885
- typescript,
1886
- unicorn,
1887
- vue,
1888
- yml
1889
- });