@lincy/eslint-config 4.7.0 → 5.0.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 +5 -5
- package/dist/index.cjs +167 -107
- package/dist/index.d.cts +192 -89
- package/dist/index.d.ts +192 -89
- package/dist/index.js +159 -107
- package/package.json +45 -33
package/dist/index.cjs
CHANGED
|
@@ -50,11 +50,13 @@ __export(src_exports, {
|
|
|
50
50
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
51
51
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
52
52
|
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
53
|
+
GLOB_SVG: () => GLOB_SVG,
|
|
53
54
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
54
55
|
GLOB_TOML: () => GLOB_TOML,
|
|
55
56
|
GLOB_TS: () => GLOB_TS,
|
|
56
57
|
GLOB_TSX: () => GLOB_TSX,
|
|
57
58
|
GLOB_VUE: () => GLOB_VUE,
|
|
59
|
+
GLOB_XML: () => GLOB_XML,
|
|
58
60
|
GLOB_YAML: () => GLOB_YAML,
|
|
59
61
|
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
60
62
|
combine: () => combine,
|
|
@@ -67,6 +69,8 @@ __export(src_exports, {
|
|
|
67
69
|
imports: () => imports,
|
|
68
70
|
interopDefault: () => interopDefault,
|
|
69
71
|
isInEditorEnv: () => isInEditorEnv,
|
|
72
|
+
isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
|
|
73
|
+
isPackageInScope: () => isPackageInScope,
|
|
70
74
|
javascript: () => javascript,
|
|
71
75
|
jsdoc: () => jsdoc,
|
|
72
76
|
jsonc: () => jsonc,
|
|
@@ -93,13 +97,17 @@ __export(src_exports, {
|
|
|
93
97
|
});
|
|
94
98
|
module.exports = __toCommonJS(src_exports);
|
|
95
99
|
|
|
100
|
+
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.41_tsx@4.19.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
101
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
102
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
103
|
+
|
|
96
104
|
// src/factory.ts
|
|
97
105
|
var import_local_pkg4 = require("local-pkg");
|
|
98
106
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
99
107
|
|
|
100
108
|
// src/plugins.ts
|
|
101
109
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
102
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
110
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
103
111
|
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
104
112
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
105
113
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
@@ -110,7 +118,7 @@ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfecti
|
|
|
110
118
|
async function comments() {
|
|
111
119
|
return [
|
|
112
120
|
{
|
|
113
|
-
name: "eslint
|
|
121
|
+
name: "eslint/comments/rules",
|
|
114
122
|
plugins: {
|
|
115
123
|
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
116
124
|
},
|
|
@@ -145,6 +153,8 @@ var GLOB_SVELTE = "**/*.svelte";
|
|
|
145
153
|
var GLOB_VUE = "**/*.vue";
|
|
146
154
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
147
155
|
var GLOB_TOML = "**/*.toml";
|
|
156
|
+
var GLOB_XML = "**/*.xml";
|
|
157
|
+
var GLOB_SVG = "**/*.svg";
|
|
148
158
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
149
159
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
150
160
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
@@ -206,7 +216,7 @@ async function ignores(options = {}) {
|
|
|
206
216
|
...GLOB_EXCLUDE,
|
|
207
217
|
...ignores2
|
|
208
218
|
],
|
|
209
|
-
name: "eslint
|
|
219
|
+
name: "eslint/ignores"
|
|
210
220
|
}
|
|
211
221
|
];
|
|
212
222
|
}
|
|
@@ -218,7 +228,7 @@ async function imports(options = {}) {
|
|
|
218
228
|
} = options;
|
|
219
229
|
return [
|
|
220
230
|
{
|
|
221
|
-
name: "eslint
|
|
231
|
+
name: "eslint/imports/rules",
|
|
222
232
|
plugins: {
|
|
223
233
|
antfu: import_eslint_plugin_antfu.default,
|
|
224
234
|
import: pluginImport
|
|
@@ -241,7 +251,7 @@ async function imports(options = {}) {
|
|
|
241
251
|
},
|
|
242
252
|
{
|
|
243
253
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
244
|
-
name: "eslint
|
|
254
|
+
name: "eslint/imports/disables/bin",
|
|
245
255
|
rules: {
|
|
246
256
|
"antfu/no-import-dist": "off",
|
|
247
257
|
"antfu/no-import-node-modules-by-path": "off"
|
|
@@ -281,10 +291,10 @@ async function javascript(options = {}) {
|
|
|
281
291
|
linterOptions: {
|
|
282
292
|
reportUnusedDisableDirectives: true
|
|
283
293
|
},
|
|
284
|
-
name: "eslint
|
|
294
|
+
name: "eslint/javascript/setup"
|
|
285
295
|
},
|
|
286
296
|
{
|
|
287
|
-
name: "eslint
|
|
297
|
+
name: "eslint/javascript/rules",
|
|
288
298
|
plugins: {
|
|
289
299
|
"antfu": import_eslint_plugin_antfu.default,
|
|
290
300
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
@@ -363,9 +373,6 @@ async function javascript(options = {}) {
|
|
|
363
373
|
],
|
|
364
374
|
"no-restricted-syntax": [
|
|
365
375
|
"error",
|
|
366
|
-
"DebuggerStatement",
|
|
367
|
-
"LabeledStatement",
|
|
368
|
-
"WithStatement",
|
|
369
376
|
"TSEnumDeclaration[const=true]",
|
|
370
377
|
"TSExportAssignment"
|
|
371
378
|
],
|
|
@@ -468,7 +475,7 @@ async function javascript(options = {}) {
|
|
|
468
475
|
},
|
|
469
476
|
{
|
|
470
477
|
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
471
|
-
name: "eslint
|
|
478
|
+
name: "eslint/scripts/disables",
|
|
472
479
|
rules: {
|
|
473
480
|
"no-console": "off"
|
|
474
481
|
}
|
|
@@ -478,7 +485,10 @@ async function javascript(options = {}) {
|
|
|
478
485
|
|
|
479
486
|
// src/utils.ts
|
|
480
487
|
var import_node_process = __toESM(require("process"), 1);
|
|
488
|
+
var import_node_url = require("url");
|
|
481
489
|
var import_local_pkg = require("local-pkg");
|
|
490
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
491
|
+
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@antfu/eslint-config");
|
|
482
492
|
async function combine(...configs2) {
|
|
483
493
|
const resolved = await Promise.all(configs2);
|
|
484
494
|
return resolved.flat();
|
|
@@ -521,28 +531,31 @@ async function interopDefault(m) {
|
|
|
521
531
|
const resolved = await m;
|
|
522
532
|
return resolved.default || resolved;
|
|
523
533
|
}
|
|
534
|
+
function isPackageInScope(name) {
|
|
535
|
+
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
536
|
+
}
|
|
524
537
|
async function ensurePackages(packages) {
|
|
525
|
-
if (import_node_process.default.stdout.isTTY === false)
|
|
538
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
|
|
526
539
|
return;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (nonExistingPackages.length === 0) {
|
|
540
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
541
|
+
if (nonExistingPackages.length === 0)
|
|
530
542
|
return;
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
name: "result",
|
|
537
|
-
type: "confirm"
|
|
538
|
-
}
|
|
539
|
-
]);
|
|
540
|
-
if (result) {
|
|
543
|
+
const p = await import("@clack/prompts");
|
|
544
|
+
const result = await p.confirm({
|
|
545
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
546
|
+
});
|
|
547
|
+
if (result)
|
|
541
548
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
542
|
-
}
|
|
543
549
|
}
|
|
544
550
|
function isInEditorEnv() {
|
|
545
|
-
|
|
551
|
+
if (import_node_process.default.env.CI)
|
|
552
|
+
return false;
|
|
553
|
+
if (isInGitHooksOrLintStaged())
|
|
554
|
+
return false;
|
|
555
|
+
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
|
|
556
|
+
}
|
|
557
|
+
function isInGitHooksOrLintStaged() {
|
|
558
|
+
return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
546
559
|
}
|
|
547
560
|
|
|
548
561
|
// src/configs/jsdoc.ts
|
|
@@ -552,7 +565,7 @@ async function jsdoc(options = {}) {
|
|
|
552
565
|
} = options;
|
|
553
566
|
return [
|
|
554
567
|
{
|
|
555
|
-
name: "eslint
|
|
568
|
+
name: "eslint/jsdoc/rules",
|
|
556
569
|
plugins: {
|
|
557
570
|
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
558
571
|
},
|
|
@@ -597,7 +610,7 @@ async function jsonc(options = {}) {
|
|
|
597
610
|
]);
|
|
598
611
|
return [
|
|
599
612
|
{
|
|
600
|
-
name: "eslint
|
|
613
|
+
name: "eslint/jsonc/setup",
|
|
601
614
|
plugins: {
|
|
602
615
|
jsonc: pluginJsonc
|
|
603
616
|
}
|
|
@@ -607,7 +620,7 @@ async function jsonc(options = {}) {
|
|
|
607
620
|
languageOptions: {
|
|
608
621
|
parser: parserJsonc
|
|
609
622
|
},
|
|
610
|
-
name: "eslint
|
|
623
|
+
name: "eslint/jsonc/rules",
|
|
611
624
|
rules: {
|
|
612
625
|
"jsonc/no-bigint-literals": "error",
|
|
613
626
|
"jsonc/no-binary-expression": "error",
|
|
@@ -665,7 +678,7 @@ async function jsx() {
|
|
|
665
678
|
}
|
|
666
679
|
}
|
|
667
680
|
},
|
|
668
|
-
name: "eslint
|
|
681
|
+
name: "eslint/jsx/setup"
|
|
669
682
|
}
|
|
670
683
|
];
|
|
671
684
|
}
|
|
@@ -682,7 +695,7 @@ async function markdown(options = {}) {
|
|
|
682
695
|
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
683
696
|
return [
|
|
684
697
|
{
|
|
685
|
-
name: "eslint
|
|
698
|
+
name: "eslint/markdown/setup",
|
|
686
699
|
plugins: {
|
|
687
700
|
markdown: markdown2
|
|
688
701
|
}
|
|
@@ -690,7 +703,7 @@ async function markdown(options = {}) {
|
|
|
690
703
|
{
|
|
691
704
|
files,
|
|
692
705
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
693
|
-
name: "eslint
|
|
706
|
+
name: "eslint/markdown/processor",
|
|
694
707
|
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
695
708
|
markdown2.processors.markdown,
|
|
696
709
|
import_eslint_merge_processors.processorPassThrough
|
|
@@ -701,7 +714,7 @@ async function markdown(options = {}) {
|
|
|
701
714
|
languageOptions: {
|
|
702
715
|
parser: parserPlain
|
|
703
716
|
},
|
|
704
|
-
name: "eslint
|
|
717
|
+
name: "eslint/markdown/parser"
|
|
705
718
|
},
|
|
706
719
|
{
|
|
707
720
|
files: [
|
|
@@ -715,7 +728,7 @@ async function markdown(options = {}) {
|
|
|
715
728
|
}
|
|
716
729
|
}
|
|
717
730
|
},
|
|
718
|
-
name: "eslint
|
|
731
|
+
name: "eslint/markdown/disables",
|
|
719
732
|
rules: {
|
|
720
733
|
"import/newline-after-import": "off",
|
|
721
734
|
"no-alert": "off",
|
|
@@ -769,7 +782,7 @@ async function markdown(options = {}) {
|
|
|
769
782
|
async function perfectionist() {
|
|
770
783
|
return [
|
|
771
784
|
{
|
|
772
|
-
name: "eslint
|
|
785
|
+
name: "eslint/perfectionist/setup",
|
|
773
786
|
plugins: {
|
|
774
787
|
perfectionist: import_eslint_plugin_perfectionist.default
|
|
775
788
|
}
|
|
@@ -811,7 +824,7 @@ async function stylistic(options = {}) {
|
|
|
811
824
|
});
|
|
812
825
|
return [
|
|
813
826
|
{
|
|
814
|
-
name: "eslint
|
|
827
|
+
name: "eslint/stylistic/rules",
|
|
815
828
|
plugins: {
|
|
816
829
|
antfu: import_eslint_plugin_antfu.default,
|
|
817
830
|
style: pluginStylistic
|
|
@@ -839,17 +852,21 @@ async function stylistic(options = {}) {
|
|
|
839
852
|
// src/configs/formatters.ts
|
|
840
853
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
841
854
|
const defaultIndent = 4;
|
|
842
|
-
await ensurePackages([
|
|
843
|
-
"eslint-plugin-format"
|
|
844
|
-
]);
|
|
845
855
|
if (options === true) {
|
|
856
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
846
857
|
options = {
|
|
847
858
|
css: false,
|
|
848
859
|
graphql: true,
|
|
849
860
|
html: true,
|
|
850
|
-
markdown: true
|
|
861
|
+
markdown: true,
|
|
862
|
+
svg: isPrettierPluginXmlInScope,
|
|
863
|
+
xml: isPrettierPluginXmlInScope
|
|
851
864
|
};
|
|
852
865
|
}
|
|
866
|
+
await ensurePackages([
|
|
867
|
+
"eslint-plugin-format",
|
|
868
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
869
|
+
]);
|
|
853
870
|
const {
|
|
854
871
|
indent,
|
|
855
872
|
quotes,
|
|
@@ -861,6 +878,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
861
878
|
const prettierOptions = Object.assign(
|
|
862
879
|
{
|
|
863
880
|
endOfLine: "lf",
|
|
881
|
+
printWidth: 200,
|
|
864
882
|
semi,
|
|
865
883
|
singleQuote: quotes === "single",
|
|
866
884
|
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
@@ -869,6 +887,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
869
887
|
},
|
|
870
888
|
options.prettierOptions || {}
|
|
871
889
|
);
|
|
890
|
+
const prettierXmlOptions = {
|
|
891
|
+
xmlQuoteAttributes: "double",
|
|
892
|
+
xmlSelfClosingSpace: true,
|
|
893
|
+
xmlSortAttributesByKey: false,
|
|
894
|
+
xmlWhitespaceSensitivity: "ignore"
|
|
895
|
+
};
|
|
872
896
|
const dprintOptions = Object.assign(
|
|
873
897
|
{
|
|
874
898
|
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
@@ -880,7 +904,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
880
904
|
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
881
905
|
const configs2 = [
|
|
882
906
|
{
|
|
883
|
-
name: "eslint
|
|
907
|
+
name: "eslint/formatters/setup",
|
|
884
908
|
plugins: {
|
|
885
909
|
format: pluginFormat
|
|
886
910
|
}
|
|
@@ -893,7 +917,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
893
917
|
languageOptions: {
|
|
894
918
|
parser: parserPlain2
|
|
895
919
|
},
|
|
896
|
-
name: "eslint
|
|
920
|
+
name: "eslint/formatters/css",
|
|
897
921
|
rules: {
|
|
898
922
|
"format/prettier": [
|
|
899
923
|
"error",
|
|
@@ -909,7 +933,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
909
933
|
languageOptions: {
|
|
910
934
|
parser: parserPlain2
|
|
911
935
|
},
|
|
912
|
-
name: "eslint
|
|
936
|
+
name: "eslint/formatters/scss",
|
|
913
937
|
rules: {
|
|
914
938
|
"format/prettier": [
|
|
915
939
|
"error",
|
|
@@ -925,7 +949,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
925
949
|
languageOptions: {
|
|
926
950
|
parser: parserPlain2
|
|
927
951
|
},
|
|
928
|
-
name: "eslint
|
|
952
|
+
name: "eslint/formatters/less",
|
|
929
953
|
rules: {
|
|
930
954
|
"format/prettier": [
|
|
931
955
|
"error",
|
|
@@ -944,7 +968,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
944
968
|
languageOptions: {
|
|
945
969
|
parser: parserPlain2
|
|
946
970
|
},
|
|
947
|
-
name: "eslint
|
|
971
|
+
name: "eslint/formatters/html",
|
|
948
972
|
rules: {
|
|
949
973
|
"format/prettier": [
|
|
950
974
|
"error",
|
|
@@ -956,6 +980,28 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
956
980
|
}
|
|
957
981
|
});
|
|
958
982
|
}
|
|
983
|
+
if (options.svg) {
|
|
984
|
+
configs2.push({
|
|
985
|
+
files: [GLOB_SVG],
|
|
986
|
+
languageOptions: {
|
|
987
|
+
parser: parserPlain2
|
|
988
|
+
},
|
|
989
|
+
name: "eslint/formatters/svg",
|
|
990
|
+
rules: {
|
|
991
|
+
"format/prettier": [
|
|
992
|
+
"error",
|
|
993
|
+
{
|
|
994
|
+
...prettierXmlOptions,
|
|
995
|
+
...prettierOptions,
|
|
996
|
+
parser: "xml",
|
|
997
|
+
plugins: [
|
|
998
|
+
"@prettier/plugin-xml"
|
|
999
|
+
]
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
959
1005
|
if (options.markdown) {
|
|
960
1006
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
961
1007
|
configs2.push({
|
|
@@ -963,12 +1009,11 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
963
1009
|
languageOptions: {
|
|
964
1010
|
parser: parserPlain2
|
|
965
1011
|
},
|
|
966
|
-
name: "eslint
|
|
1012
|
+
name: "eslint/formatters/markdown",
|
|
967
1013
|
rules: {
|
|
968
1014
|
[`format/${formater}`]: [
|
|
969
1015
|
"error",
|
|
970
1016
|
formater === "prettier" ? {
|
|
971
|
-
printWidth: 200,
|
|
972
1017
|
...prettierOptions,
|
|
973
1018
|
embeddedLanguageFormatting: "off",
|
|
974
1019
|
parser: "markdown"
|
|
@@ -986,7 +1031,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
986
1031
|
languageOptions: {
|
|
987
1032
|
parser: parserPlain2
|
|
988
1033
|
},
|
|
989
|
-
name: "eslint
|
|
1034
|
+
name: "eslint/formatters/graphql",
|
|
990
1035
|
rules: {
|
|
991
1036
|
"format/prettier": [
|
|
992
1037
|
"error",
|
|
@@ -1005,7 +1050,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
1005
1050
|
async function node() {
|
|
1006
1051
|
return [
|
|
1007
1052
|
{
|
|
1008
|
-
name: "eslint
|
|
1053
|
+
name: "eslint/node/rules",
|
|
1009
1054
|
plugins: {
|
|
1010
1055
|
node: import_eslint_plugin_n.default
|
|
1011
1056
|
},
|
|
@@ -1061,7 +1106,7 @@ async function react(options = {}) {
|
|
|
1061
1106
|
const plugins = pluginReact.configs.all.plugins;
|
|
1062
1107
|
return [
|
|
1063
1108
|
{
|
|
1064
|
-
name: "eslint
|
|
1109
|
+
name: "eslint/react/setup",
|
|
1065
1110
|
plugins: {
|
|
1066
1111
|
"react": plugins["@eslint-react"],
|
|
1067
1112
|
"react-dom": plugins["@eslint-react/dom"],
|
|
@@ -1082,7 +1127,7 @@ async function react(options = {}) {
|
|
|
1082
1127
|
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1083
1128
|
}
|
|
1084
1129
|
},
|
|
1085
|
-
name: "eslint
|
|
1130
|
+
name: "eslint/react/rules",
|
|
1086
1131
|
rules: {
|
|
1087
1132
|
// recommended rules from @eslint-react/dom
|
|
1088
1133
|
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
@@ -1186,7 +1231,7 @@ async function sortPackageJson() {
|
|
|
1186
1231
|
return [
|
|
1187
1232
|
{
|
|
1188
1233
|
files: ["**/package.json"],
|
|
1189
|
-
name: "eslint
|
|
1234
|
+
name: "eslint/sort/package-json",
|
|
1190
1235
|
rules: {
|
|
1191
1236
|
"jsonc/sort-array-values": [
|
|
1192
1237
|
"error",
|
|
@@ -1288,7 +1333,7 @@ function sortTsconfig() {
|
|
|
1288
1333
|
return [
|
|
1289
1334
|
{
|
|
1290
1335
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
1291
|
-
name: "eslint
|
|
1336
|
+
name: "eslint/sort/tsconfig",
|
|
1292
1337
|
rules: {
|
|
1293
1338
|
"jsonc/sort-keys": [
|
|
1294
1339
|
"error",
|
|
@@ -1421,13 +1466,13 @@ async function test(options = {}) {
|
|
|
1421
1466
|
pluginVitest,
|
|
1422
1467
|
pluginNoOnlyTests
|
|
1423
1468
|
] = await Promise.all([
|
|
1424
|
-
interopDefault(import("eslint-plugin
|
|
1469
|
+
interopDefault(import("@vitest/eslint-plugin")),
|
|
1425
1470
|
// @ts-expect-error missing types
|
|
1426
1471
|
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1427
1472
|
]);
|
|
1428
1473
|
return [
|
|
1429
1474
|
{
|
|
1430
|
-
name: "eslint
|
|
1475
|
+
name: "eslint/test/setup",
|
|
1431
1476
|
plugins: {
|
|
1432
1477
|
test: {
|
|
1433
1478
|
...pluginVitest,
|
|
@@ -1441,7 +1486,7 @@ async function test(options = {}) {
|
|
|
1441
1486
|
},
|
|
1442
1487
|
{
|
|
1443
1488
|
files,
|
|
1444
|
-
name: "eslint
|
|
1489
|
+
name: "eslint/test/rules",
|
|
1445
1490
|
rules: {
|
|
1446
1491
|
"node/prefer-global/process": "off",
|
|
1447
1492
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
@@ -1470,6 +1515,9 @@ async function typescript(options = {}) {
|
|
|
1470
1515
|
GLOB_SRC,
|
|
1471
1516
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1472
1517
|
];
|
|
1518
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1519
|
+
`${GLOB_MARKDOWN}/**`
|
|
1520
|
+
];
|
|
1473
1521
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1474
1522
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1475
1523
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -1522,13 +1570,13 @@ async function typescript(options = {}) {
|
|
|
1522
1570
|
...parserOptions
|
|
1523
1571
|
}
|
|
1524
1572
|
},
|
|
1525
|
-
name: `eslint
|
|
1573
|
+
name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
1526
1574
|
};
|
|
1527
1575
|
}
|
|
1528
1576
|
return [
|
|
1529
1577
|
{
|
|
1530
1578
|
// Install the plugins without globs, so they can be configured separately.
|
|
1531
|
-
name: "eslint
|
|
1579
|
+
name: "eslint/typescript/setup",
|
|
1532
1580
|
plugins: {
|
|
1533
1581
|
antfu: import_eslint_plugin_antfu.default,
|
|
1534
1582
|
ts: pluginTs
|
|
@@ -1536,14 +1584,14 @@ async function typescript(options = {}) {
|
|
|
1536
1584
|
},
|
|
1537
1585
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
1538
1586
|
...isTypeAware ? [
|
|
1539
|
-
makeParser(
|
|
1540
|
-
makeParser(
|
|
1587
|
+
makeParser(false, files),
|
|
1588
|
+
makeParser(true, filesTypeAware, ignoresTypeAware)
|
|
1541
1589
|
] : [
|
|
1542
1590
|
makeParser(false, files)
|
|
1543
1591
|
],
|
|
1544
1592
|
{
|
|
1545
1593
|
files,
|
|
1546
|
-
name: "eslint
|
|
1594
|
+
name: "eslint/typescript/rules",
|
|
1547
1595
|
rules: {
|
|
1548
1596
|
...renameRules(
|
|
1549
1597
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
@@ -1594,7 +1642,8 @@ async function typescript(options = {}) {
|
|
|
1594
1642
|
},
|
|
1595
1643
|
...isTypeAware ? [{
|
|
1596
1644
|
files: filesTypeAware,
|
|
1597
|
-
|
|
1645
|
+
ignores: ignoresTypeAware,
|
|
1646
|
+
name: "eslint/typescript/rules-type-aware",
|
|
1598
1647
|
rules: {
|
|
1599
1648
|
...typeAwareRules,
|
|
1600
1649
|
...overrides
|
|
@@ -1602,7 +1651,7 @@ async function typescript(options = {}) {
|
|
|
1602
1651
|
}] : [],
|
|
1603
1652
|
{
|
|
1604
1653
|
files: ["**/*.d.?([cm])ts"],
|
|
1605
|
-
name: "eslint
|
|
1654
|
+
name: "eslint/typescript/disables/dts",
|
|
1606
1655
|
rules: {
|
|
1607
1656
|
"eslint-comments/no-unlimited-disable": "off",
|
|
1608
1657
|
"import/no-duplicates": "off",
|
|
@@ -1612,14 +1661,14 @@ async function typescript(options = {}) {
|
|
|
1612
1661
|
},
|
|
1613
1662
|
{
|
|
1614
1663
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1615
|
-
name: "eslint
|
|
1664
|
+
name: "eslint/typescript/disables/test",
|
|
1616
1665
|
rules: {
|
|
1617
1666
|
"no-unused-expressions": "off"
|
|
1618
1667
|
}
|
|
1619
1668
|
},
|
|
1620
1669
|
{
|
|
1621
1670
|
files: ["**/*.js", "**/*.cjs"],
|
|
1622
|
-
name: "eslint
|
|
1671
|
+
name: "eslint/typescript/disables/cjs",
|
|
1623
1672
|
rules: {
|
|
1624
1673
|
"ts/no-require-imports": "off",
|
|
1625
1674
|
"ts/no-var-requires": "off"
|
|
@@ -1629,40 +1678,32 @@ async function typescript(options = {}) {
|
|
|
1629
1678
|
}
|
|
1630
1679
|
|
|
1631
1680
|
// src/configs/unicorn.ts
|
|
1632
|
-
async function unicorn() {
|
|
1681
|
+
async function unicorn(options = {}) {
|
|
1633
1682
|
return [
|
|
1634
1683
|
{
|
|
1635
|
-
name: "eslint
|
|
1684
|
+
name: "eslint/unicorn/rules",
|
|
1636
1685
|
plugins: {
|
|
1637
1686
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1638
1687
|
},
|
|
1639
1688
|
rules: {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1659
|
-
"unicorn/prefer-number-properties": "error",
|
|
1660
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1661
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1662
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
1663
|
-
"unicorn/prefer-type-error": "error",
|
|
1664
|
-
// Use new when throwing error
|
|
1665
|
-
"unicorn/throw-new-error": "error"
|
|
1689
|
+
...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
|
|
1690
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1691
|
+
"unicorn/consistent-function-scoping": "error",
|
|
1692
|
+
"unicorn/error-message": "error",
|
|
1693
|
+
"unicorn/escape-case": "error",
|
|
1694
|
+
"unicorn/new-for-builtins": "error",
|
|
1695
|
+
"unicorn/no-instanceof-array": "error",
|
|
1696
|
+
"unicorn/no-new-array": "error",
|
|
1697
|
+
"unicorn/no-new-buffer": "error",
|
|
1698
|
+
"unicorn/number-literal-case": "error",
|
|
1699
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1700
|
+
"unicorn/prefer-includes": "error",
|
|
1701
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1702
|
+
"unicorn/prefer-number-properties": "error",
|
|
1703
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1704
|
+
"unicorn/prefer-type-error": "error",
|
|
1705
|
+
"unicorn/throw-new-error": "error"
|
|
1706
|
+
}
|
|
1666
1707
|
}
|
|
1667
1708
|
}
|
|
1668
1709
|
];
|
|
@@ -1685,7 +1726,7 @@ async function unocss(options = {}) {
|
|
|
1685
1726
|
]);
|
|
1686
1727
|
return [
|
|
1687
1728
|
{
|
|
1688
|
-
name: "eslint
|
|
1729
|
+
name: "eslint/unocss/rules",
|
|
1689
1730
|
plugins: {
|
|
1690
1731
|
unocss: pluginUnoCSS
|
|
1691
1732
|
},
|
|
@@ -1750,7 +1791,7 @@ async function vue(options = {}) {
|
|
|
1750
1791
|
watchEffect: "readonly"
|
|
1751
1792
|
}
|
|
1752
1793
|
},
|
|
1753
|
-
name: "eslint
|
|
1794
|
+
name: "eslint/vue/setup",
|
|
1754
1795
|
plugins: {
|
|
1755
1796
|
vue: pluginVue
|
|
1756
1797
|
}
|
|
@@ -1768,7 +1809,7 @@ async function vue(options = {}) {
|
|
|
1768
1809
|
sourceType: "module"
|
|
1769
1810
|
}
|
|
1770
1811
|
},
|
|
1771
|
-
name: "eslint
|
|
1812
|
+
name: "eslint/vue/rules",
|
|
1772
1813
|
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
|
|
1773
1814
|
pluginVue.processors[".vue"],
|
|
1774
1815
|
processorVueBlocks({
|
|
@@ -1897,7 +1938,7 @@ async function yaml(options = {}) {
|
|
|
1897
1938
|
]);
|
|
1898
1939
|
return [
|
|
1899
1940
|
{
|
|
1900
|
-
name: "eslint
|
|
1941
|
+
name: "eslint/yaml/setup",
|
|
1901
1942
|
plugins: {
|
|
1902
1943
|
yaml: pluginYaml
|
|
1903
1944
|
}
|
|
@@ -1907,7 +1948,7 @@ async function yaml(options = {}) {
|
|
|
1907
1948
|
languageOptions: {
|
|
1908
1949
|
parser: parserYaml
|
|
1909
1950
|
},
|
|
1910
|
-
name: "eslint
|
|
1951
|
+
name: "eslint/yaml/rules",
|
|
1911
1952
|
rules: {
|
|
1912
1953
|
"style/spaced-comment": "off",
|
|
1913
1954
|
"yaml/block-mapping": "error",
|
|
@@ -1955,7 +1996,7 @@ async function toml(options = {}) {
|
|
|
1955
1996
|
]);
|
|
1956
1997
|
return [
|
|
1957
1998
|
{
|
|
1958
|
-
name: "eslint
|
|
1999
|
+
name: "eslint/toml/setup",
|
|
1959
2000
|
plugins: {
|
|
1960
2001
|
toml: pluginToml
|
|
1961
2002
|
}
|
|
@@ -1965,7 +2006,7 @@ async function toml(options = {}) {
|
|
|
1965
2006
|
languageOptions: {
|
|
1966
2007
|
parser: parserToml
|
|
1967
2008
|
},
|
|
1968
|
-
name: "eslint
|
|
2009
|
+
name: "eslint/toml/rules",
|
|
1969
2010
|
rules: {
|
|
1970
2011
|
"style/spaced-comment": "off",
|
|
1971
2012
|
"toml/comma-style": "error",
|
|
@@ -1998,8 +2039,6 @@ async function toml(options = {}) {
|
|
|
1998
2039
|
// src/factory.ts
|
|
1999
2040
|
var flatConfigProps = [
|
|
2000
2041
|
"name",
|
|
2001
|
-
"files",
|
|
2002
|
-
"ignores",
|
|
2003
2042
|
"languageOptions",
|
|
2004
2043
|
"linterOptions",
|
|
2005
2044
|
"processor",
|
|
@@ -2034,15 +2073,21 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2034
2073
|
autoRenamePlugins = true,
|
|
2035
2074
|
componentExts = [],
|
|
2036
2075
|
gitignore: enableGitignore = true,
|
|
2037
|
-
isInEditor = isInEditorEnv(),
|
|
2038
2076
|
jsx: enableJsx = true,
|
|
2039
2077
|
overrides = {},
|
|
2040
2078
|
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
2041
2079
|
regexp: enableRegexp = true,
|
|
2042
2080
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2081
|
+
unicorn: enableUnicorn = true,
|
|
2043
2082
|
unocss: enableUnoCSS = false,
|
|
2044
2083
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2045
2084
|
} = options;
|
|
2085
|
+
let isInEditor = options.isInEditor;
|
|
2086
|
+
if (isInEditor == null) {
|
|
2087
|
+
isInEditor = isInEditorEnv();
|
|
2088
|
+
if (isInEditor)
|
|
2089
|
+
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2090
|
+
}
|
|
2046
2091
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2047
2092
|
const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
|
|
2048
2093
|
if (stylisticOptions) {
|
|
@@ -2053,9 +2098,15 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2053
2098
|
const configs2 = [];
|
|
2054
2099
|
if (enableGitignore) {
|
|
2055
2100
|
if (typeof enableGitignore !== "boolean") {
|
|
2056
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(
|
|
2101
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2102
|
+
name: "eslint/gitignore",
|
|
2103
|
+
...enableGitignore
|
|
2104
|
+
})]));
|
|
2057
2105
|
} else {
|
|
2058
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2106
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2107
|
+
name: "eslint/gitignore",
|
|
2108
|
+
strict: false
|
|
2109
|
+
})]));
|
|
2059
2110
|
}
|
|
2060
2111
|
}
|
|
2061
2112
|
configs2.push(
|
|
@@ -2074,10 +2125,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2074
2125
|
imports({
|
|
2075
2126
|
stylistic: stylisticOptions
|
|
2076
2127
|
}),
|
|
2077
|
-
unicorn(),
|
|
2078
2128
|
// Optional plugins (installed but not enabled by default)
|
|
2079
2129
|
perfectionist()
|
|
2080
2130
|
);
|
|
2131
|
+
if (enableUnicorn) {
|
|
2132
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2133
|
+
}
|
|
2081
2134
|
if (enableVue) {
|
|
2082
2135
|
componentExts.push("vue");
|
|
2083
2136
|
}
|
|
@@ -2170,6 +2223,9 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2170
2223
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2171
2224
|
));
|
|
2172
2225
|
}
|
|
2226
|
+
if ("files" in options) {
|
|
2227
|
+
throw new Error("[@lincy/eslint-config] \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E0D\u5E94\u5305\u542B\u201Cfiles\u201D\u5C5E\u6027\uFF0C\u56E0\u4E3A\u9009\u9879\u5E94\u8BE5\u662F\u5168\u5C40\u7684\u3002\u8BF7\u5C06\u5176\u653E\u5728\u7B2C\u4E8C\u4E2A\u6216\u66F4\u540E\u9762\u7684\u914D\u7F6E\u4E2D\u3002");
|
|
2228
|
+
}
|
|
2173
2229
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2174
2230
|
if (key in options) {
|
|
2175
2231
|
acc[key] = options[key];
|
|
@@ -2214,11 +2270,13 @@ var src_default = lincy;
|
|
|
2214
2270
|
GLOB_SRC_EXT,
|
|
2215
2271
|
GLOB_STYLE,
|
|
2216
2272
|
GLOB_SVELTE,
|
|
2273
|
+
GLOB_SVG,
|
|
2217
2274
|
GLOB_TESTS,
|
|
2218
2275
|
GLOB_TOML,
|
|
2219
2276
|
GLOB_TS,
|
|
2220
2277
|
GLOB_TSX,
|
|
2221
2278
|
GLOB_VUE,
|
|
2279
|
+
GLOB_XML,
|
|
2222
2280
|
GLOB_YAML,
|
|
2223
2281
|
StylisticConfigDefaults,
|
|
2224
2282
|
combine,
|
|
@@ -2230,6 +2288,8 @@ var src_default = lincy;
|
|
|
2230
2288
|
imports,
|
|
2231
2289
|
interopDefault,
|
|
2232
2290
|
isInEditorEnv,
|
|
2291
|
+
isInGitHooksOrLintStaged,
|
|
2292
|
+
isPackageInScope,
|
|
2233
2293
|
javascript,
|
|
2234
2294
|
jsdoc,
|
|
2235
2295
|
jsonc,
|