@lincy/eslint-config 5.8.1 → 6.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/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/index.cjs +92 -88
- package/dist/index.d.cts +756 -299
- package/dist/index.d.ts +757 -300
- package/dist/index.js +61 -50
- package/dist/lib-B2tdYoXA.cjs +10938 -0
- package/dist/lib-DMY_mkdT.js +10961 -0
- package/package.json +42 -41
package/dist/index.js
CHANGED
|
@@ -187,8 +187,7 @@ const parserPlain = {
|
|
|
187
187
|
* Combine array and non-array configs into a single array.
|
|
188
188
|
*/
|
|
189
189
|
async function combine(...configs$1) {
|
|
190
|
-
|
|
191
|
-
return resolved.flat();
|
|
190
|
+
return (await Promise.all(configs$1)).flat();
|
|
192
191
|
}
|
|
193
192
|
function renameRules(rules, map) {
|
|
194
193
|
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
@@ -221,9 +220,7 @@ async function ensurePackages(packages) {
|
|
|
221
220
|
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) return;
|
|
222
221
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
223
222
|
if (nonExistingPackages.length === 0) return;
|
|
224
|
-
|
|
225
|
-
const result = await p.confirm({ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?` });
|
|
226
|
-
if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
223
|
+
if (await (await import("@clack/prompts")).confirm({ message: `此配置需要软件包: ${nonExistingPackages.join(", ")}. 你想安装它们吗?` })) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
227
224
|
}
|
|
228
225
|
function isInEditorEnv() {
|
|
229
226
|
if (process.env.CI) return false;
|
|
@@ -342,10 +339,9 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
342
339
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
343
340
|
useTabs: indent === "tab"
|
|
344
341
|
}, options.dprintOptions || {});
|
|
345
|
-
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
346
342
|
const configs$1 = [{
|
|
347
343
|
name: "eslint/formatter/setup",
|
|
348
|
-
plugins: { format:
|
|
344
|
+
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
349
345
|
}];
|
|
350
346
|
if (options.css) configs$1.push({
|
|
351
347
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
@@ -459,7 +455,7 @@ async function javascript(options = {}) {
|
|
|
459
455
|
const { isInEditor = false, overrides = {} } = options;
|
|
460
456
|
return [{
|
|
461
457
|
languageOptions: {
|
|
462
|
-
ecmaVersion:
|
|
458
|
+
ecmaVersion: "latest",
|
|
463
459
|
globals: {
|
|
464
460
|
...globals.browser,
|
|
465
461
|
...globals.es2021,
|
|
@@ -470,7 +466,7 @@ async function javascript(options = {}) {
|
|
|
470
466
|
},
|
|
471
467
|
parserOptions: {
|
|
472
468
|
ecmaFeatures: { jsx: true },
|
|
473
|
-
ecmaVersion:
|
|
469
|
+
ecmaVersion: "latest",
|
|
474
470
|
sourceType: "module"
|
|
475
471
|
},
|
|
476
472
|
sourceType: "module"
|
|
@@ -1065,43 +1061,7 @@ async function react(options = {}) {
|
|
|
1065
1061
|
"react-dom/no-unsafe-target-blank": "warn",
|
|
1066
1062
|
"react-dom/no-use-form-state": "error",
|
|
1067
1063
|
"react-dom/no-void-elements-with-children": "error",
|
|
1068
|
-
"react-
|
|
1069
|
-
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
1070
|
-
"react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
|
|
1071
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1072
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1073
|
-
"react-refresh/only-export-components": ["warn", {
|
|
1074
|
-
allowConstantExport: isAllowConstantExport,
|
|
1075
|
-
allowExportNames: [...isUsingNext ? [
|
|
1076
|
-
"dynamic",
|
|
1077
|
-
"dynamicParams",
|
|
1078
|
-
"revalidate",
|
|
1079
|
-
"fetchCache",
|
|
1080
|
-
"runtime",
|
|
1081
|
-
"preferredRegion",
|
|
1082
|
-
"maxDuration",
|
|
1083
|
-
"config",
|
|
1084
|
-
"generateStaticParams",
|
|
1085
|
-
"metadata",
|
|
1086
|
-
"generateMetadata",
|
|
1087
|
-
"viewport",
|
|
1088
|
-
"generateViewport"
|
|
1089
|
-
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1090
|
-
"meta",
|
|
1091
|
-
"links",
|
|
1092
|
-
"headers",
|
|
1093
|
-
"loader",
|
|
1094
|
-
"action",
|
|
1095
|
-
"clientLoader",
|
|
1096
|
-
"clientAction",
|
|
1097
|
-
"handle",
|
|
1098
|
-
"shouldRevalidate"
|
|
1099
|
-
] : []]
|
|
1100
|
-
}],
|
|
1101
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1102
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1103
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1104
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1064
|
+
"react/jsx-no-comment-textnodes": "warn",
|
|
1105
1065
|
"react/jsx-no-duplicate-props": "warn",
|
|
1106
1066
|
"react/jsx-uses-vars": "warn",
|
|
1107
1067
|
"react/no-access-state-in-setstate": "error",
|
|
@@ -1112,7 +1072,6 @@ async function react(options = {}) {
|
|
|
1112
1072
|
"react/no-children-only": "warn",
|
|
1113
1073
|
"react/no-children-to-array": "warn",
|
|
1114
1074
|
"react/no-clone-element": "warn",
|
|
1115
|
-
"react/no-comment-textnodes": "warn",
|
|
1116
1075
|
"react/no-component-will-mount": "error",
|
|
1117
1076
|
"react/no-component-will-receive-props": "error",
|
|
1118
1077
|
"react/no-component-will-update": "error",
|
|
@@ -1120,7 +1079,6 @@ async function react(options = {}) {
|
|
|
1120
1079
|
"react/no-create-ref": "error",
|
|
1121
1080
|
"react/no-default-props": "error",
|
|
1122
1081
|
"react/no-direct-mutation-state": "error",
|
|
1123
|
-
"react/no-duplicate-jsx-props": "warn",
|
|
1124
1082
|
"react/no-duplicate-key": "warn",
|
|
1125
1083
|
"react/no-forward-ref": "warn",
|
|
1126
1084
|
"react/no-implicit-key": "warn",
|
|
@@ -1132,6 +1090,7 @@ async function react(options = {}) {
|
|
|
1132
1090
|
"react/no-set-state-in-component-did-update": "warn",
|
|
1133
1091
|
"react/no-set-state-in-component-will-update": "warn",
|
|
1134
1092
|
"react/no-string-refs": "error",
|
|
1093
|
+
"react/no-unnecessary-use-prefix": "warn",
|
|
1135
1094
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1136
1095
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1137
1096
|
"react/no-unsafe-component-will-update": "warn",
|
|
@@ -1141,7 +1100,41 @@ async function react(options = {}) {
|
|
|
1141
1100
|
"react/no-unused-state": "warn",
|
|
1142
1101
|
"react/no-use-context": "warn",
|
|
1143
1102
|
"react/no-useless-forward-ref": "warn",
|
|
1144
|
-
"react/use-
|
|
1103
|
+
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1104
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
1105
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1106
|
+
"react-refresh/only-export-components": ["warn", {
|
|
1107
|
+
allowConstantExport: isAllowConstantExport,
|
|
1108
|
+
allowExportNames: [...isUsingNext ? [
|
|
1109
|
+
"dynamic",
|
|
1110
|
+
"dynamicParams",
|
|
1111
|
+
"revalidate",
|
|
1112
|
+
"fetchCache",
|
|
1113
|
+
"runtime",
|
|
1114
|
+
"preferredRegion",
|
|
1115
|
+
"maxDuration",
|
|
1116
|
+
"config",
|
|
1117
|
+
"generateStaticParams",
|
|
1118
|
+
"metadata",
|
|
1119
|
+
"generateMetadata",
|
|
1120
|
+
"viewport",
|
|
1121
|
+
"generateViewport"
|
|
1122
|
+
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1123
|
+
"meta",
|
|
1124
|
+
"links",
|
|
1125
|
+
"headers",
|
|
1126
|
+
"loader",
|
|
1127
|
+
"action",
|
|
1128
|
+
"clientLoader",
|
|
1129
|
+
"clientAction",
|
|
1130
|
+
"handle",
|
|
1131
|
+
"shouldRevalidate"
|
|
1132
|
+
] : []]
|
|
1133
|
+
}],
|
|
1134
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1135
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1136
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1137
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1145
1138
|
...overrides
|
|
1146
1139
|
}
|
|
1147
1140
|
},
|
|
@@ -1248,6 +1241,14 @@ async function sortPackageJson() {
|
|
|
1248
1241
|
order: { type: "asc" },
|
|
1249
1242
|
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
1250
1243
|
},
|
|
1244
|
+
{
|
|
1245
|
+
order: { type: "asc" },
|
|
1246
|
+
pathPattern: "^workspaces\\.catalog$"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
order: { type: "asc" },
|
|
1250
|
+
pathPattern: "^workspaces\\.catalogs\\.[^.]+$"
|
|
1251
|
+
},
|
|
1251
1252
|
{
|
|
1252
1253
|
order: [
|
|
1253
1254
|
"types",
|
|
@@ -1477,7 +1478,7 @@ async function toml(options = {}) {
|
|
|
1477
1478
|
//#endregion
|
|
1478
1479
|
//#region src/configs/typescript.ts
|
|
1479
1480
|
async function typescript(options = {}) {
|
|
1480
|
-
const { componentExts = [], overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1481
|
+
const { componentExts = [], erasableOnly = false, overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1481
1482
|
const files = options.files ?? [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
1482
1483
|
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
|
|
1483
1484
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
@@ -1610,6 +1611,16 @@ async function typescript(options = {}) {
|
|
|
1610
1611
|
...typeAwareRules,
|
|
1611
1612
|
...overrides
|
|
1612
1613
|
}
|
|
1614
|
+
}] : [],
|
|
1615
|
+
...erasableOnly ? [{
|
|
1616
|
+
name: "eslint/typescript/erasable-syntax-only",
|
|
1617
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-DMY_mkdT.js")) },
|
|
1618
|
+
rules: {
|
|
1619
|
+
"erasable-syntax-only/enums": "error",
|
|
1620
|
+
"erasable-syntax-only/import-aliases": "error",
|
|
1621
|
+
"erasable-syntax-only/namespaces": "error",
|
|
1622
|
+
"erasable-syntax-only/parameter-properties": "error"
|
|
1623
|
+
}
|
|
1613
1624
|
}] : []
|
|
1614
1625
|
];
|
|
1615
1626
|
}
|