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