@frabbit/eslint-config 1.2.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.js ADDED
@@ -0,0 +1,1023 @@
1
+ // src/plugins.ts
2
+ import * as _pluginAntfu from "eslint-plugin-antfu";
3
+ import * as _pluginComments from "eslint-plugin-eslint-comments";
4
+ import * as _pluginMarkdown from "eslint-plugin-markdown";
5
+ import * as _pluginTypeScript from "@typescript-eslint/eslint-plugin";
6
+ import * as _pluginUnicorn from "eslint-plugin-unicorn";
7
+ import * as _pluginVue from "eslint-plugin-vue";
8
+ import * as _pluginUnocss from "@unocss/eslint-plugin";
9
+ import * as _pluginPrettier from "eslint-plugin-prettier";
10
+ import * as _configPrettier from "eslint-config-prettier";
11
+ import * as pluginImport from "eslint-plugin-i";
12
+ import * as pluginJsonc from "eslint-plugin-jsonc";
13
+ import * as pluginUnusedImports from "eslint-plugin-unused-imports";
14
+ import * as pluginYml from "eslint-plugin-yml";
15
+ import * as parserTypeScript from "@typescript-eslint/parser";
16
+ import * as parserVue from "vue-eslint-parser";
17
+ import * as parserYml from "yaml-eslint-parser";
18
+ import * as parserJsonc from "jsonc-eslint-parser";
19
+ // @__NO_SIDE_EFFECTS__
20
+ function interopDefault(m) {
21
+ return m.default || m;
22
+ }
23
+ var pluginAntfu = /* @__PURE__ */ interopDefault(_pluginAntfu);
24
+ var pluginComments = /* @__PURE__ */ interopDefault(_pluginComments);
25
+ var pluginMarkdown = /* @__PURE__ */ interopDefault(_pluginMarkdown);
26
+ var pluginTypeScript = /* @__PURE__ */ interopDefault(_pluginTypeScript);
27
+ var pluginUnicorn = /* @__PURE__ */ interopDefault(_pluginUnicorn);
28
+ var pluginVue = /* @__PURE__ */ interopDefault(_pluginVue);
29
+ var pluginUnocss = /* @__PURE__ */ interopDefault(_pluginUnocss);
30
+ var pluginPrettier = /* @__PURE__ */ interopDefault(_pluginPrettier);
31
+ var configPrettier = /* @__PURE__ */ interopDefault(_configPrettier);
32
+
33
+ // src/configs/comments.ts
34
+ var comments = [
35
+ {
36
+ plugins: {
37
+ "eslint-comments": pluginComments
38
+ },
39
+ rules: {
40
+ ...pluginComments.configs.recommended.rules,
41
+ "eslint-comments/disable-enable-pair": [
42
+ "error",
43
+ { allowWholeFile: true }
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_ALL_SRC = [
68
+ GLOB_SRC,
69
+ GLOB_STYLE,
70
+ GLOB_JSON,
71
+ GLOB_JSON5,
72
+ GLOB_MARKDOWN,
73
+ GLOB_VUE,
74
+ GLOB_YAML,
75
+ GLOB_HTML
76
+ ];
77
+ var GLOB_NODE_MODULES = "**/node_modules";
78
+ var GLOB_DIST = "**/dist";
79
+ var GLOB_LOCKFILE = [
80
+ "**/package-lock.json",
81
+ "**/yarn.lock",
82
+ "**/pnpm-lock.yaml"
83
+ ];
84
+ var GLOB_EXCLUDE = [
85
+ GLOB_NODE_MODULES,
86
+ GLOB_DIST,
87
+ ...GLOB_LOCKFILE,
88
+ "**/output",
89
+ "**/coverage",
90
+ "**/temp",
91
+ "**/fixtures",
92
+ "**/.vitepress/cache",
93
+ "**/.nuxt",
94
+ "**/.vercel",
95
+ "**/.changeset",
96
+ "**/.idea",
97
+ "**/.output",
98
+ "**/.vite-inspect",
99
+ "**/CHANGELOG*.md",
100
+ "**/*.min.*",
101
+ "**/LICENSE*",
102
+ "**/__snapshots__",
103
+ "**/auto-import?(s).d.ts",
104
+ "**/components.d.ts"
105
+ ];
106
+
107
+ // src/configs/ignores.ts
108
+ var ignores = [{ ignores: GLOB_EXCLUDE }];
109
+
110
+ // src/configs/imports.ts
111
+ var imports = [
112
+ {
113
+ plugins: {
114
+ antfu: pluginAntfu,
115
+ import: pluginImport
116
+ },
117
+ rules: {
118
+ "antfu/import-dedupe": "error",
119
+ "antfu/prefer-inline-type-import": "error",
120
+ "import/first": "error",
121
+ "import/newline-after-import": ["error", { count: 1 }],
122
+ "import/no-default-export": "error",
123
+ "import/no-duplicates": "error",
124
+ "import/no-mutable-exports": "error",
125
+ "import/no-named-default": "error",
126
+ "import/no-self-import": "error",
127
+ "import/no-webpack-loader-syntax": "error",
128
+ "import/order": [
129
+ "error",
130
+ {
131
+ alphabetize: { caseInsensitive: true, order: "asc" },
132
+ groups: [
133
+ "builtin",
134
+ "external",
135
+ "internal",
136
+ "parent",
137
+ "sibling",
138
+ "index",
139
+ "object",
140
+ "type"
141
+ ],
142
+ "newlines-between": "always",
143
+ pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
144
+ pathGroupsExcludedImportTypes: ["type"]
145
+ }
146
+ ]
147
+ }
148
+ },
149
+ {
150
+ files: [
151
+ `**/*config*.${GLOB_SRC_EXT}`,
152
+ `**/views/${GLOB_SRC}`,
153
+ `**/pages/${GLOB_SRC}`,
154
+ `**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
155
+ "**/*.d.ts",
156
+ `${GLOB_MARKDOWN}/**`
157
+ ],
158
+ plugins: {
159
+ import: pluginImport
160
+ },
161
+ rules: {
162
+ "import/no-default-export": "off"
163
+ }
164
+ }
165
+ ];
166
+
167
+ // src/configs/javascript.ts
168
+ import globals from "globals";
169
+
170
+ // src/env.ts
171
+ import process2 from "node:process";
172
+ import { isPackageExists } from "local-pkg";
173
+ var isInEditor = (process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI;
174
+ var hasTypeScript = isPackageExists("typescript");
175
+ var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli");
176
+
177
+ // src/configs/javascript.ts
178
+ var javascript = [
179
+ {
180
+ languageOptions: {
181
+ globals: {
182
+ ...globals.browser,
183
+ ...globals.es2021,
184
+ ...globals.node
185
+ },
186
+ parserOptions: {
187
+ ecmaFeatures: {
188
+ jsx: true
189
+ },
190
+ sourceType: "module"
191
+ },
192
+ sourceType: "module"
193
+ },
194
+ plugins: {
195
+ "unused-imports": pluginUnusedImports
196
+ },
197
+ rules: {
198
+ "array-callback-return": "error",
199
+ "block-scoped-var": "error",
200
+ "class-methods-use-this": "error",
201
+ "constructor-super": "error",
202
+ "dot-notation": "warn",
203
+ eqeqeq: ["error", "smart"],
204
+ "for-direction": "error",
205
+ "getter-return": "error",
206
+ "no-alert": "warn",
207
+ "no-async-promise-executor": "error",
208
+ "no-await-in-loop": "error",
209
+ "no-case-declarations": "error",
210
+ "no-class-assign": "error",
211
+ "no-compare-neg-zero": "error",
212
+ "no-cond-assign": "error",
213
+ "no-console": ["warn", { allow: ["warn", "error"] }],
214
+ "no-const-assign": "error",
215
+ "no-constant-condition": "error",
216
+ "no-control-regex": "error",
217
+ "no-debugger": "warn",
218
+ "no-delete-var": "error",
219
+ "no-dupe-args": "error",
220
+ "no-dupe-class-members": "error",
221
+ "no-dupe-else-if": "error",
222
+ "no-dupe-keys": "error",
223
+ "no-duplicate-case": "error",
224
+ "no-duplicate-imports": "error",
225
+ "no-else-return": "error",
226
+ "no-empty": ["error", { allowEmptyCatch: true }],
227
+ "no-empty-character-class": "error",
228
+ "no-empty-pattern": "error",
229
+ "no-ex-assign": "error",
230
+ "no-extend-native": "error",
231
+ "no-extra-bind": "error",
232
+ "no-extra-boolean-cast": "error",
233
+ "no-extra-label": "error",
234
+ "no-fallthrough": ["warn", { commentPattern: "break[\\s\\w]*omitted" }],
235
+ "no-func-assign": "error",
236
+ "no-global-assign": "error",
237
+ "no-import-assign": "error",
238
+ "no-inner-declarations": "error",
239
+ "no-invalid-regexp": "error",
240
+ "no-irregular-whitespace": "error",
241
+ "no-lonely-if": "error",
242
+ "no-loop-func": "error",
243
+ "no-loss-of-precision": "error",
244
+ "no-misleading-character-class": "error",
245
+ "no-mixed-spaces-and-tabs": "error",
246
+ "no-multi-str": "error",
247
+ "no-new-symbol": "error",
248
+ "no-nonoctal-decimal-escape": "error",
249
+ "no-obj-calls": "error",
250
+ "no-octal": "error",
251
+ "no-octal-escape": "error",
252
+ "no-param-reassign": "error",
253
+ "no-proto": "error",
254
+ "no-prototype-builtins": "error",
255
+ "no-redeclare": "error",
256
+ "no-regex-spaces": "error",
257
+ "no-restricted-syntax": [
258
+ "error",
259
+ "ForInStatement",
260
+ "LabeledStatement",
261
+ "WithStatement"
262
+ ],
263
+ "no-return-await": "warn",
264
+ "no-self-assign": "error",
265
+ "no-setter-return": "error",
266
+ "no-shadow-restricted-names": "error",
267
+ "no-sparse-arrays": "error",
268
+ "no-this-before-super": "error",
269
+ "no-undef": "error",
270
+ "no-undef-init": "error",
271
+ "no-unexpected-multiline": "error",
272
+ "no-unneeded-ternary": "error",
273
+ "no-unreachable": "error",
274
+ "no-unsafe-finally": "error",
275
+ "no-unsafe-negation": "error",
276
+ "no-unsafe-optional-chaining": "error",
277
+ "no-unused-expressions": [
278
+ "error",
279
+ {
280
+ allowShortCircuit: true,
281
+ allowTaggedTemplates: true,
282
+ allowTernary: true
283
+ }
284
+ ],
285
+ "no-unused-labels": "error",
286
+ "no-unused-vars": "off",
287
+ "no-useless-backreference": "error",
288
+ "no-useless-call": "error",
289
+ "no-useless-catch": "error",
290
+ "no-useless-escape": "error",
291
+ "no-useless-return": "error",
292
+ "no-void": "error",
293
+ "no-with": "error",
294
+ "object-shorthand": [
295
+ "error",
296
+ "always",
297
+ { avoidQuotes: true, ignoreConstructors: false }
298
+ ],
299
+ "prefer-arrow-callback": [
300
+ "error",
301
+ { allowNamedFunctions: false, allowUnboundThis: true }
302
+ ],
303
+ "prefer-const": [
304
+ "warn",
305
+ { destructuring: "all", ignoreReadBeforeAssign: true }
306
+ ],
307
+ "prefer-exponentiation-operator": "error",
308
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
309
+ "prefer-rest-params": "error",
310
+ "prefer-spread": "error",
311
+ "prefer-template": "error",
312
+ "require-atomic-updates": "error",
313
+ "require-await": "error",
314
+ "require-yield": "error",
315
+ "sort-imports": [
316
+ "error",
317
+ {
318
+ allowSeparatedGroups: false,
319
+ ignoreCase: false,
320
+ ignoreDeclarationSort: true,
321
+ ignoreMemberSort: false,
322
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
323
+ }
324
+ ],
325
+ "unicode-bom": ["error", "never"],
326
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
327
+ "unused-imports/no-unused-vars": [
328
+ "error",
329
+ { args: "after-used", ignoreRestSiblings: true }
330
+ ],
331
+ "use-isnan": [
332
+ "error",
333
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
334
+ ],
335
+ "valid-typeof": ["error", { requireStringLiterals: true }],
336
+ "vars-on-top": "error",
337
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }]
338
+ }
339
+ },
340
+ {
341
+ files: ["**/scripts/*", "**/cli.*"],
342
+ rules: {
343
+ "no-console": "off"
344
+ }
345
+ },
346
+ {
347
+ files: ["**/*.{test,spec}.js?(x)"],
348
+ rules: {
349
+ "no-unused-expressions": "off"
350
+ }
351
+ }
352
+ ];
353
+
354
+ // src/configs/jsonc.ts
355
+ var jsonc = [
356
+ {
357
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
358
+ languageOptions: {
359
+ parser: parserJsonc
360
+ },
361
+ plugins: {
362
+ jsonc: pluginJsonc
363
+ },
364
+ rules: {
365
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
366
+ "jsonc/quote-props": "off",
367
+ "jsonc/quotes": "off"
368
+ }
369
+ }
370
+ ];
371
+
372
+ // src/configs/markdown.ts
373
+ var markdown = [
374
+ {
375
+ files: [GLOB_MARKDOWN],
376
+ plugins: {
377
+ markdown: pluginMarkdown
378
+ },
379
+ processor: "markdown/markdown"
380
+ },
381
+ {
382
+ files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
383
+ languageOptions: {
384
+ parserOptions: {
385
+ ecmaFeatures: {
386
+ impliedStrict: true
387
+ }
388
+ }
389
+ },
390
+ rules: {
391
+ ...pluginMarkdown.configs.recommended.overrides[1].rules,
392
+ "@typescript-eslint/comma-dangle": "off",
393
+ "@typescript-eslint/consistent-type-imports": "off",
394
+ "@typescript-eslint/no-extraneous-class": "off",
395
+ "@typescript-eslint/no-namespace": "off",
396
+ "@typescript-eslint/no-redeclare": "off",
397
+ "@typescript-eslint/no-require-imports": "off",
398
+ "@typescript-eslint/no-unused-vars": "off",
399
+ "@typescript-eslint/no-use-before-define": "off",
400
+ "@typescript-eslint/no-var-requires": "off",
401
+ "no-alert": "off",
402
+ "no-console": "off",
403
+ "no-restricted-imports": "off",
404
+ "no-undef": "off",
405
+ "no-unused-expressions": "off",
406
+ "no-unused-vars": "off",
407
+ "unused-imports/no-unused-imports": "off",
408
+ "unused-imports/no-unused-vars": "off"
409
+ }
410
+ }
411
+ ];
412
+
413
+ // src/configs/prettier.ts
414
+ var prettierConflictRules = { ...configPrettier.rules };
415
+ delete prettierConflictRules["vue/html-self-closing"];
416
+ var prettier = [
417
+ {
418
+ plugins: {
419
+ prettier: pluginPrettier
420
+ },
421
+ rules: {
422
+ ...prettierConflictRules,
423
+ ...pluginPrettier.configs.recommended.rules,
424
+ "prettier/prettier": "warn"
425
+ }
426
+ }
427
+ ];
428
+
429
+ // src/configs/sort.ts
430
+ var sortPackageJson = [
431
+ {
432
+ files: ["**/package.json"],
433
+ rules: {
434
+ "jsonc/sort-array-values": [
435
+ "error",
436
+ {
437
+ order: { type: "asc" },
438
+ pathPattern: "^files$"
439
+ }
440
+ ],
441
+ "jsonc/sort-keys": [
442
+ "error",
443
+ {
444
+ order: [
445
+ "name",
446
+ "version",
447
+ "private",
448
+ "packageManager",
449
+ "description",
450
+ "type",
451
+ "keywords",
452
+ "license",
453
+ "homepage",
454
+ "bugs",
455
+ "repository",
456
+ "author",
457
+ "contributors",
458
+ "funding",
459
+ "files",
460
+ "main",
461
+ "module",
462
+ "types",
463
+ "exports",
464
+ "typesVersions",
465
+ "sideEffects",
466
+ "unpkg",
467
+ "jsdelivr",
468
+ "browser",
469
+ "bin",
470
+ "man",
471
+ "directories",
472
+ "publishConfig",
473
+ "scripts",
474
+ "peerDependencies",
475
+ "peerDependenciesMeta",
476
+ "optionalDependencies",
477
+ "dependencies",
478
+ "devDependencies",
479
+ "engines",
480
+ "config",
481
+ "overrides",
482
+ "pnpm",
483
+ "husky",
484
+ "lint-staged",
485
+ "eslintConfig",
486
+ "prettier"
487
+ ],
488
+ pathPattern: "^$"
489
+ },
490
+ {
491
+ order: { type: "asc" },
492
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
493
+ },
494
+ {
495
+ order: ["types", "require", "import", "default"],
496
+ pathPattern: "^exports.*$"
497
+ },
498
+ {
499
+ order: { type: "asc" },
500
+ pathPattern: "^resolutions$"
501
+ },
502
+ {
503
+ order: { type: "asc" },
504
+ pathPattern: "^pnpm.overrides$"
505
+ }
506
+ ]
507
+ }
508
+ }
509
+ ];
510
+ var sortTsconfig = [
511
+ {
512
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
513
+ rules: {
514
+ "jsonc/sort-keys": [
515
+ "error",
516
+ {
517
+ order: [
518
+ "extends",
519
+ "compilerOptions",
520
+ "references",
521
+ "files",
522
+ "include",
523
+ "exclude"
524
+ ],
525
+ pathPattern: "^$"
526
+ },
527
+ {
528
+ order: [
529
+ /* Projects */
530
+ "incremental",
531
+ "composite",
532
+ "tsBuildInfoFile",
533
+ "disableSourceOfProjectReferenceRedirect",
534
+ "disableSolutionSearching",
535
+ "disableReferencedProjectLoad",
536
+ /* Language and Environment */
537
+ "target",
538
+ "lib",
539
+ "jsx",
540
+ "experimentalDecorators",
541
+ "emitDecoratorMetadata",
542
+ "jsxFactory",
543
+ "jsxFragmentFactory",
544
+ "jsxImportSource",
545
+ "reactNamespace",
546
+ "noLib",
547
+ "useDefineForClassFields",
548
+ "moduleDetection",
549
+ /* Modules */
550
+ "module",
551
+ "rootDir",
552
+ "moduleResolution",
553
+ "baseUrl",
554
+ "paths",
555
+ "rootDirs",
556
+ "typeRoots",
557
+ "types",
558
+ "allowUmdGlobalAccess",
559
+ "moduleSuffixes",
560
+ "allowImportingTsExtensions",
561
+ "resolvePackageJsonExports",
562
+ "resolvePackageJsonImports",
563
+ "customConditions",
564
+ "resolveJsonModule",
565
+ "allowArbitraryExtensions",
566
+ "noResolve",
567
+ /* JavaScript Support */
568
+ "allowJs",
569
+ "checkJs",
570
+ "maxNodeModuleJsDepth",
571
+ /* Emit */
572
+ "declaration",
573
+ "declarationMap",
574
+ "emitDeclarationOnly",
575
+ "sourceMap",
576
+ "inlineSourceMap",
577
+ "outFile",
578
+ "outDir",
579
+ "removeComments",
580
+ "noEmit",
581
+ "importHelpers",
582
+ "importsNotUsedAsValues",
583
+ "downlevelIteration",
584
+ "sourceRoot",
585
+ "mapRoot",
586
+ "inlineSources",
587
+ "emitBOM",
588
+ "newLine",
589
+ "stripInternal",
590
+ "noEmitHelpers",
591
+ "noEmitOnError",
592
+ "preserveConstEnums",
593
+ "declarationDir",
594
+ "preserveValueImports",
595
+ /* Interop Constraints */
596
+ "isolatedModules",
597
+ "verbatimModuleSyntax",
598
+ "allowSyntheticDefaultImports",
599
+ "esModuleInterop",
600
+ "preserveSymlinks",
601
+ "forceConsistentCasingInFileNames",
602
+ /* Type Checking */
603
+ "strict",
604
+ "strictBindCallApply",
605
+ "strictFunctionTypes",
606
+ "strictNullChecks",
607
+ "strictPropertyInitialization",
608
+ "allowUnreachableCode",
609
+ "allowUnusedLabels",
610
+ "alwaysStrict",
611
+ "exactOptionalPropertyTypes",
612
+ "noFallthroughCasesInSwitch",
613
+ "noImplicitAny",
614
+ "noImplicitOverride",
615
+ "noImplicitReturns",
616
+ "noImplicitThis",
617
+ "noPropertyAccessFromIndexSignature",
618
+ "noUncheckedIndexedAccess",
619
+ "noUnusedLocals",
620
+ "noUnusedParameters",
621
+ "useUnknownInCatchVariables",
622
+ /* Completeness */
623
+ "skipDefaultLibCheck",
624
+ "skipLibCheck"
625
+ ],
626
+ pathPattern: "^compilerOptions$"
627
+ }
628
+ ]
629
+ }
630
+ }
631
+ ];
632
+
633
+ // src/configs/typescript.ts
634
+ var typescript = [
635
+ {
636
+ files: [GLOB_TS, GLOB_TSX],
637
+ languageOptions: {
638
+ parser: parserTypeScript,
639
+ parserOptions: {
640
+ sourceType: "module"
641
+ }
642
+ },
643
+ plugins: {
644
+ "@typescript-eslint": pluginTypeScript,
645
+ antfu: pluginAntfu
646
+ },
647
+ rules: {
648
+ ...pluginTypeScript.configs["eslint-recommended"].overrides[0].rules,
649
+ ...pluginTypeScript.configs.strict.rules,
650
+ "@typescript-eslint/ban-ts-comment": "off",
651
+ "@typescript-eslint/ban-types": "off",
652
+ "@typescript-eslint/consistent-type-assertions": [
653
+ "error",
654
+ {
655
+ assertionStyle: "as",
656
+ objectLiteralTypeAssertions: "allow-as-parameter"
657
+ }
658
+ ],
659
+ "@typescript-eslint/consistent-type-imports": [
660
+ "error",
661
+ { disallowTypeAnnotations: false, fixStyle: "inline-type-imports" }
662
+ ],
663
+ "@typescript-eslint/no-explicit-any": "off",
664
+ "@typescript-eslint/no-non-null-assertion": "off",
665
+ "@typescript-eslint/no-redeclare": "error",
666
+ // handled by unused-imports/no-unused-imports
667
+ "@typescript-eslint/no-unused-vars": "off",
668
+ "@typescript-eslint/prefer-as-const": "warn",
669
+ "antfu/no-const-enum": "error"
670
+ }
671
+ },
672
+ {
673
+ files: ["**/*.d.ts"],
674
+ rules: {
675
+ "eslint-comments/no-unlimited-disable": "off",
676
+ "import/no-duplicates": "off",
677
+ "unused-imports/no-unused-vars": "off"
678
+ }
679
+ },
680
+ {
681
+ files: ["**/*.{test,spec}.ts?(x)"],
682
+ rules: {
683
+ "no-unused-expressions": "off"
684
+ }
685
+ },
686
+ {
687
+ files: ["**/*.js", "**/*.cjs"],
688
+ rules: {
689
+ "@typescript-eslint/no-require-imports": "off",
690
+ "@typescript-eslint/no-var-requires": "off"
691
+ }
692
+ }
693
+ ];
694
+
695
+ // src/configs/unicorn.ts
696
+ var unicorn = [
697
+ {
698
+ plugins: {
699
+ unicorn: pluginUnicorn
700
+ },
701
+ rules: {
702
+ "unicorn/better-regex": "error",
703
+ "unicorn/catch-error-name": "error",
704
+ "unicorn/custom-error-definition": "error",
705
+ "unicorn/error-message": "error",
706
+ "unicorn/escape-case": "error",
707
+ "unicorn/explicit-length-check": "error",
708
+ "unicorn/filename-case": [
709
+ "error",
710
+ {
711
+ case: "kebabCase",
712
+ ignore: [/^[A-Z]+\..*$/]
713
+ }
714
+ ],
715
+ "unicorn/new-for-builtins": "error",
716
+ "unicorn/no-array-callback-reference": "error",
717
+ "unicorn/no-array-method-this-argument": "error",
718
+ "unicorn/no-array-push-push": "error",
719
+ "unicorn/no-console-spaces": "error",
720
+ "unicorn/no-for-loop": "error",
721
+ "unicorn/no-hex-escape": "error",
722
+ "unicorn/no-instanceof-array": "error",
723
+ "unicorn/no-invalid-remove-event-listener": "error",
724
+ "unicorn/no-lonely-if": "error",
725
+ "unicorn/no-new-array": "error",
726
+ "unicorn/no-new-buffer": "error",
727
+ "unicorn/no-static-only-class": "error",
728
+ "unicorn/no-unnecessary-await": "error",
729
+ "unicorn/no-zero-fractions": `error`,
730
+ "unicorn/prefer-add-event-listener": "error",
731
+ "unicorn/prefer-array-find": "error",
732
+ "unicorn/prefer-array-flat-map": "error",
733
+ "unicorn/prefer-array-index-of": "error",
734
+ "unicorn/prefer-array-some": "error",
735
+ "unicorn/prefer-at": "error",
736
+ "unicorn/prefer-blob-reading-methods": "error",
737
+ "unicorn/prefer-date-now": "error",
738
+ "unicorn/prefer-dom-node-append": "error",
739
+ "unicorn/prefer-dom-node-dataset": "error",
740
+ "unicorn/prefer-dom-node-remove": "error",
741
+ "unicorn/prefer-dom-node-text-content": "error",
742
+ "unicorn/prefer-includes": "error",
743
+ "unicorn/prefer-keyboard-event-key": "error",
744
+ "unicorn/prefer-math-trunc": "error",
745
+ "unicorn/prefer-modern-dom-apis": "error",
746
+ "unicorn/prefer-modern-math-apis": "error",
747
+ "unicorn/prefer-negative-index": "error",
748
+ "unicorn/prefer-node-protocol": "error",
749
+ "unicorn/prefer-number-properties": "error",
750
+ "unicorn/prefer-optional-catch-binding": "error",
751
+ "unicorn/prefer-prototype-methods": "error",
752
+ "unicorn/prefer-query-selector": "error",
753
+ "unicorn/prefer-reflect-apply": "error",
754
+ "unicorn/prefer-regexp-test": "error",
755
+ "unicorn/prefer-string-replace-all": "error",
756
+ "unicorn/prefer-string-slice": "error",
757
+ "unicorn/prefer-string-starts-ends-with": "error",
758
+ "unicorn/prefer-string-trim-start-end": "error",
759
+ "unicorn/prefer-top-level-await": "error",
760
+ "unicorn/prefer-type-error": "error",
761
+ "unicorn/throw-new-error": "error"
762
+ }
763
+ }
764
+ ];
765
+
766
+ // src/configs/unocss.ts
767
+ var unocss = [
768
+ {
769
+ plugins: {
770
+ "@unocss": pluginUnocss
771
+ },
772
+ rules: {
773
+ ...pluginUnocss.configs.recommended.rules
774
+ }
775
+ }
776
+ ];
777
+
778
+ // src/configs/vue.ts
779
+ import { getPackageInfoSync } from "local-pkg";
780
+ import tsPlugin from "@typescript-eslint/eslint-plugin";
781
+ function getVueVersion() {
782
+ const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
783
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
784
+ return +pkg.version[0];
785
+ }
786
+ return 3;
787
+ }
788
+ var isVue3 = getVueVersion() === 3;
789
+ var reactivityTransform = [
790
+ {
791
+ languageOptions: {
792
+ globals: {
793
+ $: "readonly",
794
+ $$: "readonly",
795
+ $computed: "readonly",
796
+ $customRef: "readonly",
797
+ $ref: "readonly",
798
+ $shallowRef: "readonly",
799
+ $toRef: "readonly"
800
+ }
801
+ },
802
+ plugins: {
803
+ vue: pluginVue
804
+ },
805
+ rules: {
806
+ "vue/no-setup-props-reactivity-loss": "off"
807
+ }
808
+ }
809
+ ];
810
+ var vueCustomRules = {
811
+ "vue/block-order": ["error", { order: ["script", "template", "style"] }],
812
+ "vue/custom-event-name-casing": ["error", "camelCase"],
813
+ "vue/eqeqeq": ["error", "smart"],
814
+ "vue/html-self-closing": [
815
+ "error",
816
+ {
817
+ html: {
818
+ component: "always",
819
+ normal: "always",
820
+ void: "always"
821
+ },
822
+ math: "always",
823
+ svg: "always"
824
+ }
825
+ ],
826
+ "vue/max-attributes-per-line": "off",
827
+ "vue/multi-word-component-names": "off",
828
+ "vue/no-constant-condition": "warn",
829
+ "vue/no-empty-pattern": "error",
830
+ "vue/no-loss-of-precision": "error",
831
+ "vue/no-unused-refs": "error",
832
+ "vue/no-useless-v-bind": "error",
833
+ "vue/no-v-html": "off",
834
+ "vue/object-shorthand": [
835
+ "error",
836
+ "always",
837
+ {
838
+ avoidQuotes: true,
839
+ ignoreConstructors: false
840
+ }
841
+ ],
842
+ "vue/padding-line-between-blocks": ["error", "always"],
843
+ "vue/prefer-template": "error",
844
+ "vue/require-default-prop": "off",
845
+ "vue/require-prop-types": "off"
846
+ };
847
+ var vue3Rules = {
848
+ ...pluginVue.configs.base.rules,
849
+ ...pluginVue.configs["vue3-essential"].rules,
850
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
851
+ ...pluginVue.configs["vue3-recommended"].rules
852
+ };
853
+ var vue2Rules = {
854
+ ...pluginVue.configs.base.rules,
855
+ ...pluginVue.configs.essential.rules,
856
+ ...pluginVue.configs["strongly-recommended"].rules,
857
+ ...pluginVue.configs.recommended.rules
858
+ };
859
+ var vue = [
860
+ {
861
+ files: [GLOB_VUE],
862
+ languageOptions: {
863
+ parser: parserVue,
864
+ parserOptions: {
865
+ ecmaFeatures: {
866
+ jsx: true
867
+ },
868
+ extraFileExtensions: [".vue"],
869
+ parser: "@typescript-eslint/parser",
870
+ sourceType: "module"
871
+ }
872
+ },
873
+ plugins: {
874
+ "@typescript-eslint": tsPlugin,
875
+ vue: pluginVue
876
+ },
877
+ processor: pluginVue.processors[".vue"],
878
+ rules: {
879
+ ...typescript[0].rules
880
+ }
881
+ },
882
+ {
883
+ plugins: {
884
+ vue: pluginVue
885
+ },
886
+ rules: {
887
+ ...isVue3 ? vue3Rules : vue2Rules,
888
+ ...vueCustomRules
889
+ }
890
+ },
891
+ ...reactivityTransform
892
+ ];
893
+
894
+ // src/configs/yml.ts
895
+ var yml = [
896
+ {
897
+ files: [GLOB_YAML],
898
+ languageOptions: {
899
+ parser: parserYml
900
+ },
901
+ plugins: {
902
+ yml: pluginYml
903
+ },
904
+ rules: {
905
+ ...pluginYml.configs.standard.rules,
906
+ ...pluginYml.configs.prettier.rules,
907
+ "yml/no-empty-mapping-value": "off"
908
+ }
909
+ }
910
+ ];
911
+
912
+ // src/presets.ts
913
+ var presetJavaScript = [
914
+ ...ignores,
915
+ ...javascript,
916
+ ...comments,
917
+ ...imports,
918
+ ...unicorn
919
+ ];
920
+ var presetLangsExtensions = [
921
+ ...markdown,
922
+ ...yml,
923
+ ...jsonc,
924
+ ...sortPackageJson,
925
+ ...sortTsconfig
926
+ ];
927
+ var basic = [
928
+ ...presetJavaScript,
929
+ ...typescript,
930
+ ...presetLangsExtensions
931
+ ];
932
+ var all = [...basic, ...vue, ...unocss, ...prettier];
933
+ function frabbit(config = [], {
934
+ vue: enableVue = true,
935
+ prettier: enablePrettier = true,
936
+ markdown: enableMarkdown = true,
937
+ unocss: enableUnocss = false
938
+ } = {}) {
939
+ const configs = [];
940
+ configs.push(...basic);
941
+ if (enableVue) {
942
+ configs.push(...vue);
943
+ }
944
+ if (enableMarkdown) {
945
+ configs.push(...markdown);
946
+ }
947
+ if (enableUnocss) {
948
+ configs.push(...unocss);
949
+ }
950
+ if (enablePrettier) {
951
+ configs.push(...prettier);
952
+ }
953
+ if (Object.keys(config).length > 0) {
954
+ configs.push(...Array.isArray(config) ? config : [config]);
955
+ }
956
+ return configs;
957
+ }
958
+ export {
959
+ GLOB_ALL_SRC,
960
+ GLOB_CSS,
961
+ GLOB_DIST,
962
+ GLOB_EXCLUDE,
963
+ GLOB_HTML,
964
+ GLOB_JS,
965
+ GLOB_JSON,
966
+ GLOB_JSON5,
967
+ GLOB_JSONC,
968
+ GLOB_JSX,
969
+ GLOB_LESS,
970
+ GLOB_LOCKFILE,
971
+ GLOB_MARKDOWN,
972
+ GLOB_NODE_MODULES,
973
+ GLOB_SCSS,
974
+ GLOB_SRC,
975
+ GLOB_SRC_EXT,
976
+ GLOB_STYLE,
977
+ GLOB_TS,
978
+ GLOB_TSX,
979
+ GLOB_VUE,
980
+ GLOB_YAML,
981
+ all,
982
+ basic,
983
+ comments,
984
+ configPrettier,
985
+ frabbit,
986
+ getVueVersion,
987
+ hasTypeScript,
988
+ hasVue,
989
+ ignores,
990
+ imports,
991
+ isInEditor,
992
+ javascript,
993
+ jsonc,
994
+ markdown,
995
+ parserJsonc,
996
+ parserTypeScript,
997
+ parserVue,
998
+ parserYml,
999
+ pluginAntfu,
1000
+ pluginComments,
1001
+ pluginImport,
1002
+ pluginJsonc,
1003
+ pluginMarkdown,
1004
+ pluginPrettier,
1005
+ pluginTypeScript,
1006
+ pluginUnicorn,
1007
+ pluginUnocss,
1008
+ pluginUnusedImports,
1009
+ pluginVue,
1010
+ pluginYml,
1011
+ basic as presetBasic,
1012
+ presetJavaScript,
1013
+ presetLangsExtensions,
1014
+ prettier,
1015
+ reactivityTransform,
1016
+ sortPackageJson,
1017
+ sortTsconfig,
1018
+ typescript,
1019
+ unicorn,
1020
+ unocss,
1021
+ vue,
1022
+ yml
1023
+ };