@antfu/eslint-config 0.43.1 → 1.0.0-beta.1

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,1208 @@
1
+ // src/flags.ts
2
+ var OFF = 0;
3
+
4
+ // src/plugins.ts
5
+ import { default as default2 } from "eslint-plugin-antfu";
6
+ import { default as default3 } from "eslint-plugin-eslint-comments";
7
+ import { default as default4 } from "eslint-plugin-i";
8
+ import { default as default5 } from "eslint-plugin-jsdoc";
9
+ import { default as default6 } from "eslint-plugin-jsonc";
10
+ import { default as default7 } from "eslint-plugin-markdown";
11
+ import { default as default8 } from "eslint-plugin-n";
12
+ import { default as default9 } from "@stylistic/eslint-plugin-js";
13
+ import { default as default10 } from "@stylistic/eslint-plugin-ts";
14
+ import { default as default11 } from "@typescript-eslint/eslint-plugin";
15
+ import { default as default12 } from "eslint-plugin-unicorn";
16
+ import { default as default13 } from "eslint-plugin-unused-imports";
17
+ import { default as default14 } from "eslint-plugin-vue";
18
+ import { default as default15 } from "eslint-plugin-yml";
19
+ import { default as default16 } from "eslint-plugin-no-only-tests";
20
+ import { default as default17 } from "@typescript-eslint/parser";
21
+ import { default as default18 } from "vue-eslint-parser";
22
+ import { default as default19 } from "yaml-eslint-parser";
23
+ import { default as default20 } from "jsonc-eslint-parser";
24
+
25
+ // src/configs/comments.ts
26
+ var comments = [
27
+ {
28
+ plugins: {
29
+ "eslint-comments": default3
30
+ },
31
+ rules: {
32
+ ...default3.configs.recommended.rules,
33
+ "eslint-comments/disable-enable-pair": OFF
34
+ }
35
+ }
36
+ ];
37
+
38
+ // src/globs.ts
39
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
40
+ var GLOB_TS = "**/*.?([cm])ts";
41
+ var GLOB_TSX = "**/*.?([cm])tsx";
42
+ var GLOB_JSON = "**/*.json";
43
+ var GLOB_JSON5 = "**/*.json5";
44
+ var GLOB_JSONC = "**/*.jsonc";
45
+ var GLOB_MARKDOWN = "**/*.md";
46
+ var GLOB_VUE = "**/*.vue";
47
+ var GLOB_YAML = "**/*.y?(a)ml";
48
+ var GLOB_TESTS = [
49
+ "**/__tests__/**/*.?([cm])[jt]s?(x)",
50
+ "**/*.spec.?([cm])[jt]s?(x)",
51
+ "**/*.test.?([cm])[jt]s?(x)"
52
+ ];
53
+ var GLOB_NODE_MODULES = "**/node_modules";
54
+ var GLOB_DIST = "**/dist";
55
+ var GLOB_LOCKFILE = [
56
+ "**/package-lock.json",
57
+ "**/yarn.lock",
58
+ "**/pnpm-lock.yaml"
59
+ ];
60
+ var GLOB_EXCLUDE = [
61
+ GLOB_NODE_MODULES,
62
+ GLOB_DIST,
63
+ ...GLOB_LOCKFILE,
64
+ "**/output",
65
+ "**/coverage",
66
+ "**/temp",
67
+ "**/fixtures",
68
+ "**/.vitepress/cache",
69
+ "**/.nuxt",
70
+ "**/.vercel",
71
+ "**/.changeset",
72
+ "**/.idea",
73
+ "**/.output",
74
+ "**/.vite-inspect",
75
+ "**/CHANGELOG*.md",
76
+ "**/*.min.*",
77
+ "**/LICENSE*",
78
+ "**/__snapshots__",
79
+ "**/auto-import?(s).d.ts",
80
+ "**/components.d.ts"
81
+ ];
82
+
83
+ // src/configs/ignores.ts
84
+ var ignores = [
85
+ { ignores: GLOB_EXCLUDE }
86
+ ];
87
+
88
+ // src/configs/imports.ts
89
+ var imports = [
90
+ {
91
+ plugins: {
92
+ import: default4
93
+ },
94
+ rules: {
95
+ "import/export": "error",
96
+ "import/first": "error",
97
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
98
+ "import/no-duplicates": "error",
99
+ "import/no-mutable-exports": "error",
100
+ "import/no-named-default": "error",
101
+ "import/no-self-import": "error",
102
+ "import/no-webpack-loader-syntax": "error",
103
+ "import/order": "error"
104
+ }
105
+ }
106
+ ];
107
+
108
+ // src/configs/javascript.ts
109
+ import globals from "globals";
110
+
111
+ // src/env.ts
112
+ import process from "process";
113
+ import { isPackageExists } from "local-pkg";
114
+ var isInEditor = (process.env.VSCODE_PID || process.env.JETBRAINS_IDE) && !process.env.CI;
115
+ var hasTypeScript = isPackageExists("typescript");
116
+ var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli");
117
+
118
+ // src/configs/javascript.ts
119
+ var javascript = [
120
+ {
121
+ languageOptions: {
122
+ ecmaVersion: 2022,
123
+ globals: {
124
+ ...globals.browser,
125
+ ...globals.es2021,
126
+ ...globals.node,
127
+ document: "readonly",
128
+ navigator: "readonly",
129
+ window: "readonly"
130
+ },
131
+ parserOptions: {
132
+ ecmaFeatures: {
133
+ jsx: true
134
+ },
135
+ ecmaVersion: 2022,
136
+ sourceType: "module"
137
+ },
138
+ sourceType: "module"
139
+ },
140
+ plugins: {
141
+ "antfu": default2,
142
+ "unused-imports": default13
143
+ },
144
+ rules: {
145
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
146
+ "antfu/if-newline": "error",
147
+ "antfu/import-dedupe": "error",
148
+ "antfu/no-import-node-modules-by-path": "error",
149
+ "antfu/top-level-function": "error",
150
+ // best-practice
151
+ "array-callback-return": "error",
152
+ "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
153
+ "block-scoped-var": "error",
154
+ "camelcase": OFF,
155
+ "comma-dangle": ["error", "always-multiline"],
156
+ "complexity": OFF,
157
+ "consistent-return": OFF,
158
+ "constructor-super": "error",
159
+ "curly": ["error", "multi-or-nest", "consistent"],
160
+ "default-case-last": "error",
161
+ "dot-notation": ["error", { allowKeywords: true }],
162
+ "eol-last": "error",
163
+ "eqeqeq": ["error", "smart"],
164
+ "max-statements-per-line": ["error", { max: 1 }],
165
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
166
+ "new-parens": "error",
167
+ "no-alert": "warn",
168
+ "no-array-constructor": "error",
169
+ "no-async-promise-executor": "error",
170
+ "no-caller": "error",
171
+ "no-case-declarations": "error",
172
+ "no-class-assign": "error",
173
+ "no-compare-neg-zero": "error",
174
+ "no-cond-assign": ["error", "always"],
175
+ "no-console": ["error", { allow: ["warn", "error"] }],
176
+ "no-const-assign": "error",
177
+ "no-constant-condition": "warn",
178
+ "no-control-regex": "error",
179
+ "no-debugger": "error",
180
+ "no-delete-var": "error",
181
+ "no-dupe-args": "error",
182
+ "no-dupe-class-members": "error",
183
+ "no-dupe-keys": "error",
184
+ "no-duplicate-case": "error",
185
+ "no-empty": ["error", { allowEmptyCatch: true }],
186
+ "no-empty-character-class": "error",
187
+ "no-empty-pattern": "error",
188
+ "no-eval": "error",
189
+ "no-ex-assign": "error",
190
+ "no-extend-native": "error",
191
+ "no-extra-bind": "error",
192
+ "no-extra-boolean-cast": "error",
193
+ "no-extra-parens": ["error", "functions"],
194
+ "no-fallthrough": "error",
195
+ "no-floating-decimal": "error",
196
+ "no-func-assign": "error",
197
+ "no-global-assign": "error",
198
+ "no-implied-eval": "error",
199
+ "no-import-assign": "error",
200
+ "no-invalid-regexp": "error",
201
+ "no-invalid-this": "error",
202
+ "no-irregular-whitespace": "error",
203
+ "no-iterator": "error",
204
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
205
+ "no-lone-blocks": "error",
206
+ "no-loss-of-precision": "error",
207
+ "no-misleading-character-class": "error",
208
+ "no-mixed-operators": ["error", {
209
+ allowSamePrecedence: true,
210
+ groups: [
211
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
212
+ ["&&", "||"],
213
+ ["in", "instanceof"]
214
+ ]
215
+ }],
216
+ "no-multi-str": "error",
217
+ "no-new": "error",
218
+ "no-new-func": "error",
219
+ "no-new-object": "error",
220
+ "no-new-symbol": "error",
221
+ "no-new-wrappers": "error",
222
+ "no-obj-calls": "error",
223
+ "no-octal": "error",
224
+ "no-octal-escape": "error",
225
+ "no-param-reassign": OFF,
226
+ "no-proto": "error",
227
+ "no-prototype-builtins": "error",
228
+ "no-redeclare": ["error", { builtinGlobals: false }],
229
+ "no-regex-spaces": "error",
230
+ "no-restricted-globals": [
231
+ "error",
232
+ { message: "Use `globalThis` instead.", name: "global" },
233
+ { message: "Use `globalThis` instead.", name: "self" }
234
+ ],
235
+ "no-restricted-properties": [
236
+ "error",
237
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
238
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
239
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
240
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
241
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
242
+ ],
243
+ "no-restricted-syntax": [
244
+ "error",
245
+ "DebuggerStatement",
246
+ "LabeledStatement",
247
+ "WithStatement"
248
+ ],
249
+ "no-return-assign": OFF,
250
+ "no-return-await": OFF,
251
+ "no-self-assign": ["error", { props: true }],
252
+ "no-self-compare": "error",
253
+ "no-sequences": "error",
254
+ "no-shadow-restricted-names": "error",
255
+ "no-sparse-arrays": "error",
256
+ "no-template-curly-in-string": "error",
257
+ "no-this-before-super": "error",
258
+ "no-throw-literal": "error",
259
+ "no-undef": "error",
260
+ "no-undef-init": "error",
261
+ "no-unexpected-multiline": "error",
262
+ "no-unmodified-loop-condition": "error",
263
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
264
+ "no-unreachable": "error",
265
+ "no-unreachable-loop": "error",
266
+ "no-unsafe-finally": "error",
267
+ "no-unsafe-negation": "error",
268
+ "no-unused-expressions": ["error", {
269
+ allowShortCircuit: true,
270
+ allowTaggedTemplates: true,
271
+ allowTernary: true
272
+ }],
273
+ "no-unused-vars": ["error", {
274
+ args: "none",
275
+ caughtErrors: "none",
276
+ ignoreRestSiblings: true,
277
+ vars: "all"
278
+ }],
279
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
280
+ "no-useless-backreference": "error",
281
+ "no-useless-call": "error",
282
+ "no-useless-catch": "error",
283
+ "no-useless-computed-key": "error",
284
+ "no-useless-constructor": "error",
285
+ "no-useless-escape": OFF,
286
+ "no-useless-rename": "error",
287
+ "no-useless-return": "error",
288
+ // ES6
289
+ "no-var": "error",
290
+ "no-void": "error",
291
+ "no-with": "error",
292
+ "object-shorthand": [
293
+ "error",
294
+ "always",
295
+ {
296
+ avoidQuotes: true,
297
+ ignoreConstructors: false
298
+ }
299
+ ],
300
+ "one-var": ["error", { initialized: "never" }],
301
+ "prefer-arrow-callback": [
302
+ "error",
303
+ {
304
+ allowNamedFunctions: false,
305
+ allowUnboundThis: true
306
+ }
307
+ ],
308
+ "prefer-const": [
309
+ "error",
310
+ {
311
+ destructuring: "all",
312
+ ignoreReadBeforeAssign: true
313
+ }
314
+ ],
315
+ "prefer-exponentiation-operator": "error",
316
+ "prefer-promise-reject-errors": "error",
317
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
318
+ "prefer-rest-params": "error",
319
+ "prefer-spread": "error",
320
+ "prefer-template": "error",
321
+ "quote-props": ["error", "consistent-as-needed"],
322
+ "quotes": ["error", "single"],
323
+ "require-await": OFF,
324
+ // Common
325
+ "semi": ["error", "never"],
326
+ "sort-imports": [
327
+ "error",
328
+ {
329
+ allowSeparatedGroups: false,
330
+ ignoreCase: false,
331
+ ignoreDeclarationSort: true,
332
+ ignoreMemberSort: false,
333
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
334
+ }
335
+ ],
336
+ "symbol-description": "error",
337
+ "unicode-bom": ["error", "never"],
338
+ "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
339
+ "unused-imports/no-unused-vars": [
340
+ "warn",
341
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
342
+ ],
343
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
344
+ "valid-typeof": ["error", { requireStringLiterals: true }],
345
+ "vars-on-top": "error",
346
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
347
+ "yoda": ["error", "never"]
348
+ }
349
+ },
350
+ {
351
+ files: ["scripts/**/*.*", "cli.*"],
352
+ rules: {
353
+ "no-console": OFF
354
+ }
355
+ }
356
+ ];
357
+
358
+ // src/configs/jsdoc.ts
359
+ var jsdoc = [
360
+ {
361
+ plugins: {
362
+ jsdoc: default5
363
+ },
364
+ rules: {
365
+ ...default5.configs.recommended.rules,
366
+ "jsdoc/check-tag-names": OFF,
367
+ "jsdoc/check-values": OFF,
368
+ "jsdoc/no-undefined-types": OFF,
369
+ "jsdoc/require-jsdoc": OFF,
370
+ "jsdoc/require-param": OFF,
371
+ "jsdoc/require-param-description": OFF,
372
+ "jsdoc/require-param-type": OFF,
373
+ "jsdoc/require-returns": OFF,
374
+ "jsdoc/require-returns-type": OFF,
375
+ "jsdoc/require-throws": OFF,
376
+ "jsdoc/require-yields": OFF,
377
+ "jsdoc/tag-lines": OFF
378
+ }
379
+ }
380
+ ];
381
+
382
+ // src/configs/jsonc.ts
383
+ var jsonc = [
384
+ {
385
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
386
+ languageOptions: {
387
+ parser: default20
388
+ },
389
+ plugins: {
390
+ jsonc: default6
391
+ },
392
+ rules: {
393
+ ...default6.configs["recommended-with-jsonc"].rules,
394
+ "jsonc/array-bracket-spacing": ["error", "never"],
395
+ "jsonc/comma-dangle": ["error", "never"],
396
+ "jsonc/comma-style": ["error", "last"],
397
+ "jsonc/indent": ["error", 2],
398
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
399
+ "jsonc/no-octal-escape": "error",
400
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
401
+ "jsonc/object-curly-spacing": ["error", "always"],
402
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }]
403
+ }
404
+ }
405
+ ];
406
+
407
+ // src/configs/markdown.ts
408
+ var markdown = [
409
+ {
410
+ files: [GLOB_MARKDOWN],
411
+ plugins: {
412
+ markdown: default7
413
+ },
414
+ processor: "markdown/markdown"
415
+ },
416
+ {
417
+ files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
418
+ languageOptions: {
419
+ parserOptions: {
420
+ ecmaFeatures: {
421
+ impliedStrict: true
422
+ }
423
+ }
424
+ },
425
+ rules: {
426
+ ...default7.configs.recommended.overrides[1].rules,
427
+ "@typescript-eslint/comma-dangle": OFF,
428
+ "@typescript-eslint/consistent-type-imports": OFF,
429
+ "@typescript-eslint/no-namespace": OFF,
430
+ "@typescript-eslint/no-redeclare": OFF,
431
+ "@typescript-eslint/no-require-imports": OFF,
432
+ "@typescript-eslint/no-unused-vars": OFF,
433
+ "@typescript-eslint/no-use-before-define": OFF,
434
+ "@typescript-eslint/no-var-requires": OFF,
435
+ "antfu/no-cjs-exports": OFF,
436
+ "antfu/no-ts-export-equal": OFF,
437
+ "import/no-unresolved": OFF,
438
+ "n/prefer-global/process": OFF,
439
+ "no-alert": OFF,
440
+ "no-console": OFF,
441
+ "no-restricted-imports": OFF,
442
+ "no-undef": OFF,
443
+ "no-unused-expressions": OFF,
444
+ "no-unused-vars": OFF,
445
+ "unused-imports/no-unused-imports": OFF,
446
+ "unused-imports/no-unused-vars": OFF
447
+ }
448
+ }
449
+ ];
450
+
451
+ // src/configs/node.ts
452
+ var node = [
453
+ {
454
+ plugins: {
455
+ n: default8
456
+ },
457
+ rules: {
458
+ // Node
459
+ "n/handle-callback-err": ["error", "^(err|error)$"],
460
+ "n/no-deprecated-api": "error",
461
+ "n/no-exports-assign": "error",
462
+ "n/no-new-require": "error",
463
+ "n/no-path-concat": "error",
464
+ "n/prefer-global/buffer": ["error", "never"],
465
+ "n/prefer-global/process": ["error", "never"],
466
+ "n/process-exit-as-throw": "error"
467
+ }
468
+ }
469
+ ];
470
+
471
+ // src/configs/sort.ts
472
+ var sortPackageJson = [
473
+ {
474
+ files: ["**/package.json"],
475
+ rules: {
476
+ "jsonc/sort-array-values": [
477
+ "error",
478
+ {
479
+ order: { type: "asc" },
480
+ pathPattern: "^files$"
481
+ }
482
+ ],
483
+ "jsonc/sort-keys": [
484
+ "error",
485
+ {
486
+ order: [
487
+ "publisher",
488
+ "name",
489
+ "displayName",
490
+ "type",
491
+ "version",
492
+ "private",
493
+ "packageManager",
494
+ "description",
495
+ "author",
496
+ "license",
497
+ "funding",
498
+ "homepage",
499
+ "repository",
500
+ "bugs",
501
+ "keywords",
502
+ "categories",
503
+ "sideEffects",
504
+ "exports",
505
+ "main",
506
+ "module",
507
+ "unpkg",
508
+ "jsdelivr",
509
+ "types",
510
+ "typesVersions",
511
+ "bin",
512
+ "icon",
513
+ "files",
514
+ "engines",
515
+ "activationEvents",
516
+ "contributes",
517
+ "scripts",
518
+ "peerDependencies",
519
+ "peerDependenciesMeta",
520
+ "dependencies",
521
+ "optionalDependencies",
522
+ "devDependencies",
523
+ "pnpm",
524
+ "overrides",
525
+ "resolutions",
526
+ "husky",
527
+ "simple-git-hooks",
528
+ "lint-staged",
529
+ "eslintConfig"
530
+ ],
531
+ pathPattern: "^$"
532
+ },
533
+ {
534
+ order: { type: "asc" },
535
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
536
+ },
537
+ {
538
+ order: { type: "asc" },
539
+ pathPattern: "^resolutions$"
540
+ },
541
+ {
542
+ order: { type: "asc" },
543
+ pathPattern: "^pnpm.overrides$"
544
+ },
545
+ {
546
+ order: [
547
+ "types",
548
+ "import",
549
+ "require",
550
+ "default"
551
+ ],
552
+ pathPattern: "^exports.*$"
553
+ }
554
+ ]
555
+ }
556
+ }
557
+ ];
558
+ var sortTsconfig = [
559
+ {
560
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
561
+ rules: {
562
+ "jsonc/sort-keys": [
563
+ "error",
564
+ {
565
+ order: [
566
+ "extends",
567
+ "compilerOptions",
568
+ "references",
569
+ "files",
570
+ "include",
571
+ "exclude"
572
+ ],
573
+ pathPattern: "^$"
574
+ },
575
+ {
576
+ order: [
577
+ /* Projects */
578
+ "incremental",
579
+ "composite",
580
+ "tsBuildInfoFile",
581
+ "disableSourceOfProjectReferenceRedirect",
582
+ "disableSolutionSearching",
583
+ "disableReferencedProjectLoad",
584
+ /* Language and Environment */
585
+ "target",
586
+ "lib",
587
+ "jsx",
588
+ "experimentalDecorators",
589
+ "emitDecoratorMetadata",
590
+ "jsxFactory",
591
+ "jsxFragmentFactory",
592
+ "jsxImportSource",
593
+ "reactNamespace",
594
+ "noLib",
595
+ "useDefineForClassFields",
596
+ "moduleDetection",
597
+ /* Modules */
598
+ "module",
599
+ "rootDir",
600
+ "moduleResolution",
601
+ "baseUrl",
602
+ "paths",
603
+ "rootDirs",
604
+ "typeRoots",
605
+ "types",
606
+ "allowUmdGlobalAccess",
607
+ "moduleSuffixes",
608
+ "allowImportingTsExtensions",
609
+ "resolvePackageJsonExports",
610
+ "resolvePackageJsonImports",
611
+ "customConditions",
612
+ "resolveJsonModule",
613
+ "allowArbitraryExtensions",
614
+ "noResolve",
615
+ /* JavaScript Support */
616
+ "allowJs",
617
+ "checkJs",
618
+ "maxNodeModuleJsDepth",
619
+ /* Emit */
620
+ "declaration",
621
+ "declarationMap",
622
+ "emitDeclarationOnly",
623
+ "sourceMap",
624
+ "inlineSourceMap",
625
+ "outFile",
626
+ "outDir",
627
+ "removeComments",
628
+ "noEmit",
629
+ "importHelpers",
630
+ "importsNotUsedAsValues",
631
+ "downlevelIteration",
632
+ "sourceRoot",
633
+ "mapRoot",
634
+ "inlineSources",
635
+ "emitBOM",
636
+ "newLine",
637
+ "stripInternal",
638
+ "noEmitHelpers",
639
+ "noEmitOnError",
640
+ "preserveConstEnums",
641
+ "declarationDir",
642
+ "preserveValueImports",
643
+ /* Interop Constraints */
644
+ "isolatedModules",
645
+ "verbatimModuleSyntax",
646
+ "allowSyntheticDefaultImports",
647
+ "esModuleInterop",
648
+ "preserveSymlinks",
649
+ "forceConsistentCasingInFileNames",
650
+ /* Type Checking */
651
+ "strict",
652
+ "strictBindCallApply",
653
+ "strictFunctionTypes",
654
+ "strictNullChecks",
655
+ "strictPropertyInitialization",
656
+ "allowUnreachableCode",
657
+ "allowUnusedLabels",
658
+ "alwaysStrict",
659
+ "exactOptionalPropertyTypes",
660
+ "noFallthroughCasesInSwitch",
661
+ "noImplicitAny",
662
+ "noImplicitOverride",
663
+ "noImplicitReturns",
664
+ "noImplicitThis",
665
+ "noPropertyAccessFromIndexSignature",
666
+ "noUncheckedIndexedAccess",
667
+ "noUnusedLocals",
668
+ "noUnusedParameters",
669
+ "useUnknownInCatchVariables",
670
+ /* Completeness */
671
+ "skipDefaultLibCheck",
672
+ "skipLibCheck"
673
+ ],
674
+ pathPattern: "^compilerOptions$"
675
+ }
676
+ ]
677
+ }
678
+ }
679
+ ];
680
+
681
+ // src/configs/stylistic.ts
682
+ import { rules } from "@eslint-stylistic/metadata";
683
+ var javascriptStylistic = [
684
+ {
685
+ plugins: {
686
+ "@stylistic/js": default9
687
+ },
688
+ rules: {
689
+ // Stylistic
690
+ "@stylistic/js/array-bracket-spacing": ["error", "never"],
691
+ "@stylistic/js/arrow-spacing": ["error", { after: true, before: true }],
692
+ "@stylistic/js/block-spacing": ["error", "always"],
693
+ "@stylistic/js/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
694
+ "@stylistic/js/comma-spacing": ["error", { after: true, before: false }],
695
+ "@stylistic/js/comma-style": ["error", "last"],
696
+ "@stylistic/js/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
697
+ "@stylistic/js/dot-location": ["error", "property"],
698
+ "@stylistic/js/func-call-spacing": OFF,
699
+ "@stylistic/js/generator-star-spacing": OFF,
700
+ "@stylistic/js/indent": ["error", 2, {
701
+ ArrayExpression: 1,
702
+ CallExpression: { arguments: 1 },
703
+ FunctionDeclaration: { body: 1, parameters: 1 },
704
+ FunctionExpression: { body: 1, parameters: 1 },
705
+ ImportDeclaration: 1,
706
+ MemberExpression: 1,
707
+ ObjectExpression: 1,
708
+ SwitchCase: 1,
709
+ VariableDeclarator: 1,
710
+ flatTernaryExpressions: false,
711
+ ignoreComments: false,
712
+ ignoredNodes: [
713
+ "TemplateLiteral *",
714
+ "JSXElement",
715
+ "JSXElement > *",
716
+ "JSXAttribute",
717
+ "JSXIdentifier",
718
+ "JSXNamespacedName",
719
+ "JSXMemberExpression",
720
+ "JSXSpreadAttribute",
721
+ "JSXExpressionContainer",
722
+ "JSXOpeningElement",
723
+ "JSXClosingElement",
724
+ "JSXFragment",
725
+ "JSXOpeningFragment",
726
+ "JSXClosingFragment",
727
+ "JSXText",
728
+ "JSXEmptyExpression",
729
+ "JSXSpreadChild",
730
+ "TSTypeParameterInstantiation",
731
+ "FunctionExpression > .params[decorators.length > 0]",
732
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
733
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
734
+ ],
735
+ offsetTernaryExpressions: true,
736
+ outerIIFEBody: 1
737
+ }],
738
+ "@stylistic/js/key-spacing": ["error", { afterColon: true, beforeColon: false }],
739
+ "@stylistic/js/keyword-spacing": ["error", { after: true, before: true }],
740
+ "@stylistic/js/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
741
+ "@stylistic/js/multiline-ternary": ["error", "always-multiline"],
742
+ "@stylistic/js/no-mixed-spaces-and-tabs": "error",
743
+ "@stylistic/js/no-multi-spaces": "error",
744
+ "@stylistic/js/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
745
+ "@stylistic/js/no-tabs": "error",
746
+ "@stylistic/js/no-trailing-spaces": "error",
747
+ "@stylistic/js/no-whitespace-before-property": "error",
748
+ "@stylistic/js/object-curly-newline": ["error", { consistent: true, multiline: true }],
749
+ "@stylistic/js/object-curly-spacing": ["error", "always"],
750
+ "@stylistic/js/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
751
+ "@stylistic/js/operator-linebreak": ["error", "before"],
752
+ "@stylistic/js/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
753
+ "@stylistic/js/rest-spread-spacing": ["error", "never"],
754
+ "@stylistic/js/semi-spacing": ["error", { after: true, before: false }],
755
+ "@stylistic/js/space-before-blocks": ["error", "always"],
756
+ "@stylistic/js/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
757
+ "@stylistic/js/space-in-parens": ["error", "never"],
758
+ "@stylistic/js/space-infix-ops": "error",
759
+ "@stylistic/js/space-unary-ops": ["error", { nonwords: false, words: true }],
760
+ "@stylistic/js/spaced-comment": ["error", "always", {
761
+ block: {
762
+ balanced: true,
763
+ exceptions: ["*"],
764
+ markers: ["!"]
765
+ },
766
+ line: {
767
+ exceptions: ["/", "#"],
768
+ markers: ["/"]
769
+ }
770
+ }],
771
+ "@stylistic/js/template-curly-spacing": "error",
772
+ "@stylistic/js/template-tag-spacing": ["error", "never"],
773
+ "@stylistic/js/yield-star-spacing": ["error", "both"]
774
+ }
775
+ }
776
+ ];
777
+ var typescriptStylistic = [
778
+ {
779
+ plugins: {
780
+ "@stylistic/js": default9,
781
+ "@stylistic/ts": default10
782
+ },
783
+ rules: {
784
+ ...stylisticJsToTS(rules),
785
+ "@stylistic/ts/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
786
+ "@stylistic/ts/type-annotation-spacing": ["error", {}]
787
+ }
788
+ }
789
+ ];
790
+ function stylisticJsToTS(input) {
791
+ return {
792
+ // turn off all stylistic rules from @stylistic/js
793
+ ...Object.fromEntries(
794
+ Object.entries(input).map(([key]) => rules.find((i) => i.name === key) ? [key, OFF] : null).filter(Boolean)
795
+ ),
796
+ // rename all stylistic rules from @stylistic/js to @stylistic/ts
797
+ ...Object.fromEntries(
798
+ Object.entries(input).map(([key, value]) => {
799
+ const newKey = key.replace("@stylistic/js", "@stylistic/ts");
800
+ if (newKey === key)
801
+ return null;
802
+ return rules.find((i) => i.name === newKey) ? [key.replace("@stylistic/js", "@stylistic/ts"), value] : null;
803
+ }).filter(Boolean)
804
+ )
805
+ };
806
+ }
807
+
808
+ // src/configs/typescript.ts
809
+ import process2 from "process";
810
+ var GLOBS_TS_LIKE = [GLOB_TS, GLOB_TSX];
811
+ if (hasVue)
812
+ GLOBS_TS_LIKE.push(GLOB_VUE);
813
+ var typescript = [
814
+ {
815
+ files: GLOBS_TS_LIKE,
816
+ languageOptions: {
817
+ parser: default17,
818
+ parserOptions: {
819
+ sourceType: "module"
820
+ }
821
+ },
822
+ plugins: {
823
+ "@typescript-eslint": default11,
824
+ "antfu": default2,
825
+ "import": default4
826
+ },
827
+ rules: {
828
+ ...default11.configs["eslint-recommended"].overrides[0].rules,
829
+ ...default11.configs.strict.rules,
830
+ // TS
831
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
832
+ "@typescript-eslint/ban-ts-ignore": OFF,
833
+ "@typescript-eslint/comma-dangle": ["error", "always-multiline"],
834
+ "@typescript-eslint/consistent-indexed-object-style": OFF,
835
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
836
+ "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
837
+ "@typescript-eslint/explicit-function-return-type": OFF,
838
+ "@typescript-eslint/explicit-member-accessibility": OFF,
839
+ "@typescript-eslint/explicit-module-boundary-types": OFF,
840
+ "@typescript-eslint/naming-convention": OFF,
841
+ "@typescript-eslint/no-dupe-class-members": "error",
842
+ "@typescript-eslint/no-empty-function": OFF,
843
+ "@typescript-eslint/no-empty-interface": OFF,
844
+ "@typescript-eslint/no-explicit-any": OFF,
845
+ "@typescript-eslint/no-extra-parens": ["error", "functions"],
846
+ "@typescript-eslint/no-invalid-this": "error",
847
+ "@typescript-eslint/no-loss-of-precision": "error",
848
+ "@typescript-eslint/no-non-null-assertion": OFF,
849
+ "@typescript-eslint/no-redeclare": "error",
850
+ "@typescript-eslint/no-require-imports": "error",
851
+ "@typescript-eslint/no-unused-vars": OFF,
852
+ "@typescript-eslint/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
853
+ "@typescript-eslint/parameter-properties": OFF,
854
+ "@typescript-eslint/prefer-ts-expect-error": "error",
855
+ "@typescript-eslint/quotes": ["error", "single"],
856
+ "@typescript-eslint/semi": ["error", "never"],
857
+ "@typescript-eslint/triple-slash-reference": OFF,
858
+ "antfu/generic-spacing": "error",
859
+ "antfu/named-tuple-spacing": "error",
860
+ "antfu/no-cjs-exports": "error",
861
+ "antfu/no-const-enum": "error",
862
+ "antfu/no-ts-export-equal": "error",
863
+ "comma-dangle": OFF,
864
+ "no-dupe-class-members": OFF,
865
+ "no-extra-parens": OFF,
866
+ "no-invalid-this": OFF,
867
+ "no-loss-of-precision": OFF,
868
+ "no-redeclare": OFF,
869
+ "no-use-before-define": OFF,
870
+ "no-useless-constructor": OFF,
871
+ "quotes": OFF,
872
+ "semi": OFF
873
+ }
874
+ },
875
+ {
876
+ files: ["**/*.d.ts"],
877
+ rules: {
878
+ "eslint-comments/no-unlimited-disable": OFF,
879
+ "import/no-duplicates": OFF,
880
+ "unused-imports/no-unused-vars": OFF
881
+ }
882
+ },
883
+ {
884
+ files: ["**/*.{test,spec}.ts?(x)"],
885
+ rules: {
886
+ "no-unused-expressions": OFF
887
+ }
888
+ },
889
+ {
890
+ files: ["**/*.js", "**/*.cjs"],
891
+ rules: {
892
+ "@typescript-eslint/no-require-imports": OFF,
893
+ "@typescript-eslint/no-var-requires": OFF
894
+ }
895
+ }
896
+ ];
897
+ function typescriptWithLanguageServer({
898
+ tsconfig
899
+ }) {
900
+ return [
901
+ {
902
+ files: GLOBS_TS_LIKE,
903
+ ignores: ["**/*.md/*.*"],
904
+ languageOptions: {
905
+ parser: default17,
906
+ parserOptions: {
907
+ project: [tsconfig],
908
+ tsconfigRootDir: process2.cwd()
909
+ }
910
+ },
911
+ plugins: {
912
+ "@typescript-eslint": default11
913
+ },
914
+ rules: {
915
+ "@typescript-eslint/await-thenable": "error",
916
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
917
+ "@typescript-eslint/no-floating-promises": "error",
918
+ "@typescript-eslint/no-for-in-array": "error",
919
+ "@typescript-eslint/no-implied-eval": "error",
920
+ "@typescript-eslint/no-misused-promises": "error",
921
+ "@typescript-eslint/no-throw-literal": "error",
922
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
923
+ "@typescript-eslint/no-unsafe-argument": "error",
924
+ "@typescript-eslint/no-unsafe-assignment": "error",
925
+ "@typescript-eslint/no-unsafe-call": "error",
926
+ "@typescript-eslint/no-unsafe-member-access": "error",
927
+ "@typescript-eslint/no-unsafe-return": "error",
928
+ "@typescript-eslint/require-await": "error",
929
+ "@typescript-eslint/restrict-plus-operands": "error",
930
+ "@typescript-eslint/restrict-template-expressions": "error",
931
+ "@typescript-eslint/unbound-method": "error",
932
+ "dot-notation": OFF,
933
+ "no-implied-eval": OFF,
934
+ "no-throw-literal": OFF,
935
+ "require-await": OFF
936
+ }
937
+ }
938
+ ];
939
+ }
940
+
941
+ // src/configs/unicorn.ts
942
+ var unicorn = [
943
+ {
944
+ plugins: {
945
+ unicorn: default12
946
+ },
947
+ rules: {
948
+ // Pass error message when throwing errors
949
+ "unicorn/error-message": "error",
950
+ // Uppercase regex escapes
951
+ "unicorn/escape-case": "error",
952
+ // Array.isArray instead of instanceof
953
+ "unicorn/no-instanceof-array": "error",
954
+ // Ban `new Array` as `Array` constructor's params are ambiguous
955
+ "unicorn/no-new-array": "error",
956
+ // Prevent deprecated `new Buffer()`
957
+ "unicorn/no-new-buffer": "error",
958
+ // Keep regex literals safe!
959
+ "unicorn/no-unsafe-regex": "error",
960
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
961
+ "unicorn/number-literal-case": "error",
962
+ // includes over indexOf when checking for existence
963
+ "unicorn/prefer-includes": "error",
964
+ // Prefer using the node: protocol
965
+ "unicorn/prefer-node-protocol": "error",
966
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
967
+ "unicorn/prefer-number-properties": "error",
968
+ // String methods startsWith/endsWith instead of more complicated stuff
969
+ "unicorn/prefer-string-starts-ends-with": "error",
970
+ // textContent instead of innerText
971
+ "unicorn/prefer-text-content": "error",
972
+ // Enforce throwing type error when throwing error while checking typeof
973
+ "unicorn/prefer-type-error": "error",
974
+ // Use new when throwing error
975
+ "unicorn/throw-new-error": "error"
976
+ }
977
+ }
978
+ ];
979
+
980
+ // src/configs/vue.ts
981
+ var vue = [
982
+ {
983
+ files: [GLOB_VUE],
984
+ languageOptions: {
985
+ parser: default18,
986
+ parserOptions: {
987
+ ecmaFeatures: {
988
+ jsx: true
989
+ },
990
+ extraFileExtensions: [".vue"],
991
+ parser: hasTypeScript ? default17 : null,
992
+ sourceType: "module"
993
+ }
994
+ },
995
+ plugins: {
996
+ vue: default14
997
+ },
998
+ processor: default14.processors[".vue"],
999
+ rules: {
1000
+ ...default14.configs.base.rules,
1001
+ ...default14.configs["vue3-essential"].rules,
1002
+ ...default14.configs["vue3-strongly-recommended"].rules,
1003
+ ...default14.configs["vue3-recommended"].rules,
1004
+ "vue/array-bracket-spacing": ["error", "never"],
1005
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1006
+ "vue/block-order": ["error", {
1007
+ order: ["script", "template", "style"]
1008
+ }],
1009
+ "vue/block-spacing": ["error", "always"],
1010
+ "vue/block-tag-newline": ["error", {
1011
+ multiline: "always",
1012
+ singleline: "always"
1013
+ }],
1014
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1015
+ "vue/comma-dangle": ["error", "always-multiline"],
1016
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1017
+ "vue/comma-style": ["error", "last"],
1018
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1019
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1020
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1021
+ "vue/define-macros-order": ["error", {
1022
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1023
+ }],
1024
+ "vue/dot-location": ["error", "property"],
1025
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1026
+ "vue/eqeqeq": ["error", "smart"],
1027
+ "vue/html-comment-content-spacing": ["error", "always", {
1028
+ exceptions: ["-"]
1029
+ }],
1030
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1031
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1032
+ "vue/max-attributes-per-line": OFF,
1033
+ "vue/multi-word-component-names": OFF,
1034
+ "vue/no-constant-condition": "warn",
1035
+ "vue/no-dupe-keys": OFF,
1036
+ "vue/no-empty-pattern": "error",
1037
+ "vue/no-extra-parens": ["error", "functions"],
1038
+ "vue/no-irregular-whitespace": "error",
1039
+ "vue/no-loss-of-precision": "error",
1040
+ "vue/no-restricted-syntax": [
1041
+ "error",
1042
+ "DebuggerStatement",
1043
+ "LabeledStatement",
1044
+ "WithStatement"
1045
+ ],
1046
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1047
+ // reactivity transform
1048
+ "vue/no-setup-props-reactivity-loss": OFF,
1049
+ "vue/no-sparse-arrays": "error",
1050
+ "vue/no-unused-refs": "error",
1051
+ "vue/no-useless-v-bind": "error",
1052
+ "vue/no-v-html": OFF,
1053
+ "vue/no-v-text-v-html-on-component": OFF,
1054
+ "vue/object-curly-newline": ["error", { consistent: true, multiline: true }],
1055
+ "vue/object-curly-spacing": ["error", "always"],
1056
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1057
+ "vue/object-shorthand": [
1058
+ "error",
1059
+ "always",
1060
+ {
1061
+ avoidQuotes: true,
1062
+ ignoreConstructors: false
1063
+ }
1064
+ ],
1065
+ "vue/operator-linebreak": ["error", "before"],
1066
+ "vue/padding-line-between-blocks": ["error", "always"],
1067
+ "vue/prefer-separate-static-class": "error",
1068
+ "vue/prefer-template": "error",
1069
+ "vue/quote-props": ["error", "consistent-as-needed"],
1070
+ "vue/require-default-prop": OFF,
1071
+ "vue/require-prop-types": OFF,
1072
+ "vue/space-in-parens": ["error", "never"],
1073
+ "vue/space-infix-ops": "error",
1074
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1075
+ "vue/template-curly-spacing": "error"
1076
+ }
1077
+ }
1078
+ ];
1079
+
1080
+ // src/configs/yml.ts
1081
+ var yml = [
1082
+ {
1083
+ files: [GLOB_YAML],
1084
+ languageOptions: {
1085
+ parser: default19
1086
+ },
1087
+ plugins: {
1088
+ yml: default15
1089
+ },
1090
+ rules: {
1091
+ ...default15.configs.standard.rules,
1092
+ "@stylistic/js/spaced-comment": OFF,
1093
+ "yml/no-empty-document": OFF,
1094
+ "yml/no-empty-mapping-value": OFF,
1095
+ "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }]
1096
+ }
1097
+ }
1098
+ ];
1099
+
1100
+ // src/configs/test.ts
1101
+ var test = [
1102
+ {
1103
+ files: GLOB_TESTS,
1104
+ plugins: {
1105
+ "no-only-tests": default16
1106
+ },
1107
+ rules: {
1108
+ "no-only-tests/no-only-tests": isInEditor ? OFF : "error"
1109
+ }
1110
+ }
1111
+ ];
1112
+
1113
+ // src/presets.ts
1114
+ var presetJavaScript = [
1115
+ ...ignores,
1116
+ ...javascript,
1117
+ ...comments,
1118
+ ...node,
1119
+ ...jsdoc,
1120
+ ...imports,
1121
+ ...unicorn,
1122
+ ...javascriptStylistic
1123
+ ];
1124
+ var presetTypeScript = [
1125
+ ...typescript,
1126
+ ...typescriptStylistic
1127
+ ];
1128
+ var presetLangsExtensions = [
1129
+ ...markdown,
1130
+ ...yml,
1131
+ ...jsonc,
1132
+ ...sortPackageJson,
1133
+ ...sortTsconfig
1134
+ ];
1135
+ var presetAuto = [
1136
+ ...presetJavaScript,
1137
+ // ts
1138
+ ...hasTypeScript ? presetTypeScript : [],
1139
+ ...test,
1140
+ // vue
1141
+ ...hasVue ? vue : [],
1142
+ // language extensions
1143
+ ...presetLangsExtensions
1144
+ ];
1145
+ var presetAll = [
1146
+ ...presetJavaScript,
1147
+ ...presetTypeScript,
1148
+ ...test,
1149
+ ...vue,
1150
+ ...presetLangsExtensions
1151
+ ];
1152
+
1153
+ // src/utils.ts
1154
+ function combine(...configs) {
1155
+ return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
1156
+ }
1157
+
1158
+ // src/index.ts
1159
+ var src_default = presetAuto;
1160
+ export {
1161
+ combine,
1162
+ comments,
1163
+ src_default as default,
1164
+ hasTypeScript,
1165
+ hasVue,
1166
+ ignores,
1167
+ imports,
1168
+ isInEditor,
1169
+ javascript,
1170
+ javascriptStylistic,
1171
+ jsdoc,
1172
+ jsonc,
1173
+ markdown,
1174
+ node,
1175
+ default20 as parserJsonc,
1176
+ default17 as parserTs,
1177
+ default18 as parserVue,
1178
+ default19 as parserYml,
1179
+ default2 as pluginAntfu,
1180
+ default3 as pluginComments,
1181
+ default4 as pluginImport,
1182
+ default5 as pluginJsdoc,
1183
+ default6 as pluginJsonc,
1184
+ default7 as pluginMarkdown,
1185
+ default16 as pluginNoOnlyTests,
1186
+ default8 as pluginNode,
1187
+ default9 as pluginStylisticJs,
1188
+ default10 as pluginStylisticTs,
1189
+ default11 as pluginTs,
1190
+ default12 as pluginUnicorn,
1191
+ default13 as pluginUnusedImports,
1192
+ default14 as pluginVue,
1193
+ default15 as pluginYml,
1194
+ presetAll,
1195
+ presetAuto,
1196
+ presetJavaScript,
1197
+ presetLangsExtensions,
1198
+ presetTypeScript,
1199
+ sortPackageJson,
1200
+ sortTsconfig,
1201
+ test,
1202
+ typescript,
1203
+ typescriptStylistic,
1204
+ typescriptWithLanguageServer,
1205
+ unicorn,
1206
+ vue,
1207
+ yml
1208
+ };