@ivanmaxlogiudice/eslint-config 1.0.0-beta.9 → 1.0.6

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