@dhzh/eslint-config 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +21 -22
- package/dist/cli.cjs +123 -49
- package/dist/cli.js +123 -49
- package/dist/index.cjs +197 -83
- package/dist/index.d.cts +6819 -3582
- package/dist/index.d.ts +6819 -3582
- package/dist/index.js +197 -84
- package/package.json +39 -31
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ __export(src_exports, {
|
|
|
81
81
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
82
82
|
renameRules: () => renameRules,
|
|
83
83
|
resolveSubOptions: () => resolveSubOptions,
|
|
84
|
+
solid: () => solid,
|
|
84
85
|
sortPackageJson: () => sortPackageJson,
|
|
85
86
|
sortTsconfig: () => sortTsconfig,
|
|
86
87
|
stylistic: () => stylistic,
|
|
@@ -115,7 +116,7 @@ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfecti
|
|
|
115
116
|
async function comments() {
|
|
116
117
|
return [
|
|
117
118
|
{
|
|
118
|
-
name: "antfu
|
|
119
|
+
name: "antfu/eslint-comments/rules",
|
|
119
120
|
plugins: {
|
|
120
121
|
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
121
122
|
},
|
|
@@ -209,6 +210,8 @@ async function ignores() {
|
|
|
209
210
|
return [
|
|
210
211
|
{
|
|
211
212
|
ignores: GLOB_EXCLUDE
|
|
213
|
+
// Awaits https://github.com/humanwhocodes/config-array/pull/131
|
|
214
|
+
// name: 'antfu/ignores',
|
|
212
215
|
}
|
|
213
216
|
];
|
|
214
217
|
}
|
|
@@ -220,7 +223,7 @@ async function imports(options = {}) {
|
|
|
220
223
|
} = options;
|
|
221
224
|
return [
|
|
222
225
|
{
|
|
223
|
-
name: "antfu
|
|
226
|
+
name: "antfu/imports/rules",
|
|
224
227
|
plugins: {
|
|
225
228
|
antfu: import_eslint_plugin_antfu.default,
|
|
226
229
|
import: pluginImport
|
|
@@ -243,7 +246,7 @@ async function imports(options = {}) {
|
|
|
243
246
|
},
|
|
244
247
|
{
|
|
245
248
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
246
|
-
name: "antfu
|
|
249
|
+
name: "antfu/imports/disables/bin",
|
|
247
250
|
rules: {
|
|
248
251
|
"antfu/no-import-dist": "off",
|
|
249
252
|
"antfu/no-import-node-modules-by-path": "off"
|
|
@@ -283,7 +286,7 @@ async function javascript(options = {}) {
|
|
|
283
286
|
linterOptions: {
|
|
284
287
|
reportUnusedDisableDirectives: true
|
|
285
288
|
},
|
|
286
|
-
name: "antfu
|
|
289
|
+
name: "antfu/javascript/rules",
|
|
287
290
|
plugins: {
|
|
288
291
|
"antfu": import_eslint_plugin_antfu.default,
|
|
289
292
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
@@ -337,7 +340,7 @@ async function javascript(options = {}) {
|
|
|
337
340
|
"no-multi-str": "error",
|
|
338
341
|
"no-new": "error",
|
|
339
342
|
"no-new-func": "error",
|
|
340
|
-
"no-new-
|
|
343
|
+
"no-new-native-nonconstructor": "error",
|
|
341
344
|
"no-new-wrappers": "error",
|
|
342
345
|
"no-obj-calls": "error",
|
|
343
346
|
"no-octal": "error",
|
|
@@ -449,7 +452,13 @@ async function javascript(options = {}) {
|
|
|
449
452
|
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
450
453
|
"unused-imports/no-unused-vars": [
|
|
451
454
|
"error",
|
|
452
|
-
{
|
|
455
|
+
{
|
|
456
|
+
args: "after-used",
|
|
457
|
+
argsIgnorePattern: "^_",
|
|
458
|
+
ignoreRestSiblings: true,
|
|
459
|
+
vars: "all",
|
|
460
|
+
varsIgnorePattern: "^_"
|
|
461
|
+
}
|
|
453
462
|
],
|
|
454
463
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
455
464
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
@@ -460,7 +469,7 @@ async function javascript(options = {}) {
|
|
|
460
469
|
},
|
|
461
470
|
{
|
|
462
471
|
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
463
|
-
name: "antfu
|
|
472
|
+
name: "antfu/javascript/disables/cli",
|
|
464
473
|
rules: {
|
|
465
474
|
"no-console": "off"
|
|
466
475
|
}
|
|
@@ -499,8 +508,9 @@ function renameRules(rules, map) {
|
|
|
499
508
|
return Object.fromEntries(
|
|
500
509
|
Object.entries(rules).map(([key, value]) => {
|
|
501
510
|
for (const [from, to] of Object.entries(map)) {
|
|
502
|
-
if (key.startsWith(`${from}/`))
|
|
511
|
+
if (key.startsWith(`${from}/`)) {
|
|
503
512
|
return [to + key.slice(from.length), value];
|
|
513
|
+
}
|
|
504
514
|
}
|
|
505
515
|
return [key, value];
|
|
506
516
|
})
|
|
@@ -509,13 +519,15 @@ function renameRules(rules, map) {
|
|
|
509
519
|
function renamePluginInConfigs(configs, map) {
|
|
510
520
|
return configs.map((i) => {
|
|
511
521
|
const clone = { ...i };
|
|
512
|
-
if (clone.rules)
|
|
522
|
+
if (clone.rules) {
|
|
513
523
|
clone.rules = renameRules(clone.rules, map);
|
|
524
|
+
}
|
|
514
525
|
if (clone.plugins) {
|
|
515
526
|
clone.plugins = Object.fromEntries(
|
|
516
527
|
Object.entries(clone.plugins).map(([key, value]) => {
|
|
517
|
-
if (key in map)
|
|
528
|
+
if (key in map) {
|
|
518
529
|
return [map[key], value];
|
|
530
|
+
}
|
|
519
531
|
return [key, value];
|
|
520
532
|
})
|
|
521
533
|
);
|
|
@@ -531,17 +543,20 @@ async function interopDefault(m) {
|
|
|
531
543
|
return resolved.default || resolved;
|
|
532
544
|
}
|
|
533
545
|
async function ensurePackages(packages) {
|
|
534
|
-
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
|
|
546
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false) {
|
|
535
547
|
return;
|
|
548
|
+
}
|
|
536
549
|
const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
|
|
537
|
-
if (nonExistingPackages.length === 0)
|
|
550
|
+
if (nonExistingPackages.length === 0) {
|
|
538
551
|
return;
|
|
552
|
+
}
|
|
539
553
|
const p = await import("@clack/prompts");
|
|
540
554
|
const result = await p.confirm({
|
|
541
555
|
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
542
556
|
});
|
|
543
|
-
if (result)
|
|
557
|
+
if (result) {
|
|
544
558
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
559
|
+
}
|
|
545
560
|
}
|
|
546
561
|
|
|
547
562
|
// src/configs/jsdoc.ts
|
|
@@ -551,7 +566,7 @@ async function jsdoc(options = {}) {
|
|
|
551
566
|
} = options;
|
|
552
567
|
return [
|
|
553
568
|
{
|
|
554
|
-
name: "antfu
|
|
569
|
+
name: "antfu/jsdoc/rules",
|
|
555
570
|
plugins: {
|
|
556
571
|
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
557
572
|
},
|
|
@@ -599,7 +614,7 @@ async function jsonc(options = {}) {
|
|
|
599
614
|
]);
|
|
600
615
|
return [
|
|
601
616
|
{
|
|
602
|
-
name: "antfu
|
|
617
|
+
name: "antfu/jsonc/setup",
|
|
603
618
|
plugins: {
|
|
604
619
|
jsonc: pluginJsonc
|
|
605
620
|
}
|
|
@@ -609,7 +624,7 @@ async function jsonc(options = {}) {
|
|
|
609
624
|
languageOptions: {
|
|
610
625
|
parser: parserJsonc
|
|
611
626
|
},
|
|
612
|
-
name: "antfu
|
|
627
|
+
name: "antfu/jsonc/rules",
|
|
613
628
|
rules: {
|
|
614
629
|
"jsonc/no-bigint-literals": "error",
|
|
615
630
|
"jsonc/no-binary-expression": "error",
|
|
@@ -666,7 +681,7 @@ async function markdown(options = {}) {
|
|
|
666
681
|
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
667
682
|
return [
|
|
668
683
|
{
|
|
669
|
-
name: "antfu
|
|
684
|
+
name: "antfu/markdown/setup",
|
|
670
685
|
plugins: {
|
|
671
686
|
markdown: markdown2
|
|
672
687
|
}
|
|
@@ -674,7 +689,7 @@ async function markdown(options = {}) {
|
|
|
674
689
|
{
|
|
675
690
|
files,
|
|
676
691
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
677
|
-
name: "antfu
|
|
692
|
+
name: "antfu/markdown/processor",
|
|
678
693
|
// `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
679
694
|
// but not the markdown file itself. We use `eslint-merge-processors` to
|
|
680
695
|
// add a pass-through processor for the markdown file itself.
|
|
@@ -688,7 +703,7 @@ async function markdown(options = {}) {
|
|
|
688
703
|
languageOptions: {
|
|
689
704
|
parser: parserPlain
|
|
690
705
|
},
|
|
691
|
-
name: "antfu
|
|
706
|
+
name: "antfu/markdown/parser"
|
|
692
707
|
},
|
|
693
708
|
{
|
|
694
709
|
files: [
|
|
@@ -702,7 +717,7 @@ async function markdown(options = {}) {
|
|
|
702
717
|
}
|
|
703
718
|
}
|
|
704
719
|
},
|
|
705
|
-
name: "antfu
|
|
720
|
+
name: "antfu/markdown/disables",
|
|
706
721
|
rules: {
|
|
707
722
|
"import/newline-after-import": "off",
|
|
708
723
|
"no-alert": "off",
|
|
@@ -756,7 +771,7 @@ async function markdown(options = {}) {
|
|
|
756
771
|
async function node() {
|
|
757
772
|
return [
|
|
758
773
|
{
|
|
759
|
-
name: "antfu
|
|
774
|
+
name: "antfu/node/rules",
|
|
760
775
|
plugins: {
|
|
761
776
|
node: import_eslint_plugin_n.default
|
|
762
777
|
},
|
|
@@ -778,7 +793,7 @@ async function node() {
|
|
|
778
793
|
async function perfectionist() {
|
|
779
794
|
return [
|
|
780
795
|
{
|
|
781
|
-
name: "antfu
|
|
796
|
+
name: "antfu/perfectionist/setup",
|
|
782
797
|
plugins: {
|
|
783
798
|
perfectionist: import_eslint_plugin_perfectionist.default
|
|
784
799
|
}
|
|
@@ -800,6 +815,7 @@ async function stylistic(options = {}) {
|
|
|
800
815
|
const {
|
|
801
816
|
indent,
|
|
802
817
|
jsx,
|
|
818
|
+
lessOpinionated = false,
|
|
803
819
|
overrides = {},
|
|
804
820
|
quotes,
|
|
805
821
|
semi
|
|
@@ -820,7 +836,7 @@ async function stylistic(options = {}) {
|
|
|
820
836
|
});
|
|
821
837
|
return [
|
|
822
838
|
{
|
|
823
|
-
name: "antfu
|
|
839
|
+
name: "antfu/stylistic/rules",
|
|
824
840
|
plugins: {
|
|
825
841
|
antfu: import_eslint_plugin_antfu.default,
|
|
826
842
|
style: pluginStylistic
|
|
@@ -828,9 +844,13 @@ async function stylistic(options = {}) {
|
|
|
828
844
|
rules: {
|
|
829
845
|
...config.rules,
|
|
830
846
|
"antfu/consistent-list-newline": "error",
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
847
|
+
...lessOpinionated ? {
|
|
848
|
+
curly: ["error", "all"]
|
|
849
|
+
} : {
|
|
850
|
+
"antfu/if-newline": "error",
|
|
851
|
+
"antfu/top-level-function": "off",
|
|
852
|
+
"curly": ["error", "all"]
|
|
853
|
+
},
|
|
834
854
|
...overrides
|
|
835
855
|
}
|
|
836
856
|
}
|
|
@@ -854,8 +874,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
854
874
|
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
855
875
|
options.astro ? "prettier-plugin-astro" : void 0
|
|
856
876
|
]);
|
|
857
|
-
if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
|
|
877
|
+
if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
|
|
858
878
|
throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
879
|
+
}
|
|
859
880
|
const {
|
|
860
881
|
indent,
|
|
861
882
|
quotes,
|
|
@@ -886,7 +907,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
886
907
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
887
908
|
const configs = [
|
|
888
909
|
{
|
|
889
|
-
name: "antfu
|
|
910
|
+
name: "antfu/formatter/setup",
|
|
890
911
|
plugins: {
|
|
891
912
|
format: pluginFormat
|
|
892
913
|
}
|
|
@@ -899,7 +920,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
899
920
|
languageOptions: {
|
|
900
921
|
parser: parserPlain
|
|
901
922
|
},
|
|
902
|
-
name: "antfu
|
|
923
|
+
name: "antfu/formatter/css",
|
|
903
924
|
rules: {
|
|
904
925
|
"format/prettier": [
|
|
905
926
|
"error",
|
|
@@ -915,7 +936,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
915
936
|
languageOptions: {
|
|
916
937
|
parser: parserPlain
|
|
917
938
|
},
|
|
918
|
-
name: "antfu
|
|
939
|
+
name: "antfu/formatter/scss",
|
|
919
940
|
rules: {
|
|
920
941
|
"format/prettier": [
|
|
921
942
|
"error",
|
|
@@ -931,7 +952,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
931
952
|
languageOptions: {
|
|
932
953
|
parser: parserPlain
|
|
933
954
|
},
|
|
934
|
-
name: "antfu
|
|
955
|
+
name: "antfu/formatter/less",
|
|
935
956
|
rules: {
|
|
936
957
|
"format/prettier": [
|
|
937
958
|
"error",
|
|
@@ -946,11 +967,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
946
967
|
}
|
|
947
968
|
if (options.html) {
|
|
948
969
|
configs.push({
|
|
949
|
-
files: [
|
|
970
|
+
files: [GLOB_HTML],
|
|
950
971
|
languageOptions: {
|
|
951
972
|
parser: parserPlain
|
|
952
973
|
},
|
|
953
|
-
name: "antfu
|
|
974
|
+
name: "antfu/formatter/html",
|
|
954
975
|
rules: {
|
|
955
976
|
"format/prettier": [
|
|
956
977
|
"error",
|
|
@@ -971,7 +992,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
971
992
|
languageOptions: {
|
|
972
993
|
parser: parserPlain
|
|
973
994
|
},
|
|
974
|
-
name: "antfu
|
|
995
|
+
name: "antfu/formatter/markdown",
|
|
975
996
|
rules: {
|
|
976
997
|
[`format/${formater}`]: [
|
|
977
998
|
"error",
|
|
@@ -993,7 +1014,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
993
1014
|
languageOptions: {
|
|
994
1015
|
parser: parserPlain
|
|
995
1016
|
},
|
|
996
|
-
name: "antfu
|
|
1017
|
+
name: "antfu/formatter/slidev",
|
|
997
1018
|
rules: {
|
|
998
1019
|
"format/prettier": [
|
|
999
1020
|
"error",
|
|
@@ -1017,7 +1038,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1017
1038
|
languageOptions: {
|
|
1018
1039
|
parser: parserPlain
|
|
1019
1040
|
},
|
|
1020
|
-
name: "antfu
|
|
1041
|
+
name: "antfu/formatter/astro",
|
|
1021
1042
|
rules: {
|
|
1022
1043
|
"format/prettier": [
|
|
1023
1044
|
"error",
|
|
@@ -1038,7 +1059,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1038
1059
|
languageOptions: {
|
|
1039
1060
|
parser: parserPlain
|
|
1040
1061
|
},
|
|
1041
|
-
name: "antfu
|
|
1062
|
+
name: "antfu/formatter/graphql",
|
|
1042
1063
|
rules: {
|
|
1043
1064
|
"format/prettier": [
|
|
1044
1065
|
"error",
|
|
@@ -1083,7 +1104,7 @@ async function react(options = {}) {
|
|
|
1083
1104
|
);
|
|
1084
1105
|
return [
|
|
1085
1106
|
{
|
|
1086
|
-
name: "antfu
|
|
1107
|
+
name: "antfu/react/setup",
|
|
1087
1108
|
plugins: {
|
|
1088
1109
|
"react": pluginReact,
|
|
1089
1110
|
"react-hooks": pluginReactHooks,
|
|
@@ -1104,7 +1125,7 @@ async function react(options = {}) {
|
|
|
1104
1125
|
}
|
|
1105
1126
|
}
|
|
1106
1127
|
},
|
|
1107
|
-
name: "antfu
|
|
1128
|
+
name: "antfu/react/rules",
|
|
1108
1129
|
rules: {
|
|
1109
1130
|
// recommended rules react-hooks
|
|
1110
1131
|
"react-hooks/exhaustive-deps": "warn",
|
|
@@ -1153,7 +1174,7 @@ async function sortPackageJson() {
|
|
|
1153
1174
|
return [
|
|
1154
1175
|
{
|
|
1155
1176
|
files: ["**/package.json"],
|
|
1156
|
-
name: "antfu
|
|
1177
|
+
name: "antfu/sort/package-json",
|
|
1157
1178
|
rules: {
|
|
1158
1179
|
"jsonc/sort-array-values": [
|
|
1159
1180
|
"error",
|
|
@@ -1254,7 +1275,7 @@ function sortTsconfig() {
|
|
|
1254
1275
|
return [
|
|
1255
1276
|
{
|
|
1256
1277
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
1257
|
-
name: "antfu
|
|
1278
|
+
name: "antfu/sort/tsconfig-json",
|
|
1258
1279
|
rules: {
|
|
1259
1280
|
"jsonc/sort-keys": [
|
|
1260
1281
|
"error",
|
|
@@ -1399,7 +1420,7 @@ async function svelte(options = {}) {
|
|
|
1399
1420
|
]);
|
|
1400
1421
|
return [
|
|
1401
1422
|
{
|
|
1402
|
-
name: "antfu
|
|
1423
|
+
name: "antfu/svelte/setup",
|
|
1403
1424
|
plugins: {
|
|
1404
1425
|
svelte: pluginSvelte
|
|
1405
1426
|
}
|
|
@@ -1413,7 +1434,7 @@ async function svelte(options = {}) {
|
|
|
1413
1434
|
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1414
1435
|
}
|
|
1415
1436
|
},
|
|
1416
|
-
name: "antfu
|
|
1437
|
+
name: "antfu/svelte/rules",
|
|
1417
1438
|
processor: pluginSvelte.processors[".svelte"],
|
|
1418
1439
|
rules: {
|
|
1419
1440
|
"import/no-mutable-exports": "off",
|
|
@@ -1424,7 +1445,7 @@ async function svelte(options = {}) {
|
|
|
1424
1445
|
caughtErrors: "none",
|
|
1425
1446
|
ignoreRestSiblings: true,
|
|
1426
1447
|
vars: "all",
|
|
1427
|
-
varsIgnorePattern: "
|
|
1448
|
+
varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1428
1449
|
}],
|
|
1429
1450
|
"svelte/comment-directive": "error",
|
|
1430
1451
|
"svelte/no-at-debug-tags": "warn",
|
|
@@ -1449,7 +1470,7 @@ async function svelte(options = {}) {
|
|
|
1449
1470
|
"svelte/valid-each-key": "error",
|
|
1450
1471
|
"unused-imports/no-unused-vars": [
|
|
1451
1472
|
"error",
|
|
1452
|
-
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1473
|
+
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)" }
|
|
1453
1474
|
],
|
|
1454
1475
|
...stylistic2 ? {
|
|
1455
1476
|
"style/indent": "off",
|
|
@@ -1472,6 +1493,7 @@ async function svelte(options = {}) {
|
|
|
1472
1493
|
}
|
|
1473
1494
|
|
|
1474
1495
|
// src/configs/test.ts
|
|
1496
|
+
var _pluginTest;
|
|
1475
1497
|
async function test(options = {}) {
|
|
1476
1498
|
const {
|
|
1477
1499
|
files = GLOB_TESTS,
|
|
@@ -1486,23 +1508,24 @@ async function test(options = {}) {
|
|
|
1486
1508
|
// @ts-expect-error missing types
|
|
1487
1509
|
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1488
1510
|
]);
|
|
1511
|
+
_pluginTest = _pluginTest || {
|
|
1512
|
+
...pluginVitest,
|
|
1513
|
+
rules: {
|
|
1514
|
+
...pluginVitest.rules,
|
|
1515
|
+
// extend `test/no-only-tests` rule
|
|
1516
|
+
...pluginNoOnlyTests.rules
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1489
1519
|
return [
|
|
1490
1520
|
{
|
|
1491
|
-
name: "antfu
|
|
1521
|
+
name: "antfu/test/setup",
|
|
1492
1522
|
plugins: {
|
|
1493
|
-
test:
|
|
1494
|
-
...pluginVitest,
|
|
1495
|
-
rules: {
|
|
1496
|
-
...pluginVitest.rules,
|
|
1497
|
-
// extend `test/no-only-tests` rule
|
|
1498
|
-
...pluginNoOnlyTests.rules
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1523
|
+
test: _pluginTest
|
|
1501
1524
|
}
|
|
1502
1525
|
},
|
|
1503
1526
|
{
|
|
1504
1527
|
files,
|
|
1505
|
-
name: "antfu
|
|
1528
|
+
name: "antfu/test/rules",
|
|
1506
1529
|
rules: {
|
|
1507
1530
|
"node/prefer-global/process": "off",
|
|
1508
1531
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
@@ -1576,13 +1599,13 @@ async function typescript(options = {}) {
|
|
|
1576
1599
|
...parserOptions
|
|
1577
1600
|
}
|
|
1578
1601
|
},
|
|
1579
|
-
name: `antfu
|
|
1602
|
+
name: `antfu/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
1580
1603
|
};
|
|
1581
1604
|
}
|
|
1582
1605
|
return [
|
|
1583
1606
|
{
|
|
1584
1607
|
// Install the plugins without globs, so they can be configured separately.
|
|
1585
|
-
name: "antfu
|
|
1608
|
+
name: "antfu/typescript/setup",
|
|
1586
1609
|
plugins: {
|
|
1587
1610
|
antfu: import_eslint_plugin_antfu.default,
|
|
1588
1611
|
ts: pluginTs
|
|
@@ -1595,7 +1618,7 @@ async function typescript(options = {}) {
|
|
|
1595
1618
|
] : [makeParser(false, files)],
|
|
1596
1619
|
{
|
|
1597
1620
|
files,
|
|
1598
|
-
name: "antfu
|
|
1621
|
+
name: "antfu/typescript/rules",
|
|
1599
1622
|
rules: {
|
|
1600
1623
|
...renameRules(
|
|
1601
1624
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
@@ -1635,17 +1658,17 @@ async function typescript(options = {}) {
|
|
|
1635
1658
|
...overrides
|
|
1636
1659
|
}
|
|
1637
1660
|
},
|
|
1638
|
-
{
|
|
1661
|
+
...isTypeAware ? [{
|
|
1639
1662
|
files: filesTypeAware,
|
|
1640
|
-
name: "antfu
|
|
1663
|
+
name: "antfu/typescript/rules-type-aware",
|
|
1641
1664
|
rules: {
|
|
1642
1665
|
...tsconfigPath ? typeAwareRules : {},
|
|
1643
1666
|
...overrides
|
|
1644
1667
|
}
|
|
1645
|
-
},
|
|
1668
|
+
}] : [],
|
|
1646
1669
|
{
|
|
1647
1670
|
files: ["**/*.d.ts"],
|
|
1648
|
-
name: "antfu
|
|
1671
|
+
name: "antfu/typescript/disables/dts",
|
|
1649
1672
|
rules: {
|
|
1650
1673
|
"eslint-comments/no-unlimited-disable": "off",
|
|
1651
1674
|
"import/no-duplicates": "off",
|
|
@@ -1655,14 +1678,14 @@ async function typescript(options = {}) {
|
|
|
1655
1678
|
},
|
|
1656
1679
|
{
|
|
1657
1680
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1658
|
-
name: "antfu
|
|
1681
|
+
name: "antfu/typescript/disables/test",
|
|
1659
1682
|
rules: {
|
|
1660
1683
|
"no-unused-expressions": "off"
|
|
1661
1684
|
}
|
|
1662
1685
|
},
|
|
1663
1686
|
{
|
|
1664
1687
|
files: ["**/*.js", "**/*.cjs"],
|
|
1665
|
-
name: "antfu
|
|
1688
|
+
name: "antfu/typescript/disables/cjs",
|
|
1666
1689
|
rules: {
|
|
1667
1690
|
"ts/no-require-imports": "off",
|
|
1668
1691
|
"ts/no-var-requires": "off"
|
|
@@ -1675,7 +1698,7 @@ async function typescript(options = {}) {
|
|
|
1675
1698
|
async function unicorn() {
|
|
1676
1699
|
return [
|
|
1677
1700
|
{
|
|
1678
|
-
name: "antfu
|
|
1701
|
+
name: "antfu/unicorn/rules",
|
|
1679
1702
|
plugins: {
|
|
1680
1703
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1681
1704
|
},
|
|
@@ -1727,7 +1750,7 @@ async function unocss(options = {}) {
|
|
|
1727
1750
|
]);
|
|
1728
1751
|
return [
|
|
1729
1752
|
{
|
|
1730
|
-
name: "antfu
|
|
1753
|
+
name: "antfu/unocss",
|
|
1731
1754
|
plugins: {
|
|
1732
1755
|
unocss: pluginUnoCSS
|
|
1733
1756
|
},
|
|
@@ -1789,7 +1812,7 @@ async function vue(options = {}) {
|
|
|
1789
1812
|
watchEffect: "readonly"
|
|
1790
1813
|
}
|
|
1791
1814
|
},
|
|
1792
|
-
name: "antfu
|
|
1815
|
+
name: "antfu/vue/setup",
|
|
1793
1816
|
plugins: {
|
|
1794
1817
|
vue: pluginVue
|
|
1795
1818
|
}
|
|
@@ -1807,7 +1830,7 @@ async function vue(options = {}) {
|
|
|
1807
1830
|
sourceType: "module"
|
|
1808
1831
|
}
|
|
1809
1832
|
},
|
|
1810
|
-
name: "antfu
|
|
1833
|
+
name: "antfu/vue/rules",
|
|
1811
1834
|
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
|
|
1812
1835
|
pluginVue.processors[".vue"],
|
|
1813
1836
|
processorVueBlocks({
|
|
@@ -1931,7 +1954,7 @@ async function yaml(options = {}) {
|
|
|
1931
1954
|
]);
|
|
1932
1955
|
return [
|
|
1933
1956
|
{
|
|
1934
|
-
name: "antfu
|
|
1957
|
+
name: "antfu/yaml/setup",
|
|
1935
1958
|
plugins: {
|
|
1936
1959
|
yaml: pluginYaml
|
|
1937
1960
|
}
|
|
@@ -1941,7 +1964,7 @@ async function yaml(options = {}) {
|
|
|
1941
1964
|
languageOptions: {
|
|
1942
1965
|
parser: parserYaml
|
|
1943
1966
|
},
|
|
1944
|
-
name: "antfu
|
|
1967
|
+
name: "antfu/yaml/rules",
|
|
1945
1968
|
rules: {
|
|
1946
1969
|
"style/spaced-comment": "off",
|
|
1947
1970
|
"yaml/block-mapping": "error",
|
|
@@ -1989,7 +2012,7 @@ async function toml(options = {}) {
|
|
|
1989
2012
|
]);
|
|
1990
2013
|
return [
|
|
1991
2014
|
{
|
|
1992
|
-
name: "antfu
|
|
2015
|
+
name: "antfu/toml/setup",
|
|
1993
2016
|
plugins: {
|
|
1994
2017
|
toml: pluginToml
|
|
1995
2018
|
}
|
|
@@ -1999,7 +2022,7 @@ async function toml(options = {}) {
|
|
|
1999
2022
|
languageOptions: {
|
|
2000
2023
|
parser: parserToml
|
|
2001
2024
|
},
|
|
2002
|
-
name: "antfu
|
|
2025
|
+
name: "antfu/toml/rules",
|
|
2003
2026
|
rules: {
|
|
2004
2027
|
"style/spaced-comment": "off",
|
|
2005
2028
|
"toml/comma-style": "error",
|
|
@@ -2047,7 +2070,7 @@ async function astro(options = {}) {
|
|
|
2047
2070
|
]);
|
|
2048
2071
|
return [
|
|
2049
2072
|
{
|
|
2050
|
-
name: "antfu
|
|
2073
|
+
name: "antfu/astro/setup",
|
|
2051
2074
|
plugins: {
|
|
2052
2075
|
astro: pluginAstro
|
|
2053
2076
|
}
|
|
@@ -2061,7 +2084,7 @@ async function astro(options = {}) {
|
|
|
2061
2084
|
parser: parserTs
|
|
2062
2085
|
}
|
|
2063
2086
|
},
|
|
2064
|
-
name: "antfu
|
|
2087
|
+
name: "antfu/astro/rules",
|
|
2065
2088
|
rules: {
|
|
2066
2089
|
"astro/no-set-html-directive": "off",
|
|
2067
2090
|
"astro/semi": "off",
|
|
@@ -2078,6 +2101,82 @@ async function astro(options = {}) {
|
|
|
2078
2101
|
];
|
|
2079
2102
|
}
|
|
2080
2103
|
|
|
2104
|
+
// src/configs/solid.ts
|
|
2105
|
+
async function solid(options = {}) {
|
|
2106
|
+
const {
|
|
2107
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
2108
|
+
overrides = {},
|
|
2109
|
+
typescript: typescript2 = true
|
|
2110
|
+
} = options;
|
|
2111
|
+
await ensurePackages([
|
|
2112
|
+
"eslint-plugin-solid"
|
|
2113
|
+
]);
|
|
2114
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
2115
|
+
const isTypeAware = !!tsconfigPath;
|
|
2116
|
+
const [
|
|
2117
|
+
pluginSolid,
|
|
2118
|
+
parserTs
|
|
2119
|
+
] = await Promise.all([
|
|
2120
|
+
interopDefault(import("eslint-plugin-solid")),
|
|
2121
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
2122
|
+
]);
|
|
2123
|
+
return [
|
|
2124
|
+
{
|
|
2125
|
+
name: "antfu/solid/setup",
|
|
2126
|
+
plugins: {
|
|
2127
|
+
solid: pluginSolid
|
|
2128
|
+
}
|
|
2129
|
+
},
|
|
2130
|
+
{
|
|
2131
|
+
files,
|
|
2132
|
+
languageOptions: {
|
|
2133
|
+
parser: parserTs,
|
|
2134
|
+
parserOptions: {
|
|
2135
|
+
ecmaFeatures: {
|
|
2136
|
+
jsx: true
|
|
2137
|
+
},
|
|
2138
|
+
...isTypeAware ? { project: tsconfigPath } : {}
|
|
2139
|
+
},
|
|
2140
|
+
sourceType: "module"
|
|
2141
|
+
},
|
|
2142
|
+
name: "antfu/solid/rules",
|
|
2143
|
+
rules: {
|
|
2144
|
+
// reactivity
|
|
2145
|
+
"solid/components-return-once": "warn",
|
|
2146
|
+
"solid/event-handlers": ["error", {
|
|
2147
|
+
// if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
|
|
2148
|
+
ignoreCase: false,
|
|
2149
|
+
// if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
|
|
2150
|
+
warnOnSpread: false
|
|
2151
|
+
}],
|
|
2152
|
+
// these rules are mostly style suggestions
|
|
2153
|
+
"solid/imports": "error",
|
|
2154
|
+
// identifier usage is important
|
|
2155
|
+
"solid/jsx-no-duplicate-props": "error",
|
|
2156
|
+
"solid/jsx-no-script-url": "error",
|
|
2157
|
+
"solid/jsx-no-undef": "error",
|
|
2158
|
+
"solid/jsx-uses-vars": "error",
|
|
2159
|
+
"solid/no-destructure": "error",
|
|
2160
|
+
// security problems
|
|
2161
|
+
"solid/no-innerhtml": ["error", { allowStatic: true }],
|
|
2162
|
+
"solid/no-react-deps": "error",
|
|
2163
|
+
"solid/no-react-specific-props": "error",
|
|
2164
|
+
"solid/no-unknown-namespaces": "error",
|
|
2165
|
+
"solid/prefer-for": "error",
|
|
2166
|
+
"solid/reactivity": "warn",
|
|
2167
|
+
"solid/self-closing-comp": "error",
|
|
2168
|
+
"solid/style-prop": ["error", { styleProps: ["style", "css"] }],
|
|
2169
|
+
...typescript2 ? {
|
|
2170
|
+
"solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
|
|
2171
|
+
"solid/no-unknown-namespaces": "off"
|
|
2172
|
+
} : {},
|
|
2173
|
+
// overrides
|
|
2174
|
+
...overrides
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
];
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2081
2180
|
// src/factory.ts
|
|
2082
2181
|
var flatConfigProps = [
|
|
2083
2182
|
"name",
|
|
@@ -2112,21 +2211,24 @@ function dhzh(options = {}, ...userConfigs) {
|
|
|
2112
2211
|
gitignore: enableGitignore = true,
|
|
2113
2212
|
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.VSCODE_CWD || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
2114
2213
|
react: enableReact = false,
|
|
2214
|
+
solid: enableSolid = false,
|
|
2115
2215
|
svelte: enableSvelte = false,
|
|
2116
2216
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2117
2217
|
unocss: enableUnoCSS = false,
|
|
2118
2218
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2119
2219
|
} = options;
|
|
2120
2220
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2121
|
-
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2221
|
+
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
|
2122
2222
|
stylisticOptions.jsx = options.jsx ?? true;
|
|
2223
|
+
}
|
|
2123
2224
|
const configs = [];
|
|
2124
2225
|
if (enableGitignore) {
|
|
2125
2226
|
if (typeof enableGitignore !== "boolean") {
|
|
2126
2227
|
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
2127
2228
|
} else {
|
|
2128
|
-
if (import_node_fs.default.existsSync(".gitignore"))
|
|
2229
|
+
if (import_node_fs.default.existsSync(".gitignore")) {
|
|
2129
2230
|
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
2231
|
+
}
|
|
2130
2232
|
}
|
|
2131
2233
|
}
|
|
2132
2234
|
configs.push(
|
|
@@ -2147,8 +2249,9 @@ function dhzh(options = {}, ...userConfigs) {
|
|
|
2147
2249
|
// Optional plugins (installed but not enabled by default)
|
|
2148
2250
|
perfectionist()
|
|
2149
2251
|
);
|
|
2150
|
-
if (enableVue)
|
|
2252
|
+
if (enableVue) {
|
|
2151
2253
|
componentExts.push("vue");
|
|
2254
|
+
}
|
|
2152
2255
|
if (enableTypeScript) {
|
|
2153
2256
|
configs.push(typescript({
|
|
2154
2257
|
...resolveSubOptions(options, "typescript"),
|
|
@@ -2159,6 +2262,7 @@ function dhzh(options = {}, ...userConfigs) {
|
|
|
2159
2262
|
if (stylisticOptions) {
|
|
2160
2263
|
configs.push(stylistic({
|
|
2161
2264
|
...stylisticOptions,
|
|
2265
|
+
lessOpinionated: options.lessOpinionated,
|
|
2162
2266
|
overrides: getOverrides(options, "stylistic")
|
|
2163
2267
|
}));
|
|
2164
2268
|
}
|
|
@@ -2182,6 +2286,13 @@ function dhzh(options = {}, ...userConfigs) {
|
|
|
2182
2286
|
typescript: !!enableTypeScript
|
|
2183
2287
|
}));
|
|
2184
2288
|
}
|
|
2289
|
+
if (enableSolid) {
|
|
2290
|
+
configs.push(solid({
|
|
2291
|
+
overrides: getOverrides(options, "solid"),
|
|
2292
|
+
tsconfigPath: getOverrides(options, "typescript").tsconfigPath,
|
|
2293
|
+
typescript: !!enableTypeScript
|
|
2294
|
+
}));
|
|
2295
|
+
}
|
|
2185
2296
|
if (enableSvelte) {
|
|
2186
2297
|
configs.push(svelte({
|
|
2187
2298
|
overrides: getOverrides(options, "svelte"),
|
|
@@ -2240,21 +2351,23 @@ function dhzh(options = {}, ...userConfigs) {
|
|
|
2240
2351
|
));
|
|
2241
2352
|
}
|
|
2242
2353
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2243
|
-
if (key in options)
|
|
2354
|
+
if (key in options) {
|
|
2244
2355
|
acc[key] = options[key];
|
|
2356
|
+
}
|
|
2245
2357
|
return acc;
|
|
2246
2358
|
}, {});
|
|
2247
|
-
if (Object.keys(fusedConfig).length)
|
|
2359
|
+
if (Object.keys(fusedConfig).length) {
|
|
2248
2360
|
configs.push([fusedConfig]);
|
|
2249
|
-
|
|
2250
|
-
|
|
2361
|
+
}
|
|
2362
|
+
let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
2363
|
+
composer = composer.append(
|
|
2251
2364
|
...configs,
|
|
2252
2365
|
...userConfigs
|
|
2253
2366
|
);
|
|
2254
2367
|
if (autoRenamePlugins) {
|
|
2255
|
-
|
|
2368
|
+
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2256
2369
|
}
|
|
2257
|
-
return
|
|
2370
|
+
return composer;
|
|
2258
2371
|
}
|
|
2259
2372
|
function resolveSubOptions(options, key) {
|
|
2260
2373
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
@@ -2321,6 +2434,7 @@ var src_default = dhzh;
|
|
|
2321
2434
|
renamePluginInConfigs,
|
|
2322
2435
|
renameRules,
|
|
2323
2436
|
resolveSubOptions,
|
|
2437
|
+
solid,
|
|
2324
2438
|
sortPackageJson,
|
|
2325
2439
|
sortTsconfig,
|
|
2326
2440
|
stylistic,
|