@oliver139/eslint-config 5.0.1 → 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/README.md +66 -0
- package/dist/cli.mjs +16 -23
- package/dist/index.d.mts +1222 -1996
- package/dist/index.mjs +169 -153
- package/dist/{lib-DRA-mDV0.mjs → lib-D3Kr7UIJ.mjs} +560 -851
- package/package.json +65 -53
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);
|
|
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,15 +922,16 @@ 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 [{
|
|
930
|
+
name: "antfu/jsdoc/setup",
|
|
931
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
932
|
+
}, {
|
|
942
933
|
files: [GLOB_SRC],
|
|
943
934
|
name: "antfu/jsdoc/rules",
|
|
944
|
-
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
945
935
|
rules: {
|
|
946
936
|
"jsdoc/check-access": "warn",
|
|
947
937
|
"jsdoc/check-param-names": "warn",
|
|
@@ -958,14 +948,13 @@ async function jsdoc(options = {}) {
|
|
|
958
948
|
"jsdoc/require-returns-check": "warn",
|
|
959
949
|
"jsdoc/require-returns-description": "warn",
|
|
960
950
|
"jsdoc/require-yields-check": "warn",
|
|
961
|
-
...stylistic
|
|
951
|
+
...stylistic ? {
|
|
962
952
|
"jsdoc/check-alignment": "warn",
|
|
963
953
|
"jsdoc/multiline-blocks": "warn"
|
|
964
954
|
} : {}
|
|
965
955
|
}
|
|
966
956
|
}];
|
|
967
957
|
}
|
|
968
|
-
|
|
969
958
|
//#endregion
|
|
970
959
|
//#region src/configs/jsonc.ts
|
|
971
960
|
async function jsonc(options = {}) {
|
|
@@ -973,15 +962,14 @@ async function jsonc(options = {}) {
|
|
|
973
962
|
GLOB_JSON,
|
|
974
963
|
GLOB_JSON5,
|
|
975
964
|
GLOB_JSONC
|
|
976
|
-
], overrides = {}, stylistic
|
|
977
|
-
const { indent = 2 } = typeof stylistic
|
|
978
|
-
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
965
|
+
], overrides = {}, stylistic = true } = options;
|
|
966
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
979
967
|
return [{
|
|
980
968
|
name: "antfu/jsonc/setup",
|
|
981
|
-
plugins: { jsonc:
|
|
969
|
+
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
982
970
|
}, {
|
|
983
971
|
files,
|
|
984
|
-
|
|
972
|
+
language: "jsonc/x",
|
|
985
973
|
name: "antfu/jsonc/rules",
|
|
986
974
|
rules: {
|
|
987
975
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -1010,7 +998,7 @@ async function jsonc(options = {}) {
|
|
|
1010
998
|
"jsonc/space-unary-ops": "error",
|
|
1011
999
|
"jsonc/valid-json-number": "error",
|
|
1012
1000
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
1013
|
-
...stylistic
|
|
1001
|
+
...stylistic ? {
|
|
1014
1002
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
1015
1003
|
"jsonc/comma-dangle": ["error", "never"],
|
|
1016
1004
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -1032,7 +1020,6 @@ async function jsonc(options = {}) {
|
|
|
1032
1020
|
}
|
|
1033
1021
|
}];
|
|
1034
1022
|
}
|
|
1035
|
-
|
|
1036
1023
|
//#endregion
|
|
1037
1024
|
//#region src/configs/jsx.ts
|
|
1038
1025
|
async function jsx(options = {}) {
|
|
@@ -1071,34 +1058,59 @@ async function jsx(options = {}) {
|
|
|
1071
1058
|
}
|
|
1072
1059
|
}];
|
|
1073
1060
|
}
|
|
1074
|
-
|
|
1075
1061
|
//#endregion
|
|
1076
1062
|
//#region src/configs/markdown.ts
|
|
1077
1063
|
async function markdown(options = {}) {
|
|
1078
|
-
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
|
|
1079
|
-
const markdown
|
|
1064
|
+
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
1065
|
+
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
1080
1066
|
return [
|
|
1081
1067
|
{
|
|
1082
1068
|
name: "antfu/markdown/setup",
|
|
1083
|
-
plugins: { markdown
|
|
1069
|
+
plugins: { markdown }
|
|
1084
1070
|
},
|
|
1085
1071
|
{
|
|
1086
1072
|
files,
|
|
1087
1073
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1088
1074
|
name: "antfu/markdown/processor",
|
|
1089
|
-
processor: mergeProcessors([markdown
|
|
1075
|
+
processor: mergeProcessors([markdown.processors.markdown, processorPassThrough])
|
|
1090
1076
|
},
|
|
1091
1077
|
{
|
|
1092
1078
|
files,
|
|
1093
|
-
|
|
1079
|
+
language: gfm ? "markdown/gfm" : "markdown/commonmark",
|
|
1094
1080
|
name: "antfu/markdown/parser"
|
|
1095
1081
|
},
|
|
1082
|
+
{
|
|
1083
|
+
files,
|
|
1084
|
+
name: "antfu/markdown/rules",
|
|
1085
|
+
rules: {
|
|
1086
|
+
...markdown.configs.recommended.at(0)?.rules,
|
|
1087
|
+
"markdown/fenced-code-language": "off",
|
|
1088
|
+
"markdown/no-missing-label-refs": "off",
|
|
1089
|
+
...overridesMarkdown
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
files,
|
|
1094
|
+
name: "antfu/markdown/disables/markdown",
|
|
1095
|
+
rules: {
|
|
1096
|
+
"command/command": "off",
|
|
1097
|
+
"no-irregular-whitespace": "off",
|
|
1098
|
+
"perfectionist/sort-exports": "off",
|
|
1099
|
+
"perfectionist/sort-imports": "off",
|
|
1100
|
+
"regexp/no-legacy-features": "off",
|
|
1101
|
+
"regexp/no-missing-g-flag": "off",
|
|
1102
|
+
"regexp/no-useless-dollar-replacements": "off",
|
|
1103
|
+
"regexp/no-useless-flag": "off",
|
|
1104
|
+
"style/indent": "off"
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1096
1107
|
{
|
|
1097
1108
|
files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
|
|
1098
1109
|
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
1099
|
-
name: "antfu/markdown/disables",
|
|
1110
|
+
name: "antfu/markdown/disables/code",
|
|
1100
1111
|
rules: {
|
|
1101
1112
|
"antfu/no-top-level-await": "off",
|
|
1113
|
+
"e18e/prefer-static-regex": "off",
|
|
1102
1114
|
"no-alert": "off",
|
|
1103
1115
|
"no-console": "off",
|
|
1104
1116
|
"no-labels": "off",
|
|
@@ -1134,7 +1146,6 @@ async function markdown(options = {}) {
|
|
|
1134
1146
|
}
|
|
1135
1147
|
];
|
|
1136
1148
|
}
|
|
1137
|
-
|
|
1138
1149
|
//#endregion
|
|
1139
1150
|
//#region src/configs/nextjs.ts
|
|
1140
1151
|
function normalizeRules(rules) {
|
|
@@ -1167,14 +1178,15 @@ async function nextjs(options = {}) {
|
|
|
1167
1178
|
settings: { react: { version: "detect" } }
|
|
1168
1179
|
}];
|
|
1169
1180
|
}
|
|
1170
|
-
|
|
1171
1181
|
//#endregion
|
|
1172
1182
|
//#region src/configs/node.ts
|
|
1173
1183
|
async function node() {
|
|
1174
1184
|
return [{
|
|
1185
|
+
name: "antfu/node/setup",
|
|
1186
|
+
plugins: { node: pluginNode }
|
|
1187
|
+
}, {
|
|
1175
1188
|
files: [GLOB_SRC],
|
|
1176
1189
|
name: "antfu/node/rules",
|
|
1177
|
-
plugins: { node: pluginNode },
|
|
1178
1190
|
rules: {
|
|
1179
1191
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1180
1192
|
"node/no-deprecated-api": "error",
|
|
@@ -1187,7 +1199,6 @@ async function node() {
|
|
|
1187
1199
|
}
|
|
1188
1200
|
}];
|
|
1189
1201
|
}
|
|
1190
|
-
|
|
1191
1202
|
//#endregion
|
|
1192
1203
|
//#region src/configs/perfectionist.ts
|
|
1193
1204
|
/**
|
|
@@ -1228,6 +1239,8 @@ async function perfectionist() {
|
|
|
1228
1239
|
newlinesBetween: "ignore",
|
|
1229
1240
|
newlinesInside: "ignore",
|
|
1230
1241
|
order: "asc",
|
|
1242
|
+
partitionByComment: true,
|
|
1243
|
+
partitionByNewLine: true,
|
|
1231
1244
|
type: "natural"
|
|
1232
1245
|
}],
|
|
1233
1246
|
"perfectionist/sort-named-exports": ["error", {
|
|
@@ -1241,27 +1254,25 @@ async function perfectionist() {
|
|
|
1241
1254
|
}
|
|
1242
1255
|
}];
|
|
1243
1256
|
}
|
|
1244
|
-
|
|
1245
1257
|
//#endregion
|
|
1246
1258
|
//#region src/configs/pnpm.ts
|
|
1247
1259
|
async function detectCatalogUsage() {
|
|
1248
1260
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1249
1261
|
if (!workspaceFile) return false;
|
|
1250
|
-
const yaml
|
|
1251
|
-
return yaml
|
|
1262
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1263
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1252
1264
|
}
|
|
1253
1265
|
async function pnpm(options) {
|
|
1254
|
-
const [pluginPnpm, pluginYaml, yamlParser
|
|
1266
|
+
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
1255
1267
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1256
1268
|
interopDefault(import("eslint-plugin-yml")),
|
|
1257
|
-
interopDefault(import("yaml-eslint-parser"))
|
|
1258
|
-
interopDefault(import("jsonc-eslint-parser"))
|
|
1269
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1259
1270
|
]);
|
|
1260
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1261
|
-
const configs
|
|
1262
|
-
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({
|
|
1263
1274
|
files: ["package.json", "**/package.json"],
|
|
1264
|
-
|
|
1275
|
+
language: "jsonc/x",
|
|
1265
1276
|
name: "antfu/pnpm/package-json",
|
|
1266
1277
|
plugins: { pnpm: pluginPnpm },
|
|
1267
1278
|
rules: {
|
|
@@ -1273,8 +1284,8 @@ async function pnpm(options) {
|
|
|
1273
1284
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1274
1285
|
}
|
|
1275
1286
|
});
|
|
1276
|
-
if (yaml
|
|
1277
|
-
configs
|
|
1287
|
+
if (yaml) {
|
|
1288
|
+
configs.push({
|
|
1278
1289
|
files: ["pnpm-workspace.yaml"],
|
|
1279
1290
|
languageOptions: { parser: yamlParser },
|
|
1280
1291
|
name: "antfu/pnpm/pnpm-workspace-yaml",
|
|
@@ -1288,7 +1299,7 @@ async function pnpm(options) {
|
|
|
1288
1299
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1289
1300
|
}
|
|
1290
1301
|
});
|
|
1291
|
-
if (sort) configs
|
|
1302
|
+
if (sort) configs.push({
|
|
1292
1303
|
files: ["pnpm-workspace.yaml"],
|
|
1293
1304
|
languageOptions: { parser: yamlParser },
|
|
1294
1305
|
name: "antfu/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1367,9 +1378,8 @@ async function pnpm(options) {
|
|
|
1367
1378
|
] }
|
|
1368
1379
|
});
|
|
1369
1380
|
}
|
|
1370
|
-
return configs
|
|
1381
|
+
return configs;
|
|
1371
1382
|
}
|
|
1372
|
-
|
|
1373
1383
|
//#endregion
|
|
1374
1384
|
//#region src/configs/react.ts
|
|
1375
1385
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1562,7 +1572,6 @@ async function react(options = {}) {
|
|
|
1562
1572
|
}] : []
|
|
1563
1573
|
];
|
|
1564
1574
|
}
|
|
1565
|
-
|
|
1566
1575
|
//#endregion
|
|
1567
1576
|
//#region src/configs/regexp.ts
|
|
1568
1577
|
async function regexp(options = {}) {
|
|
@@ -1580,11 +1589,10 @@ async function regexp(options = {}) {
|
|
|
1580
1589
|
}
|
|
1581
1590
|
}];
|
|
1582
1591
|
}
|
|
1583
|
-
|
|
1584
1592
|
//#endregion
|
|
1585
1593
|
//#region src/configs/solid.ts
|
|
1586
1594
|
async function solid(options = {}) {
|
|
1587
|
-
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript
|
|
1595
|
+
const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript = true } = options;
|
|
1588
1596
|
await ensurePackages(["eslint-plugin-solid"]);
|
|
1589
1597
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1590
1598
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -1623,7 +1631,7 @@ async function solid(options = {}) {
|
|
|
1623
1631
|
"solid/reactivity": "warn",
|
|
1624
1632
|
"solid/self-closing-comp": "error",
|
|
1625
1633
|
"solid/style-prop": ["error", { styleProps: ["style", "css"] }],
|
|
1626
|
-
...typescript
|
|
1634
|
+
...typescript ? {
|
|
1627
1635
|
"solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
|
|
1628
1636
|
"solid/no-unknown-namespaces": "off"
|
|
1629
1637
|
} : {},
|
|
@@ -1631,7 +1639,6 @@ async function solid(options = {}) {
|
|
|
1631
1639
|
}
|
|
1632
1640
|
}];
|
|
1633
1641
|
}
|
|
1634
|
-
|
|
1635
1642
|
//#endregion
|
|
1636
1643
|
//#region src/configs/sort.ts
|
|
1637
1644
|
/**
|
|
@@ -1865,12 +1872,11 @@ function sortTsconfig() {
|
|
|
1865
1872
|
] }
|
|
1866
1873
|
}];
|
|
1867
1874
|
}
|
|
1868
|
-
|
|
1869
1875
|
//#endregion
|
|
1870
1876
|
//#region src/configs/svelte.ts
|
|
1871
1877
|
async function svelte(options = {}) {
|
|
1872
|
-
const { files = [GLOB_SVELTE], overrides = {}, stylistic
|
|
1873
|
-
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;
|
|
1874
1880
|
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1875
1881
|
const [pluginSvelte, parserSvelte] = await Promise.all([interopDefault(import("eslint-plugin-svelte")), interopDefault(import("svelte-eslint-parser"))]);
|
|
1876
1882
|
return [{
|
|
@@ -1921,7 +1927,7 @@ async function svelte(options = {}) {
|
|
|
1921
1927
|
vars: "all",
|
|
1922
1928
|
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1923
1929
|
}],
|
|
1924
|
-
...stylistic
|
|
1930
|
+
...stylistic ? {
|
|
1925
1931
|
"style/indent": "off",
|
|
1926
1932
|
"style/no-trailing-spaces": "off",
|
|
1927
1933
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
@@ -1940,7 +1946,6 @@ async function svelte(options = {}) {
|
|
|
1940
1946
|
}
|
|
1941
1947
|
}];
|
|
1942
1948
|
}
|
|
1943
|
-
|
|
1944
1949
|
//#endregion
|
|
1945
1950
|
//#region src/configs/test.ts
|
|
1946
1951
|
let _pluginTest;
|
|
@@ -1971,6 +1976,7 @@ async function test(options = {}) {
|
|
|
1971
1976
|
"test/prefer-hooks-in-order": "error",
|
|
1972
1977
|
"test/prefer-lowercase-title": "error",
|
|
1973
1978
|
"antfu/no-top-level-await": "off",
|
|
1979
|
+
"e18e/prefer-static-regex": "off",
|
|
1974
1980
|
"no-unused-expressions": "off",
|
|
1975
1981
|
"node/prefer-global/process": "off",
|
|
1976
1982
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1978,12 +1984,11 @@ async function test(options = {}) {
|
|
|
1978
1984
|
}
|
|
1979
1985
|
}];
|
|
1980
1986
|
}
|
|
1981
|
-
|
|
1982
1987
|
//#endregion
|
|
1983
1988
|
//#region src/configs/toml.ts
|
|
1984
1989
|
async function toml(options = {}) {
|
|
1985
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1986
|
-
const { indent = 2 } = typeof stylistic
|
|
1990
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1991
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1987
1992
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1988
1993
|
return [{
|
|
1989
1994
|
name: "antfu/toml/setup",
|
|
@@ -2002,7 +2007,7 @@ async function toml(options = {}) {
|
|
|
2002
2007
|
"toml/precision-of-integer": "error",
|
|
2003
2008
|
"toml/tables-order": "error",
|
|
2004
2009
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
2005
|
-
...stylistic
|
|
2010
|
+
...stylistic ? {
|
|
2006
2011
|
"toml/array-bracket-newline": "error",
|
|
2007
2012
|
"toml/array-bracket-spacing": "error",
|
|
2008
2013
|
"toml/array-element-newline": "error",
|
|
@@ -2019,18 +2024,17 @@ async function toml(options = {}) {
|
|
|
2019
2024
|
}
|
|
2020
2025
|
}];
|
|
2021
2026
|
}
|
|
2022
|
-
|
|
2023
2027
|
//#endregion
|
|
2024
2028
|
//#region src/configs/typescript.ts
|
|
2025
2029
|
async function typescript(options = {}) {
|
|
2026
2030
|
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
2027
2031
|
const files = options.files ?? [
|
|
2028
|
-
|
|
2029
|
-
|
|
2032
|
+
"**/*.?([cm])ts",
|
|
2033
|
+
"**/*.?([cm])tsx",
|
|
2030
2034
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2031
2035
|
];
|
|
2032
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
2033
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
2036
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
2037
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`, "**/*.astro/*.ts"];
|
|
2034
2038
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
2035
2039
|
const isTypeAware = !!tsconfigPath;
|
|
2036
2040
|
const typeAwareRules = {
|
|
@@ -2060,10 +2064,10 @@ async function typescript(options = {}) {
|
|
|
2060
2064
|
"ts/unbound-method": "error"
|
|
2061
2065
|
};
|
|
2062
2066
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
2063
|
-
function makeParser(typeAware, files
|
|
2067
|
+
function makeParser(typeAware, files, ignores) {
|
|
2064
2068
|
return {
|
|
2065
|
-
files
|
|
2066
|
-
...ignores
|
|
2069
|
+
files,
|
|
2070
|
+
...ignores ? { ignores } : {},
|
|
2067
2071
|
languageOptions: {
|
|
2068
2072
|
parser: parserTs,
|
|
2069
2073
|
parserOptions: {
|
|
@@ -2154,7 +2158,7 @@ async function typescript(options = {}) {
|
|
|
2154
2158
|
}] : [],
|
|
2155
2159
|
...erasableOnly ? [{
|
|
2156
2160
|
name: "antfu/typescript/erasable-syntax-only",
|
|
2157
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
2161
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-D3Kr7UIJ.mjs")) },
|
|
2158
2162
|
rules: {
|
|
2159
2163
|
"erasable-syntax-only/enums": "error",
|
|
2160
2164
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -2164,7 +2168,6 @@ async function typescript(options = {}) {
|
|
|
2164
2168
|
}] : []
|
|
2165
2169
|
];
|
|
2166
2170
|
}
|
|
2167
|
-
|
|
2168
2171
|
//#endregion
|
|
2169
2172
|
//#region src/configs/unicorn.ts
|
|
2170
2173
|
async function unicorn(options = {}) {
|
|
@@ -2194,7 +2197,6 @@ async function unicorn(options = {}) {
|
|
|
2194
2197
|
}
|
|
2195
2198
|
}];
|
|
2196
2199
|
}
|
|
2197
|
-
|
|
2198
2200
|
//#endregion
|
|
2199
2201
|
//#region src/configs/unocss.ts
|
|
2200
2202
|
async function unocss(options = {}) {
|
|
@@ -2211,13 +2213,12 @@ async function unocss(options = {}) {
|
|
|
2211
2213
|
}
|
|
2212
2214
|
}];
|
|
2213
2215
|
}
|
|
2214
|
-
|
|
2215
2216
|
//#endregion
|
|
2216
2217
|
//#region src/configs/vue.ts
|
|
2217
2218
|
async function vue(options = {}) {
|
|
2218
|
-
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic
|
|
2219
|
+
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic = true, vueVersion = 3 } = options;
|
|
2219
2220
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
2220
|
-
const { braceStyle = "1tbs", indent = 2 } = typeof stylistic
|
|
2221
|
+
const { braceStyle = "1tbs", indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2221
2222
|
if (a11y) await ensurePackages(["eslint-plugin-vuejs-accessibility"]);
|
|
2222
2223
|
const [pluginVue, parserVue, processorVueBlocks, pluginVueA11y] = await Promise.all([
|
|
2223
2224
|
interopDefault(import("eslint-plugin-vue")),
|
|
@@ -2353,7 +2354,7 @@ async function vue(options = {}) {
|
|
|
2353
2354
|
nonwords: false,
|
|
2354
2355
|
words: true
|
|
2355
2356
|
}],
|
|
2356
|
-
...stylistic
|
|
2357
|
+
...stylistic ? {
|
|
2357
2358
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2358
2359
|
"vue/arrow-spacing": ["error", {
|
|
2359
2360
|
after: true,
|
|
@@ -2425,12 +2426,11 @@ async function vue(options = {}) {
|
|
|
2425
2426
|
}
|
|
2426
2427
|
}];
|
|
2427
2428
|
}
|
|
2428
|
-
|
|
2429
2429
|
//#endregion
|
|
2430
2430
|
//#region src/configs/yaml.ts
|
|
2431
2431
|
async function yaml(options = {}) {
|
|
2432
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2433
|
-
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;
|
|
2434
2434
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2435
2435
|
return [{
|
|
2436
2436
|
name: "antfu/yaml/setup",
|
|
@@ -2448,7 +2448,7 @@ async function yaml(options = {}) {
|
|
|
2448
2448
|
"yaml/no-irregular-whitespace": "error",
|
|
2449
2449
|
"yaml/plain-scalar": "error",
|
|
2450
2450
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2451
|
-
...stylistic
|
|
2451
|
+
...stylistic ? {
|
|
2452
2452
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2453
2453
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2454
2454
|
"yaml/flow-mapping-curly-newline": "error",
|
|
@@ -2468,7 +2468,22 @@ async function yaml(options = {}) {
|
|
|
2468
2468
|
}
|
|
2469
2469
|
}];
|
|
2470
2470
|
}
|
|
2471
|
-
|
|
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
|
+
}
|
|
2472
2487
|
//#endregion
|
|
2473
2488
|
//#region src/factory.ts
|
|
2474
2489
|
const flatConfigProps = [
|
|
@@ -2510,7 +2525,7 @@ const defaultPluginRenaming = {
|
|
|
2510
2525
|
* The merged ESLint configurations.
|
|
2511
2526
|
*/
|
|
2512
2527
|
function antfu(options = {}, ...userConfigs) {
|
|
2513
|
-
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;
|
|
2514
2529
|
let isInEditor = options.isInEditor;
|
|
2515
2530
|
if (isInEditor == null) {
|
|
2516
2531
|
isInEditor = isInEditorEnv();
|
|
@@ -2518,113 +2533,117 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2518
2533
|
}
|
|
2519
2534
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2520
2535
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = typeof enableJsx === "object" ? true : enableJsx;
|
|
2521
|
-
const configs
|
|
2522
|
-
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({
|
|
2523
2538
|
name: "antfu/gitignore",
|
|
2524
2539
|
...enableGitignore
|
|
2525
2540
|
})]));
|
|
2526
|
-
else configs
|
|
2541
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2527
2542
|
name: "antfu/gitignore",
|
|
2528
2543
|
strict: false
|
|
2529
2544
|
})]));
|
|
2530
2545
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2531
2546
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2532
|
-
configs
|
|
2547
|
+
configs.push(ignores(userIgnores, !enableTypeScript), javascript({
|
|
2533
2548
|
isInEditor,
|
|
2534
2549
|
overrides: getOverrides(options, "javascript")
|
|
2535
2550
|
}), comments(), command(), perfectionist());
|
|
2536
|
-
if (enableNode) configs
|
|
2537
|
-
if (enableJsdoc) configs
|
|
2538
|
-
if (enableImports) configs
|
|
2551
|
+
if (enableNode) configs.push(node());
|
|
2552
|
+
if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2553
|
+
if (enableImports) configs.push(imports({
|
|
2539
2554
|
stylistic: stylisticOptions,
|
|
2540
2555
|
...resolveSubOptions(options, "imports")
|
|
2541
2556
|
}));
|
|
2542
|
-
if (
|
|
2557
|
+
if (enableE18e) configs.push(e18e({
|
|
2558
|
+
isInEditor,
|
|
2559
|
+
...enableE18e === true ? {} : enableE18e
|
|
2560
|
+
}));
|
|
2561
|
+
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2543
2562
|
if (enableVue) componentExts.push("vue");
|
|
2544
|
-
if (enableJsx) configs
|
|
2545
|
-
if (enableTypeScript) configs
|
|
2563
|
+
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
2564
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2546
2565
|
...typescriptOptions,
|
|
2547
2566
|
componentExts,
|
|
2548
2567
|
overrides: getOverrides(options, "typescript"),
|
|
2549
|
-
type:
|
|
2568
|
+
type: appType
|
|
2550
2569
|
}));
|
|
2551
|
-
if (stylisticOptions) configs
|
|
2570
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2552
2571
|
...stylisticOptions,
|
|
2553
2572
|
lessOpinionated: options.lessOpinionated,
|
|
2554
2573
|
overrides: getOverrides(options, "stylistic")
|
|
2555
2574
|
}));
|
|
2556
|
-
if (enableRegexp) configs
|
|
2557
|
-
if (options.test ?? true) configs
|
|
2575
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2576
|
+
if (options.test ?? true) configs.push(test({
|
|
2558
2577
|
isInEditor,
|
|
2559
2578
|
overrides: getOverrides(options, "test")
|
|
2560
2579
|
}));
|
|
2561
|
-
if (enableVue) configs
|
|
2580
|
+
if (enableVue) configs.push(vue({
|
|
2562
2581
|
...resolveSubOptions(options, "vue"),
|
|
2563
2582
|
overrides: getOverrides(options, "vue"),
|
|
2564
2583
|
stylistic: stylisticOptions,
|
|
2565
2584
|
typescript: !!enableTypeScript
|
|
2566
2585
|
}));
|
|
2567
|
-
if (enableReact) configs
|
|
2586
|
+
if (enableReact) configs.push(react({
|
|
2568
2587
|
...typescriptOptions,
|
|
2569
2588
|
...resolveSubOptions(options, "react"),
|
|
2570
2589
|
overrides: getOverrides(options, "react"),
|
|
2571
2590
|
tsconfigPath
|
|
2572
2591
|
}));
|
|
2573
|
-
if (enableNextjs) configs
|
|
2574
|
-
if (enableSolid) configs
|
|
2592
|
+
if (enableNextjs) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2593
|
+
if (enableSolid) configs.push(solid({
|
|
2575
2594
|
overrides: getOverrides(options, "solid"),
|
|
2576
2595
|
tsconfigPath,
|
|
2577
2596
|
typescript: !!enableTypeScript
|
|
2578
2597
|
}));
|
|
2579
|
-
if (enableSvelte) configs
|
|
2598
|
+
if (enableSvelte) configs.push(svelte({
|
|
2580
2599
|
overrides: getOverrides(options, "svelte"),
|
|
2581
2600
|
stylistic: stylisticOptions,
|
|
2582
2601
|
typescript: !!enableTypeScript
|
|
2583
2602
|
}));
|
|
2584
|
-
if (enableUnoCSS) configs
|
|
2603
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2585
2604
|
...resolveSubOptions(options, "unocss"),
|
|
2586
2605
|
overrides: getOverrides(options, "unocss")
|
|
2587
2606
|
}));
|
|
2588
|
-
if (enableAstro) configs
|
|
2607
|
+
if (enableAstro) configs.push(astro({
|
|
2589
2608
|
overrides: getOverrides(options, "astro"),
|
|
2590
2609
|
stylistic: stylisticOptions
|
|
2591
2610
|
}));
|
|
2592
|
-
if (enableAngular) configs
|
|
2593
|
-
if (options.jsonc ?? true) configs
|
|
2611
|
+
if (enableAngular) configs.push(angular({ overrides: getOverrides(options, "angular") }));
|
|
2612
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2594
2613
|
overrides: getOverrides(options, "jsonc"),
|
|
2595
2614
|
stylistic: stylisticOptions
|
|
2596
2615
|
}), sortPackageJson(), sortTsconfig());
|
|
2597
2616
|
if (enableCatalogs) {
|
|
2598
2617
|
const optionsPnpm = resolveSubOptions(options, "pnpm");
|
|
2599
|
-
configs
|
|
2618
|
+
configs.push(pnpm({
|
|
2600
2619
|
isInEditor,
|
|
2601
2620
|
json: options.jsonc !== false,
|
|
2602
2621
|
yaml: options.yaml !== false,
|
|
2603
2622
|
...optionsPnpm
|
|
2604
2623
|
}));
|
|
2605
2624
|
}
|
|
2606
|
-
if (options.yaml ?? true) configs
|
|
2625
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2607
2626
|
overrides: getOverrides(options, "yaml"),
|
|
2608
2627
|
stylistic: stylisticOptions
|
|
2609
2628
|
}));
|
|
2610
|
-
if (options.toml ?? true) configs
|
|
2629
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2611
2630
|
overrides: getOverrides(options, "toml"),
|
|
2612
2631
|
stylistic: stylisticOptions
|
|
2613
2632
|
}));
|
|
2614
|
-
if (options.markdown ?? true) configs
|
|
2633
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2615
2634
|
componentExts,
|
|
2616
2635
|
overrides: getOverrides(options, "markdown")
|
|
2617
2636
|
}));
|
|
2618
|
-
if (options.formatters) configs
|
|
2619
|
-
configs
|
|
2637
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2638
|
+
configs.push(disables());
|
|
2620
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.");
|
|
2621
2640
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2622
2641
|
if (key in options) acc[key] = options[key];
|
|
2623
2642
|
return acc;
|
|
2624
2643
|
}, {});
|
|
2625
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2644
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2626
2645
|
let composer = new FlatConfigComposer();
|
|
2627
|
-
composer = composer.append(...configs
|
|
2646
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2628
2647
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2629
2648
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2630
2649
|
"unused-imports/no-unused-imports",
|
|
@@ -2643,7 +2662,6 @@ function getOverrides(options, key) {
|
|
|
2643
2662
|
..."overrides" in sub ? sub.overrides : {}
|
|
2644
2663
|
};
|
|
2645
2664
|
}
|
|
2646
|
-
|
|
2647
2665
|
//#endregion
|
|
2648
2666
|
//#region src/config-presets.ts
|
|
2649
2667
|
const CONFIG_PRESET_FULL_ON = {
|
|
@@ -2701,10 +2719,8 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2701
2719
|
vue: false,
|
|
2702
2720
|
yaml: false
|
|
2703
2721
|
};
|
|
2704
|
-
|
|
2705
2722
|
//#endregion
|
|
2706
2723
|
//#region src/index.ts
|
|
2707
2724
|
var src_default = antfu;
|
|
2708
|
-
|
|
2709
2725
|
//#endregion
|
|
2710
|
-
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 };
|