@oliver139/eslint-config 5.1.0 → 5.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/cli.mjs +11 -18
- package/dist/index.d.mts +1154 -2001
- package/dist/index.mjs +130 -142
- package/dist/{lib-CLEwVDK6.mjs → lib-D3Kr7UIJ.mjs} +560 -851
- package/package.json +46 -33
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import fs$1 from "node:fs";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { isPackageExists } from "local-pkg";
|
|
8
8
|
import createCommand from "eslint-plugin-command/config";
|
|
9
|
+
import pluginE18e from "@e18e/eslint-plugin";
|
|
9
10
|
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
10
11
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
11
12
|
import pluginImportLite from "eslint-plugin-import-lite";
|
|
@@ -16,7 +17,6 @@ import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
|
16
17
|
import globals from "globals";
|
|
17
18
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
18
19
|
import { configs } from "eslint-plugin-regexp";
|
|
19
|
-
|
|
20
20
|
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
21
21
|
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
22
22
|
async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
@@ -49,7 +49,6 @@ function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
|
49
49
|
directory = path.dirname(directory);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
//#endregion
|
|
54
53
|
//#region src/globs.ts
|
|
55
54
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -134,7 +133,6 @@ const GLOB_EXCLUDE = [
|
|
|
134
133
|
"**/auto-import?(s).d.ts",
|
|
135
134
|
"**/components.d.ts"
|
|
136
135
|
];
|
|
137
|
-
|
|
138
136
|
//#endregion
|
|
139
137
|
//#region src/utils.ts
|
|
140
138
|
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -161,8 +159,8 @@ const parserPlain = {
|
|
|
161
159
|
/**
|
|
162
160
|
* Combine array and non-array configs into a single array.
|
|
163
161
|
*/
|
|
164
|
-
async function combine(...configs
|
|
165
|
-
return (await Promise.all(configs
|
|
162
|
+
async function combine(...configs) {
|
|
163
|
+
return (await Promise.all(configs)).flat();
|
|
166
164
|
}
|
|
167
165
|
/**
|
|
168
166
|
* Rename plugin prefixes in a rule object.
|
|
@@ -202,8 +200,8 @@ function renameRules(rules, map) {
|
|
|
202
200
|
* })
|
|
203
201
|
* ```
|
|
204
202
|
*/
|
|
205
|
-
function renamePluginInConfigs(configs
|
|
206
|
-
return configs
|
|
203
|
+
function renamePluginInConfigs(configs, map) {
|
|
204
|
+
return configs.map((i) => {
|
|
207
205
|
const clone = { ...i };
|
|
208
206
|
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
209
207
|
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
@@ -232,12 +230,11 @@ async function ensurePackages(packages) {
|
|
|
232
230
|
function isInEditorEnv() {
|
|
233
231
|
if (process.env.CI) return false;
|
|
234
232
|
if (isInGitHooksOrLintStaged()) return false;
|
|
235
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || process.env.ZED_ENVIRONMENT);
|
|
233
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || process.env.ZED_ENVIRONMENT && !process.env.ZED_TERM);
|
|
236
234
|
}
|
|
237
235
|
function isInGitHooksOrLintStaged() {
|
|
238
236
|
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
239
237
|
}
|
|
240
|
-
|
|
241
238
|
//#endregion
|
|
242
239
|
//#region src/configs/angular.ts
|
|
243
240
|
async function angular(options = {}) {
|
|
@@ -303,11 +300,10 @@ async function angular(options = {}) {
|
|
|
303
300
|
}
|
|
304
301
|
];
|
|
305
302
|
}
|
|
306
|
-
|
|
307
303
|
//#endregion
|
|
308
304
|
//#region src/configs/astro.ts
|
|
309
305
|
async function astro(options = {}) {
|
|
310
|
-
const { files = [GLOB_ASTRO], overrides = {}, stylistic
|
|
306
|
+
const { files = [GLOB_ASTRO], overrides = {}, stylistic = true } = options;
|
|
311
307
|
const [pluginAstro, parserAstro, parserTs] = await Promise.all([
|
|
312
308
|
interopDefault(import("eslint-plugin-astro")),
|
|
313
309
|
interopDefault(import("astro-eslint-parser")),
|
|
@@ -341,7 +337,7 @@ async function astro(options = {}) {
|
|
|
341
337
|
"astro/no-unused-define-vars-in-style": "error",
|
|
342
338
|
"astro/semi": "off",
|
|
343
339
|
"astro/valid-compile": "error",
|
|
344
|
-
...stylistic
|
|
340
|
+
...stylistic ? {
|
|
345
341
|
"style/indent": "off",
|
|
346
342
|
"style/jsx-closing-tag-location": "off",
|
|
347
343
|
"style/jsx-one-expression-per-line": "off",
|
|
@@ -351,7 +347,6 @@ async function astro(options = {}) {
|
|
|
351
347
|
}
|
|
352
348
|
}];
|
|
353
349
|
}
|
|
354
|
-
|
|
355
350
|
//#endregion
|
|
356
351
|
//#region src/configs/command.ts
|
|
357
352
|
async function command() {
|
|
@@ -360,7 +355,6 @@ async function command() {
|
|
|
360
355
|
name: "antfu/command/rules"
|
|
361
356
|
}];
|
|
362
357
|
}
|
|
363
|
-
|
|
364
358
|
//#endregion
|
|
365
359
|
//#region src/configs/comments.ts
|
|
366
360
|
async function comments() {
|
|
@@ -375,7 +369,6 @@ async function comments() {
|
|
|
375
369
|
}
|
|
376
370
|
}];
|
|
377
371
|
}
|
|
378
|
-
|
|
379
372
|
//#endregion
|
|
380
373
|
//#region src/configs/disables.ts
|
|
381
374
|
async function disables() {
|
|
@@ -430,7 +423,6 @@ async function disables() {
|
|
|
430
423
|
}
|
|
431
424
|
];
|
|
432
425
|
}
|
|
433
|
-
|
|
434
426
|
//#endregion
|
|
435
427
|
//#region src/configs/stylistic.ts
|
|
436
428
|
const StylisticConfigDefaults = {
|
|
@@ -442,7 +434,7 @@ const StylisticConfigDefaults = {
|
|
|
442
434
|
semi: false
|
|
443
435
|
};
|
|
444
436
|
async function stylistic(options = {}) {
|
|
445
|
-
const { braceStyle, experimental, indent, jsx
|
|
437
|
+
const { braceStyle, experimental, indent, jsx, lessOpinionated = false, overrides = {}, quotes, semi } = {
|
|
446
438
|
...StylisticConfigDefaults,
|
|
447
439
|
...options
|
|
448
440
|
};
|
|
@@ -451,7 +443,7 @@ async function stylistic(options = {}) {
|
|
|
451
443
|
braceStyle,
|
|
452
444
|
experimental,
|
|
453
445
|
indent,
|
|
454
|
-
jsx
|
|
446
|
+
jsx,
|
|
455
447
|
pluginName: "style",
|
|
456
448
|
quotes,
|
|
457
449
|
semi
|
|
@@ -505,7 +497,6 @@ async function stylistic(options = {}) {
|
|
|
505
497
|
}
|
|
506
498
|
}];
|
|
507
499
|
}
|
|
508
|
-
|
|
509
500
|
//#endregion
|
|
510
501
|
//#region src/configs/formatters.ts
|
|
511
502
|
function mergePrettierOptions(options, overrides) {
|
|
@@ -515,7 +506,7 @@ function mergePrettierOptions(options, overrides) {
|
|
|
515
506
|
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
516
507
|
};
|
|
517
508
|
}
|
|
518
|
-
async function formatters(options = {}, stylistic
|
|
509
|
+
async function formatters(options = {}, stylistic = {}) {
|
|
519
510
|
if (options === true) {
|
|
520
511
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
521
512
|
options = {
|
|
@@ -538,7 +529,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
538
529
|
if (options.slidev && options.markdown !== true && options.markdown !== "prettier") throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
539
530
|
const { indent, quotes, semi } = {
|
|
540
531
|
...StylisticConfigDefaults,
|
|
541
|
-
...stylistic
|
|
532
|
+
...stylistic
|
|
542
533
|
};
|
|
543
534
|
const prettierOptions = Object.assign({
|
|
544
535
|
endOfLine: "auto",
|
|
@@ -555,16 +546,17 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
555
546
|
xmlSortAttributesByKey: false,
|
|
556
547
|
xmlWhitespaceSensitivity: "ignore"
|
|
557
548
|
};
|
|
558
|
-
const dprintOptions =
|
|
549
|
+
const dprintOptions = {
|
|
559
550
|
indentWidth: typeof indent === "number" ? indent : 2,
|
|
560
551
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
561
|
-
useTabs: indent === "tab"
|
|
562
|
-
|
|
563
|
-
|
|
552
|
+
useTabs: indent === "tab",
|
|
553
|
+
...options.dprintOptions || {}
|
|
554
|
+
};
|
|
555
|
+
const configs = [{
|
|
564
556
|
name: "antfu/formatter/setup",
|
|
565
557
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
566
558
|
}];
|
|
567
|
-
if (options.css) configs
|
|
559
|
+
if (options.css) configs.push({
|
|
568
560
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
569
561
|
languageOptions: { parser: parserPlain },
|
|
570
562
|
name: "antfu/formatter/css",
|
|
@@ -580,13 +572,13 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
580
572
|
name: "antfu/formatter/less",
|
|
581
573
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
582
574
|
});
|
|
583
|
-
if (options.html) configs
|
|
575
|
+
if (options.html) configs.push({
|
|
584
576
|
files: [GLOB_HTML],
|
|
585
577
|
languageOptions: { parser: parserPlain },
|
|
586
578
|
name: "antfu/formatter/html",
|
|
587
579
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
588
580
|
});
|
|
589
|
-
if (options.xml) configs
|
|
581
|
+
if (options.xml) configs.push({
|
|
590
582
|
files: [GLOB_XML],
|
|
591
583
|
languageOptions: { parser: parserPlain },
|
|
592
584
|
name: "antfu/formatter/xml",
|
|
@@ -598,7 +590,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
598
590
|
plugins: ["@prettier/plugin-xml"]
|
|
599
591
|
})] }
|
|
600
592
|
});
|
|
601
|
-
if (options.svg) configs
|
|
593
|
+
if (options.svg) configs.push({
|
|
602
594
|
files: [GLOB_SVG],
|
|
603
595
|
languageOptions: { parser: parserPlain },
|
|
604
596
|
name: "antfu/formatter/svg",
|
|
@@ -613,7 +605,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
613
605
|
if (options.markdown) {
|
|
614
606
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
615
607
|
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
616
|
-
configs
|
|
608
|
+
configs.push({
|
|
617
609
|
files: [GLOB_MARKDOWN],
|
|
618
610
|
ignores: GLOB_SLIDEV,
|
|
619
611
|
languageOptions: { parser: parserPlain },
|
|
@@ -626,7 +618,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
626
618
|
language: "markdown"
|
|
627
619
|
}] }
|
|
628
620
|
});
|
|
629
|
-
if (options.slidev) configs
|
|
621
|
+
if (options.slidev) configs.push({
|
|
630
622
|
files: GLOB_SLIDEV,
|
|
631
623
|
languageOptions: { parser: parserPlain },
|
|
632
624
|
name: "antfu/formatter/slidev",
|
|
@@ -638,7 +630,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
638
630
|
});
|
|
639
631
|
}
|
|
640
632
|
if (options.astro) {
|
|
641
|
-
configs
|
|
633
|
+
configs.push({
|
|
642
634
|
files: [GLOB_ASTRO],
|
|
643
635
|
languageOptions: { parser: parserPlain },
|
|
644
636
|
name: "antfu/formatter/astro",
|
|
@@ -647,7 +639,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
647
639
|
plugins: ["prettier-plugin-astro"]
|
|
648
640
|
})] }
|
|
649
641
|
});
|
|
650
|
-
configs
|
|
642
|
+
configs.push({
|
|
651
643
|
files: [GLOB_ASTRO, GLOB_ASTRO_TS],
|
|
652
644
|
name: "antfu/formatter/astro/disables",
|
|
653
645
|
rules: {
|
|
@@ -661,32 +653,30 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
661
653
|
}
|
|
662
654
|
});
|
|
663
655
|
}
|
|
664
|
-
if (options.graphql) configs
|
|
656
|
+
if (options.graphql) configs.push({
|
|
665
657
|
files: [GLOB_GRAPHQL],
|
|
666
658
|
languageOptions: { parser: parserPlain },
|
|
667
659
|
name: "antfu/formatter/graphql",
|
|
668
660
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
669
661
|
});
|
|
670
|
-
return configs
|
|
662
|
+
return configs;
|
|
671
663
|
}
|
|
672
|
-
|
|
673
664
|
//#endregion
|
|
674
665
|
//#region src/configs/ignores.ts
|
|
675
666
|
async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
676
|
-
let ignores
|
|
677
|
-
if (ignoreTypeScript) ignores
|
|
678
|
-
if (typeof userIgnores === "function") ignores
|
|
679
|
-
else ignores
|
|
667
|
+
let ignores = [...GLOB_EXCLUDE];
|
|
668
|
+
if (ignoreTypeScript) ignores.push(GLOB_TS, GLOB_TSX);
|
|
669
|
+
if (typeof userIgnores === "function") ignores = userIgnores(ignores);
|
|
670
|
+
else ignores = [...ignores, ...userIgnores];
|
|
680
671
|
return [{
|
|
681
|
-
ignores
|
|
672
|
+
ignores,
|
|
682
673
|
name: "antfu/ignores"
|
|
683
674
|
}];
|
|
684
675
|
}
|
|
685
|
-
|
|
686
676
|
//#endregion
|
|
687
677
|
//#region src/configs/imports.ts
|
|
688
678
|
async function imports(options = {}) {
|
|
689
|
-
const { overrides = {}, stylistic
|
|
679
|
+
const { overrides = {}, stylistic = true } = options;
|
|
690
680
|
return [{
|
|
691
681
|
name: "antfu/imports/rules",
|
|
692
682
|
plugins: {
|
|
@@ -702,12 +692,11 @@ async function imports(options = {}) {
|
|
|
702
692
|
"import/no-duplicates": "error",
|
|
703
693
|
"import/no-mutable-exports": "error",
|
|
704
694
|
"import/no-named-default": "error",
|
|
705
|
-
...stylistic
|
|
695
|
+
...stylistic ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
|
|
706
696
|
...overrides
|
|
707
697
|
}
|
|
708
698
|
}];
|
|
709
699
|
}
|
|
710
|
-
|
|
711
700
|
//#endregion
|
|
712
701
|
//#region src/configs/javascript.ts
|
|
713
702
|
async function javascript(options = {}) {
|
|
@@ -933,11 +922,10 @@ async function javascript(options = {}) {
|
|
|
933
922
|
}
|
|
934
923
|
}];
|
|
935
924
|
}
|
|
936
|
-
|
|
937
925
|
//#endregion
|
|
938
926
|
//#region src/configs/jsdoc.ts
|
|
939
927
|
async function jsdoc(options = {}) {
|
|
940
|
-
const { stylistic
|
|
928
|
+
const { stylistic = true } = options;
|
|
941
929
|
return [{
|
|
942
930
|
name: "antfu/jsdoc/setup",
|
|
943
931
|
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
@@ -960,14 +948,13 @@ async function jsdoc(options = {}) {
|
|
|
960
948
|
"jsdoc/require-returns-check": "warn",
|
|
961
949
|
"jsdoc/require-returns-description": "warn",
|
|
962
950
|
"jsdoc/require-yields-check": "warn",
|
|
963
|
-
...stylistic
|
|
951
|
+
...stylistic ? {
|
|
964
952
|
"jsdoc/check-alignment": "warn",
|
|
965
953
|
"jsdoc/multiline-blocks": "warn"
|
|
966
954
|
} : {}
|
|
967
955
|
}
|
|
968
956
|
}];
|
|
969
957
|
}
|
|
970
|
-
|
|
971
958
|
//#endregion
|
|
972
959
|
//#region src/configs/jsonc.ts
|
|
973
960
|
async function jsonc(options = {}) {
|
|
@@ -975,8 +962,8 @@ async function jsonc(options = {}) {
|
|
|
975
962
|
GLOB_JSON,
|
|
976
963
|
GLOB_JSON5,
|
|
977
964
|
GLOB_JSONC
|
|
978
|
-
], overrides = {}, stylistic
|
|
979
|
-
const { indent = 2 } = typeof stylistic
|
|
965
|
+
], overrides = {}, stylistic = true } = options;
|
|
966
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
980
967
|
return [{
|
|
981
968
|
name: "antfu/jsonc/setup",
|
|
982
969
|
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
@@ -1011,7 +998,7 @@ async function jsonc(options = {}) {
|
|
|
1011
998
|
"jsonc/space-unary-ops": "error",
|
|
1012
999
|
"jsonc/valid-json-number": "error",
|
|
1013
1000
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
1014
|
-
...stylistic
|
|
1001
|
+
...stylistic ? {
|
|
1015
1002
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
1016
1003
|
"jsonc/comma-dangle": ["error", "never"],
|
|
1017
1004
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -1033,7 +1020,6 @@ async function jsonc(options = {}) {
|
|
|
1033
1020
|
}
|
|
1034
1021
|
}];
|
|
1035
1022
|
}
|
|
1036
|
-
|
|
1037
1023
|
//#endregion
|
|
1038
1024
|
//#region src/configs/jsx.ts
|
|
1039
1025
|
async function jsx(options = {}) {
|
|
@@ -1072,22 +1058,21 @@ async function jsx(options = {}) {
|
|
|
1072
1058
|
}
|
|
1073
1059
|
}];
|
|
1074
1060
|
}
|
|
1075
|
-
|
|
1076
1061
|
//#endregion
|
|
1077
1062
|
//#region src/configs/markdown.ts
|
|
1078
1063
|
async function markdown(options = {}) {
|
|
1079
1064
|
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
1080
|
-
const markdown
|
|
1065
|
+
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
1081
1066
|
return [
|
|
1082
1067
|
{
|
|
1083
1068
|
name: "antfu/markdown/setup",
|
|
1084
|
-
plugins: { markdown
|
|
1069
|
+
plugins: { markdown }
|
|
1085
1070
|
},
|
|
1086
1071
|
{
|
|
1087
1072
|
files,
|
|
1088
1073
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1089
1074
|
name: "antfu/markdown/processor",
|
|
1090
|
-
processor: mergeProcessors([markdown
|
|
1075
|
+
processor: mergeProcessors([markdown.processors.markdown, processorPassThrough])
|
|
1091
1076
|
},
|
|
1092
1077
|
{
|
|
1093
1078
|
files,
|
|
@@ -1098,7 +1083,8 @@ async function markdown(options = {}) {
|
|
|
1098
1083
|
files,
|
|
1099
1084
|
name: "antfu/markdown/rules",
|
|
1100
1085
|
rules: {
|
|
1101
|
-
...markdown
|
|
1086
|
+
...markdown.configs.recommended.at(0)?.rules,
|
|
1087
|
+
"markdown/fenced-code-language": "off",
|
|
1102
1088
|
"markdown/no-missing-label-refs": "off",
|
|
1103
1089
|
...overridesMarkdown
|
|
1104
1090
|
}
|
|
@@ -1124,6 +1110,7 @@ async function markdown(options = {}) {
|
|
|
1124
1110
|
name: "antfu/markdown/disables/code",
|
|
1125
1111
|
rules: {
|
|
1126
1112
|
"antfu/no-top-level-await": "off",
|
|
1113
|
+
"e18e/prefer-static-regex": "off",
|
|
1127
1114
|
"no-alert": "off",
|
|
1128
1115
|
"no-console": "off",
|
|
1129
1116
|
"no-labels": "off",
|
|
@@ -1159,7 +1146,6 @@ async function markdown(options = {}) {
|
|
|
1159
1146
|
}
|
|
1160
1147
|
];
|
|
1161
1148
|
}
|
|
1162
|
-
|
|
1163
1149
|
//#endregion
|
|
1164
1150
|
//#region src/configs/nextjs.ts
|
|
1165
1151
|
function normalizeRules(rules) {
|
|
@@ -1192,7 +1178,6 @@ async function nextjs(options = {}) {
|
|
|
1192
1178
|
settings: { react: { version: "detect" } }
|
|
1193
1179
|
}];
|
|
1194
1180
|
}
|
|
1195
|
-
|
|
1196
1181
|
//#endregion
|
|
1197
1182
|
//#region src/configs/node.ts
|
|
1198
1183
|
async function node() {
|
|
@@ -1214,7 +1199,6 @@ async function node() {
|
|
|
1214
1199
|
}
|
|
1215
1200
|
}];
|
|
1216
1201
|
}
|
|
1217
|
-
|
|
1218
1202
|
//#endregion
|
|
1219
1203
|
//#region src/configs/perfectionist.ts
|
|
1220
1204
|
/**
|
|
@@ -1270,14 +1254,13 @@ async function perfectionist() {
|
|
|
1270
1254
|
}
|
|
1271
1255
|
}];
|
|
1272
1256
|
}
|
|
1273
|
-
|
|
1274
1257
|
//#endregion
|
|
1275
1258
|
//#region src/configs/pnpm.ts
|
|
1276
1259
|
async function detectCatalogUsage() {
|
|
1277
1260
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1278
1261
|
if (!workspaceFile) return false;
|
|
1279
|
-
const yaml
|
|
1280
|
-
return yaml
|
|
1262
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1263
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1281
1264
|
}
|
|
1282
1265
|
async function pnpm(options) {
|
|
1283
1266
|
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
@@ -1285,9 +1268,9 @@ async function pnpm(options) {
|
|
|
1285
1268
|
interopDefault(import("eslint-plugin-yml")),
|
|
1286
1269
|
interopDefault(import("yaml-eslint-parser"))
|
|
1287
1270
|
]);
|
|
1288
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1289
|
-
const configs
|
|
1290
|
-
if (json) configs
|
|
1271
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1272
|
+
const configs = [];
|
|
1273
|
+
if (json) configs.push({
|
|
1291
1274
|
files: ["package.json", "**/package.json"],
|
|
1292
1275
|
language: "jsonc/x",
|
|
1293
1276
|
name: "antfu/pnpm/package-json",
|
|
@@ -1301,8 +1284,8 @@ async function pnpm(options) {
|
|
|
1301
1284
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1302
1285
|
}
|
|
1303
1286
|
});
|
|
1304
|
-
if (yaml
|
|
1305
|
-
configs
|
|
1287
|
+
if (yaml) {
|
|
1288
|
+
configs.push({
|
|
1306
1289
|
files: ["pnpm-workspace.yaml"],
|
|
1307
1290
|
languageOptions: { parser: yamlParser },
|
|
1308
1291
|
name: "antfu/pnpm/pnpm-workspace-yaml",
|
|
@@ -1316,7 +1299,7 @@ async function pnpm(options) {
|
|
|
1316
1299
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1317
1300
|
}
|
|
1318
1301
|
});
|
|
1319
|
-
if (sort) configs
|
|
1302
|
+
if (sort) configs.push({
|
|
1320
1303
|
files: ["pnpm-workspace.yaml"],
|
|
1321
1304
|
languageOptions: { parser: yamlParser },
|
|
1322
1305
|
name: "antfu/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1395,9 +1378,8 @@ async function pnpm(options) {
|
|
|
1395
1378
|
] }
|
|
1396
1379
|
});
|
|
1397
1380
|
}
|
|
1398
|
-
return configs
|
|
1381
|
+
return configs;
|
|
1399
1382
|
}
|
|
1400
|
-
|
|
1401
1383
|
//#endregion
|
|
1402
1384
|
//#region src/configs/react.ts
|
|
1403
1385
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1590,7 +1572,6 @@ async function react(options = {}) {
|
|
|
1590
1572
|
}] : []
|
|
1591
1573
|
];
|
|
1592
1574
|
}
|
|
1593
|
-
|
|
1594
1575
|
//#endregion
|
|
1595
1576
|
//#region src/configs/regexp.ts
|
|
1596
1577
|
async function regexp(options = {}) {
|
|
@@ -1608,11 +1589,10 @@ async function regexp(options = {}) {
|
|
|
1608
1589
|
}
|
|
1609
1590
|
}];
|
|
1610
1591
|
}
|
|
1611
|
-
|
|
1612
1592
|
//#endregion
|
|
1613
1593
|
//#region src/configs/solid.ts
|
|
1614
1594
|
async function solid(options = {}) {
|
|
1615
|
-
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript
|
|
1595
|
+
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript = true } = options;
|
|
1616
1596
|
await ensurePackages(["eslint-plugin-solid"]);
|
|
1617
1597
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1618
1598
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -1651,7 +1631,7 @@ async function solid(options = {}) {
|
|
|
1651
1631
|
"solid/reactivity": "warn",
|
|
1652
1632
|
"solid/self-closing-comp": "error",
|
|
1653
1633
|
"solid/style-prop": ["error", { styleProps: ["style", "css"] }],
|
|
1654
|
-
...typescript
|
|
1634
|
+
...typescript ? {
|
|
1655
1635
|
"solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
|
|
1656
1636
|
"solid/no-unknown-namespaces": "off"
|
|
1657
1637
|
} : {},
|
|
@@ -1659,7 +1639,6 @@ async function solid(options = {}) {
|
|
|
1659
1639
|
}
|
|
1660
1640
|
}];
|
|
1661
1641
|
}
|
|
1662
|
-
|
|
1663
1642
|
//#endregion
|
|
1664
1643
|
//#region src/configs/sort.ts
|
|
1665
1644
|
/**
|
|
@@ -1893,12 +1872,11 @@ function sortTsconfig() {
|
|
|
1893
1872
|
] }
|
|
1894
1873
|
}];
|
|
1895
1874
|
}
|
|
1896
|
-
|
|
1897
1875
|
//#endregion
|
|
1898
1876
|
//#region src/configs/svelte.ts
|
|
1899
1877
|
async function svelte(options = {}) {
|
|
1900
|
-
const { files = [GLOB_SVELTE], overrides = {}, stylistic
|
|
1901
|
-
const { indent = 2, quotes = "single" } = typeof stylistic
|
|
1878
|
+
const { files = [GLOB_SVELTE], overrides = {}, stylistic = true } = options;
|
|
1879
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1902
1880
|
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1903
1881
|
const [pluginSvelte, parserSvelte] = await Promise.all([interopDefault(import("eslint-plugin-svelte")), interopDefault(import("svelte-eslint-parser"))]);
|
|
1904
1882
|
return [{
|
|
@@ -1949,7 +1927,7 @@ async function svelte(options = {}) {
|
|
|
1949
1927
|
vars: "all",
|
|
1950
1928
|
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1951
1929
|
}],
|
|
1952
|
-
...stylistic
|
|
1930
|
+
...stylistic ? {
|
|
1953
1931
|
"style/indent": "off",
|
|
1954
1932
|
"style/no-trailing-spaces": "off",
|
|
1955
1933
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
@@ -1968,7 +1946,6 @@ async function svelte(options = {}) {
|
|
|
1968
1946
|
}
|
|
1969
1947
|
}];
|
|
1970
1948
|
}
|
|
1971
|
-
|
|
1972
1949
|
//#endregion
|
|
1973
1950
|
//#region src/configs/test.ts
|
|
1974
1951
|
let _pluginTest;
|
|
@@ -1999,6 +1976,7 @@ async function test(options = {}) {
|
|
|
1999
1976
|
"test/prefer-hooks-in-order": "error",
|
|
2000
1977
|
"test/prefer-lowercase-title": "error",
|
|
2001
1978
|
"antfu/no-top-level-await": "off",
|
|
1979
|
+
"e18e/prefer-static-regex": "off",
|
|
2002
1980
|
"no-unused-expressions": "off",
|
|
2003
1981
|
"node/prefer-global/process": "off",
|
|
2004
1982
|
"ts/explicit-function-return-type": "off",
|
|
@@ -2006,12 +1984,11 @@ async function test(options = {}) {
|
|
|
2006
1984
|
}
|
|
2007
1985
|
}];
|
|
2008
1986
|
}
|
|
2009
|
-
|
|
2010
1987
|
//#endregion
|
|
2011
1988
|
//#region src/configs/toml.ts
|
|
2012
1989
|
async function toml(options = {}) {
|
|
2013
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
2014
|
-
const { indent = 2 } = typeof stylistic
|
|
1990
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1991
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2015
1992
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
2016
1993
|
return [{
|
|
2017
1994
|
name: "antfu/toml/setup",
|
|
@@ -2030,7 +2007,7 @@ async function toml(options = {}) {
|
|
|
2030
2007
|
"toml/precision-of-integer": "error",
|
|
2031
2008
|
"toml/tables-order": "error",
|
|
2032
2009
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
2033
|
-
...stylistic
|
|
2010
|
+
...stylistic ? {
|
|
2034
2011
|
"toml/array-bracket-newline": "error",
|
|
2035
2012
|
"toml/array-bracket-spacing": "error",
|
|
2036
2013
|
"toml/array-element-newline": "error",
|
|
@@ -2047,18 +2024,17 @@ async function toml(options = {}) {
|
|
|
2047
2024
|
}
|
|
2048
2025
|
}];
|
|
2049
2026
|
}
|
|
2050
|
-
|
|
2051
2027
|
//#endregion
|
|
2052
2028
|
//#region src/configs/typescript.ts
|
|
2053
2029
|
async function typescript(options = {}) {
|
|
2054
2030
|
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
2055
2031
|
const files = options.files ?? [
|
|
2056
|
-
|
|
2057
|
-
|
|
2032
|
+
"**/*.?([cm])ts",
|
|
2033
|
+
"**/*.?([cm])tsx",
|
|
2058
2034
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2059
2035
|
];
|
|
2060
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
2061
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
2036
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
2037
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`, "**/*.astro/*.ts"];
|
|
2062
2038
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
2063
2039
|
const isTypeAware = !!tsconfigPath;
|
|
2064
2040
|
const typeAwareRules = {
|
|
@@ -2088,10 +2064,10 @@ async function typescript(options = {}) {
|
|
|
2088
2064
|
"ts/unbound-method": "error"
|
|
2089
2065
|
};
|
|
2090
2066
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
2091
|
-
function makeParser(typeAware, files
|
|
2067
|
+
function makeParser(typeAware, files, ignores) {
|
|
2092
2068
|
return {
|
|
2093
|
-
files
|
|
2094
|
-
...ignores
|
|
2069
|
+
files,
|
|
2070
|
+
...ignores ? { ignores } : {},
|
|
2095
2071
|
languageOptions: {
|
|
2096
2072
|
parser: parserTs,
|
|
2097
2073
|
parserOptions: {
|
|
@@ -2182,7 +2158,7 @@ async function typescript(options = {}) {
|
|
|
2182
2158
|
}] : [],
|
|
2183
2159
|
...erasableOnly ? [{
|
|
2184
2160
|
name: "antfu/typescript/erasable-syntax-only",
|
|
2185
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
2161
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-D3Kr7UIJ.mjs")) },
|
|
2186
2162
|
rules: {
|
|
2187
2163
|
"erasable-syntax-only/enums": "error",
|
|
2188
2164
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -2192,7 +2168,6 @@ async function typescript(options = {}) {
|
|
|
2192
2168
|
}] : []
|
|
2193
2169
|
];
|
|
2194
2170
|
}
|
|
2195
|
-
|
|
2196
2171
|
//#endregion
|
|
2197
2172
|
//#region src/configs/unicorn.ts
|
|
2198
2173
|
async function unicorn(options = {}) {
|
|
@@ -2222,7 +2197,6 @@ async function unicorn(options = {}) {
|
|
|
2222
2197
|
}
|
|
2223
2198
|
}];
|
|
2224
2199
|
}
|
|
2225
|
-
|
|
2226
2200
|
//#endregion
|
|
2227
2201
|
//#region src/configs/unocss.ts
|
|
2228
2202
|
async function unocss(options = {}) {
|
|
@@ -2239,13 +2213,12 @@ async function unocss(options = {}) {
|
|
|
2239
2213
|
}
|
|
2240
2214
|
}];
|
|
2241
2215
|
}
|
|
2242
|
-
|
|
2243
2216
|
//#endregion
|
|
2244
2217
|
//#region src/configs/vue.ts
|
|
2245
2218
|
async function vue(options = {}) {
|
|
2246
|
-
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic
|
|
2219
|
+
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic = true, vueVersion = 3 } = options;
|
|
2247
2220
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
2248
|
-
const { braceStyle = "1tbs", indent = 2 } = typeof stylistic
|
|
2221
|
+
const { braceStyle = "1tbs", indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2249
2222
|
if (a11y) await ensurePackages(["eslint-plugin-vuejs-accessibility"]);
|
|
2250
2223
|
const [pluginVue, parserVue, processorVueBlocks, pluginVueA11y] = await Promise.all([
|
|
2251
2224
|
interopDefault(import("eslint-plugin-vue")),
|
|
@@ -2381,7 +2354,7 @@ async function vue(options = {}) {
|
|
|
2381
2354
|
nonwords: false,
|
|
2382
2355
|
words: true
|
|
2383
2356
|
}],
|
|
2384
|
-
...stylistic
|
|
2357
|
+
...stylistic ? {
|
|
2385
2358
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2386
2359
|
"vue/arrow-spacing": ["error", {
|
|
2387
2360
|
after: true,
|
|
@@ -2453,12 +2426,11 @@ async function vue(options = {}) {
|
|
|
2453
2426
|
}
|
|
2454
2427
|
}];
|
|
2455
2428
|
}
|
|
2456
|
-
|
|
2457
2429
|
//#endregion
|
|
2458
2430
|
//#region src/configs/yaml.ts
|
|
2459
2431
|
async function yaml(options = {}) {
|
|
2460
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2461
|
-
const { indent = 2, quotes = "single" } = typeof stylistic
|
|
2432
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2433
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2462
2434
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2463
2435
|
return [{
|
|
2464
2436
|
name: "antfu/yaml/setup",
|
|
@@ -2476,7 +2448,7 @@ async function yaml(options = {}) {
|
|
|
2476
2448
|
"yaml/no-irregular-whitespace": "error",
|
|
2477
2449
|
"yaml/plain-scalar": "error",
|
|
2478
2450
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2479
|
-
...stylistic
|
|
2451
|
+
...stylistic ? {
|
|
2480
2452
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2481
2453
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2482
2454
|
"yaml/flow-mapping-curly-newline": "error",
|
|
@@ -2496,7 +2468,22 @@ async function yaml(options = {}) {
|
|
|
2496
2468
|
}
|
|
2497
2469
|
}];
|
|
2498
2470
|
}
|
|
2499
|
-
|
|
2471
|
+
//#endregion
|
|
2472
|
+
//#region src/configs/e18e.ts
|
|
2473
|
+
async function e18e(options = {}) {
|
|
2474
|
+
const { isInEditor = false, modernization = true, type = "app", moduleReplacements = type === "lib" && isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
2475
|
+
const configs = pluginE18e.configs;
|
|
2476
|
+
return [{
|
|
2477
|
+
name: "antfu/e18e/rules",
|
|
2478
|
+
plugins: { e18e: pluginE18e },
|
|
2479
|
+
rules: {
|
|
2480
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
2481
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
2482
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
2483
|
+
...overrides
|
|
2484
|
+
}
|
|
2485
|
+
}];
|
|
2486
|
+
}
|
|
2500
2487
|
//#endregion
|
|
2501
2488
|
//#region src/factory.ts
|
|
2502
2489
|
const flatConfigProps = [
|
|
@@ -2538,7 +2525,7 @@ const defaultPluginRenaming = {
|
|
|
2538
2525
|
* The merged ESLint configurations.
|
|
2539
2526
|
*/
|
|
2540
2527
|
function antfu(options = {}, ...userConfigs) {
|
|
2541
|
-
const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2528
|
+
const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2542
2529
|
let isInEditor = options.isInEditor;
|
|
2543
2530
|
if (isInEditor == null) {
|
|
2544
2531
|
isInEditor = isInEditorEnv();
|
|
@@ -2546,113 +2533,117 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2546
2533
|
}
|
|
2547
2534
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2548
2535
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = typeof enableJsx === "object" ? true : enableJsx;
|
|
2549
|
-
const configs
|
|
2550
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
2536
|
+
const configs = [];
|
|
2537
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2551
2538
|
name: "antfu/gitignore",
|
|
2552
2539
|
...enableGitignore
|
|
2553
2540
|
})]));
|
|
2554
|
-
else configs
|
|
2541
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2555
2542
|
name: "antfu/gitignore",
|
|
2556
2543
|
strict: false
|
|
2557
2544
|
})]));
|
|
2558
2545
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2559
2546
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2560
|
-
configs
|
|
2547
|
+
configs.push(ignores(userIgnores, !enableTypeScript), javascript({
|
|
2561
2548
|
isInEditor,
|
|
2562
2549
|
overrides: getOverrides(options, "javascript")
|
|
2563
2550
|
}), comments(), command(), perfectionist());
|
|
2564
|
-
if (enableNode) configs
|
|
2565
|
-
if (enableJsdoc) configs
|
|
2566
|
-
if (enableImports) configs
|
|
2551
|
+
if (enableNode) configs.push(node());
|
|
2552
|
+
if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2553
|
+
if (enableImports) configs.push(imports({
|
|
2567
2554
|
stylistic: stylisticOptions,
|
|
2568
2555
|
...resolveSubOptions(options, "imports")
|
|
2569
2556
|
}));
|
|
2570
|
-
if (
|
|
2557
|
+
if (enableE18e) configs.push(e18e({
|
|
2558
|
+
isInEditor,
|
|
2559
|
+
...enableE18e === true ? {} : enableE18e
|
|
2560
|
+
}));
|
|
2561
|
+
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2571
2562
|
if (enableVue) componentExts.push("vue");
|
|
2572
|
-
if (enableJsx) configs
|
|
2573
|
-
if (enableTypeScript) configs
|
|
2563
|
+
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
2564
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2574
2565
|
...typescriptOptions,
|
|
2575
2566
|
componentExts,
|
|
2576
2567
|
overrides: getOverrides(options, "typescript"),
|
|
2577
|
-
type:
|
|
2568
|
+
type: appType
|
|
2578
2569
|
}));
|
|
2579
|
-
if (stylisticOptions) configs
|
|
2570
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2580
2571
|
...stylisticOptions,
|
|
2581
2572
|
lessOpinionated: options.lessOpinionated,
|
|
2582
2573
|
overrides: getOverrides(options, "stylistic")
|
|
2583
2574
|
}));
|
|
2584
|
-
if (enableRegexp) configs
|
|
2585
|
-
if (options.test ?? true) configs
|
|
2575
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2576
|
+
if (options.test ?? true) configs.push(test({
|
|
2586
2577
|
isInEditor,
|
|
2587
2578
|
overrides: getOverrides(options, "test")
|
|
2588
2579
|
}));
|
|
2589
|
-
if (enableVue) configs
|
|
2580
|
+
if (enableVue) configs.push(vue({
|
|
2590
2581
|
...resolveSubOptions(options, "vue"),
|
|
2591
2582
|
overrides: getOverrides(options, "vue"),
|
|
2592
2583
|
stylistic: stylisticOptions,
|
|
2593
2584
|
typescript: !!enableTypeScript
|
|
2594
2585
|
}));
|
|
2595
|
-
if (enableReact) configs
|
|
2586
|
+
if (enableReact) configs.push(react({
|
|
2596
2587
|
...typescriptOptions,
|
|
2597
2588
|
...resolveSubOptions(options, "react"),
|
|
2598
2589
|
overrides: getOverrides(options, "react"),
|
|
2599
2590
|
tsconfigPath
|
|
2600
2591
|
}));
|
|
2601
|
-
if (enableNextjs) configs
|
|
2602
|
-
if (enableSolid) configs
|
|
2592
|
+
if (enableNextjs) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2593
|
+
if (enableSolid) configs.push(solid({
|
|
2603
2594
|
overrides: getOverrides(options, "solid"),
|
|
2604
2595
|
tsconfigPath,
|
|
2605
2596
|
typescript: !!enableTypeScript
|
|
2606
2597
|
}));
|
|
2607
|
-
if (enableSvelte) configs
|
|
2598
|
+
if (enableSvelte) configs.push(svelte({
|
|
2608
2599
|
overrides: getOverrides(options, "svelte"),
|
|
2609
2600
|
stylistic: stylisticOptions,
|
|
2610
2601
|
typescript: !!enableTypeScript
|
|
2611
2602
|
}));
|
|
2612
|
-
if (enableUnoCSS) configs
|
|
2603
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2613
2604
|
...resolveSubOptions(options, "unocss"),
|
|
2614
2605
|
overrides: getOverrides(options, "unocss")
|
|
2615
2606
|
}));
|
|
2616
|
-
if (enableAstro) configs
|
|
2607
|
+
if (enableAstro) configs.push(astro({
|
|
2617
2608
|
overrides: getOverrides(options, "astro"),
|
|
2618
2609
|
stylistic: stylisticOptions
|
|
2619
2610
|
}));
|
|
2620
|
-
if (enableAngular) configs
|
|
2621
|
-
if (options.jsonc ?? true) configs
|
|
2611
|
+
if (enableAngular) configs.push(angular({ overrides: getOverrides(options, "angular") }));
|
|
2612
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2622
2613
|
overrides: getOverrides(options, "jsonc"),
|
|
2623
2614
|
stylistic: stylisticOptions
|
|
2624
2615
|
}), sortPackageJson(), sortTsconfig());
|
|
2625
2616
|
if (enableCatalogs) {
|
|
2626
2617
|
const optionsPnpm = resolveSubOptions(options, "pnpm");
|
|
2627
|
-
configs
|
|
2618
|
+
configs.push(pnpm({
|
|
2628
2619
|
isInEditor,
|
|
2629
2620
|
json: options.jsonc !== false,
|
|
2630
2621
|
yaml: options.yaml !== false,
|
|
2631
2622
|
...optionsPnpm
|
|
2632
2623
|
}));
|
|
2633
2624
|
}
|
|
2634
|
-
if (options.yaml ?? true) configs
|
|
2625
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2635
2626
|
overrides: getOverrides(options, "yaml"),
|
|
2636
2627
|
stylistic: stylisticOptions
|
|
2637
2628
|
}));
|
|
2638
|
-
if (options.toml ?? true) configs
|
|
2629
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2639
2630
|
overrides: getOverrides(options, "toml"),
|
|
2640
2631
|
stylistic: stylisticOptions
|
|
2641
2632
|
}));
|
|
2642
|
-
if (options.markdown ?? true) configs
|
|
2633
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2643
2634
|
componentExts,
|
|
2644
2635
|
overrides: getOverrides(options, "markdown")
|
|
2645
2636
|
}));
|
|
2646
|
-
if (options.formatters) configs
|
|
2647
|
-
configs
|
|
2637
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2638
|
+
configs.push(disables());
|
|
2648
2639
|
if ("files" in options) throw new Error("[@oliver139/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
2649
2640
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2650
2641
|
if (key in options) acc[key] = options[key];
|
|
2651
2642
|
return acc;
|
|
2652
2643
|
}, {});
|
|
2653
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2644
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2654
2645
|
let composer = new FlatConfigComposer();
|
|
2655
|
-
composer = composer.append(...configs
|
|
2646
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2656
2647
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2657
2648
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2658
2649
|
"unused-imports/no-unused-imports",
|
|
@@ -2671,7 +2662,6 @@ function getOverrides(options, key) {
|
|
|
2671
2662
|
..."overrides" in sub ? sub.overrides : {}
|
|
2672
2663
|
};
|
|
2673
2664
|
}
|
|
2674
|
-
|
|
2675
2665
|
//#endregion
|
|
2676
2666
|
//#region src/config-presets.ts
|
|
2677
2667
|
const CONFIG_PRESET_FULL_ON = {
|
|
@@ -2729,10 +2719,8 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2729
2719
|
vue: false,
|
|
2730
2720
|
yaml: false
|
|
2731
2721
|
};
|
|
2732
|
-
|
|
2733
2722
|
//#endregion
|
|
2734
2723
|
//#region src/index.ts
|
|
2735
2724
|
var src_default = antfu;
|
|
2736
|
-
|
|
2737
2725
|
//#endregion
|
|
2738
|
-
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
|
2726
|
+
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|