@pengzhanbo/eslint-config 2.1.0 → 2.3.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/index.d.mts +960 -582
- package/dist/index.mjs +53 -157
- package/package.json +45 -46
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import fs from "node:fs";
|
|
5
|
+
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 } = {}) {
|
|
@@ -27,7 +27,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
|
|
|
27
27
|
while (directory) {
|
|
28
28
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
29
29
|
try {
|
|
30
|
-
const stats = await
|
|
30
|
+
const stats = await fs.stat(filePath);
|
|
31
31
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
32
32
|
} catch {}
|
|
33
33
|
if (directory === stopAt || directory === root) break;
|
|
@@ -42,14 +42,13 @@ function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
|
42
42
|
while (directory) {
|
|
43
43
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
44
44
|
try {
|
|
45
|
-
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
45
|
+
const stats = fs$1.statSync(filePath, { throwIfNoEntry: false });
|
|
46
46
|
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
47
47
|
} catch {}
|
|
48
48
|
if (directory === stopAt || directory === root) break;
|
|
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)";
|
|
@@ -131,7 +130,6 @@ const GLOB_EXCLUDE = [
|
|
|
131
130
|
"**/auto-import?(s).d.ts",
|
|
132
131
|
"**/components.d.ts"
|
|
133
132
|
];
|
|
134
|
-
|
|
135
133
|
//#endregion
|
|
136
134
|
//#region src/utils.ts
|
|
137
135
|
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -230,12 +228,11 @@ async function ensurePackages(packages) {
|
|
|
230
228
|
function isInEditorEnv() {
|
|
231
229
|
if (process.env.CI) return false;
|
|
232
230
|
if (isInGitHooksOrLintStaged()) return false;
|
|
233
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
231
|
+
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);
|
|
234
232
|
}
|
|
235
233
|
function isInGitHooksOrLintStaged() {
|
|
236
234
|
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
237
235
|
}
|
|
238
|
-
|
|
239
236
|
//#endregion
|
|
240
237
|
//#region src/configs/angular.ts
|
|
241
238
|
async function angular(options = {}) {
|
|
@@ -301,7 +298,6 @@ async function angular(options = {}) {
|
|
|
301
298
|
}
|
|
302
299
|
];
|
|
303
300
|
}
|
|
304
|
-
|
|
305
301
|
//#endregion
|
|
306
302
|
//#region src/configs/astro.ts
|
|
307
303
|
async function astro(options = {}) {
|
|
@@ -349,7 +345,6 @@ async function astro(options = {}) {
|
|
|
349
345
|
}
|
|
350
346
|
}];
|
|
351
347
|
}
|
|
352
|
-
|
|
353
348
|
//#endregion
|
|
354
349
|
//#region src/configs/command.ts
|
|
355
350
|
async function command() {
|
|
@@ -358,7 +353,6 @@ async function command() {
|
|
|
358
353
|
name: "config/command/rules"
|
|
359
354
|
}];
|
|
360
355
|
}
|
|
361
|
-
|
|
362
356
|
//#endregion
|
|
363
357
|
//#region src/configs/comments.ts
|
|
364
358
|
async function comments() {
|
|
@@ -373,7 +367,6 @@ async function comments() {
|
|
|
373
367
|
}
|
|
374
368
|
}];
|
|
375
369
|
}
|
|
376
|
-
|
|
377
370
|
//#endregion
|
|
378
371
|
//#region src/configs/disables.ts
|
|
379
372
|
async function disables() {
|
|
@@ -428,7 +421,26 @@ async function disables() {
|
|
|
428
421
|
}
|
|
429
422
|
];
|
|
430
423
|
}
|
|
431
|
-
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/configs/e18e.ts
|
|
426
|
+
async function e18e(options = {}) {
|
|
427
|
+
const { isInEditor = false, modernization = true, type = "app", moduleReplacements = type === "lib" && isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
428
|
+
const configs = pluginE18e.configs;
|
|
429
|
+
return [{
|
|
430
|
+
name: "config/e18e/rules",
|
|
431
|
+
plugins: { e18e: pluginE18e },
|
|
432
|
+
rules: {
|
|
433
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
434
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
435
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
436
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
437
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
438
|
+
"e18e/prefer-array-to-spliced": "off",
|
|
439
|
+
"e18e/prefer-spread-syntax": "off",
|
|
440
|
+
...overrides
|
|
441
|
+
}
|
|
442
|
+
}];
|
|
443
|
+
}
|
|
432
444
|
//#endregion
|
|
433
445
|
//#region src/configs/stylistic.ts
|
|
434
446
|
const StylisticConfigDefaults = {
|
|
@@ -479,7 +491,6 @@ async function stylistic(options = {}) {
|
|
|
479
491
|
}
|
|
480
492
|
}];
|
|
481
493
|
}
|
|
482
|
-
|
|
483
494
|
//#endregion
|
|
484
495
|
//#region src/configs/formatters.ts
|
|
485
496
|
const formatPackages = ["eslint-plugin-format"];
|
|
@@ -525,11 +536,12 @@ async function formatters(options = {}, stylistic = {}) {
|
|
|
525
536
|
xmlSortAttributesByKey: false,
|
|
526
537
|
xmlWhitespaceSensitivity: "ignore"
|
|
527
538
|
};
|
|
528
|
-
const dprintOptions =
|
|
539
|
+
const dprintOptions = {
|
|
529
540
|
indentWidth: typeof indent === "number" ? indent : 2,
|
|
530
541
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
531
|
-
useTabs: indent === "tab"
|
|
532
|
-
|
|
542
|
+
useTabs: indent === "tab",
|
|
543
|
+
...options.dprintOptions || {}
|
|
544
|
+
};
|
|
533
545
|
const configs = [{
|
|
534
546
|
name: "config/formatters/setup",
|
|
535
547
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
@@ -627,7 +639,6 @@ async function formatters(options = {}, stylistic = {}) {
|
|
|
627
639
|
});
|
|
628
640
|
return configs;
|
|
629
641
|
}
|
|
630
|
-
|
|
631
642
|
//#endregion
|
|
632
643
|
//#region src/configs/ignores.ts
|
|
633
644
|
async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
@@ -640,7 +651,6 @@ async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
|
640
651
|
name: "config/ignores"
|
|
641
652
|
}];
|
|
642
653
|
}
|
|
643
|
-
|
|
644
654
|
//#endregion
|
|
645
655
|
//#region src/configs/imports.ts
|
|
646
656
|
async function imports(_options = {}) {
|
|
@@ -654,7 +664,6 @@ async function imports(_options = {}) {
|
|
|
654
664
|
}
|
|
655
665
|
}];
|
|
656
666
|
}
|
|
657
|
-
|
|
658
667
|
//#endregion
|
|
659
668
|
//#region src/configs/javascript.ts
|
|
660
669
|
async function javascript(options = {}) {
|
|
@@ -879,7 +888,6 @@ async function javascript(options = {}) {
|
|
|
879
888
|
}
|
|
880
889
|
}];
|
|
881
890
|
}
|
|
882
|
-
|
|
883
891
|
//#endregion
|
|
884
892
|
//#region src/configs/jsdoc.ts
|
|
885
893
|
async function jsdoc(options = {}) {
|
|
@@ -913,7 +921,6 @@ async function jsdoc(options = {}) {
|
|
|
913
921
|
}
|
|
914
922
|
}];
|
|
915
923
|
}
|
|
916
|
-
|
|
917
924
|
//#endregion
|
|
918
925
|
//#region src/configs/jsonc.ts
|
|
919
926
|
async function jsonc(options = {}) {
|
|
@@ -979,7 +986,6 @@ async function jsonc(options = {}) {
|
|
|
979
986
|
}
|
|
980
987
|
}];
|
|
981
988
|
}
|
|
982
|
-
|
|
983
989
|
//#endregion
|
|
984
990
|
//#region src/configs/jsx.ts
|
|
985
991
|
async function jsx(options = {}) {
|
|
@@ -1018,7 +1024,6 @@ async function jsx(options = {}) {
|
|
|
1018
1024
|
}
|
|
1019
1025
|
}];
|
|
1020
1026
|
}
|
|
1021
|
-
|
|
1022
1027
|
//#endregion
|
|
1023
1028
|
//#region src/configs/markdown.ts
|
|
1024
1029
|
async function markdown(options = {}) {
|
|
@@ -1098,7 +1103,6 @@ async function markdown(options = {}) {
|
|
|
1098
1103
|
}
|
|
1099
1104
|
];
|
|
1100
1105
|
}
|
|
1101
|
-
|
|
1102
1106
|
//#endregion
|
|
1103
1107
|
//#region src/configs/nextjs.ts
|
|
1104
1108
|
function normalizeRules(rules) {
|
|
@@ -1131,7 +1135,6 @@ async function nextjs(options = {}) {
|
|
|
1131
1135
|
settings: { react: { version: "detect" } }
|
|
1132
1136
|
}];
|
|
1133
1137
|
}
|
|
1134
|
-
|
|
1135
1138
|
//#endregion
|
|
1136
1139
|
//#region src/configs/node.ts
|
|
1137
1140
|
async function node() {
|
|
@@ -1153,7 +1156,6 @@ async function node() {
|
|
|
1153
1156
|
}
|
|
1154
1157
|
}];
|
|
1155
1158
|
}
|
|
1156
|
-
|
|
1157
1159
|
//#endregion
|
|
1158
1160
|
//#region src/configs/perfectionist.ts
|
|
1159
1161
|
/**
|
|
@@ -1213,13 +1215,12 @@ async function perfectionist() {
|
|
|
1213
1215
|
}
|
|
1214
1216
|
}];
|
|
1215
1217
|
}
|
|
1216
|
-
|
|
1217
1218
|
//#endregion
|
|
1218
1219
|
//#region src/configs/pnpm.ts
|
|
1219
1220
|
async function detectCatalogUsage() {
|
|
1220
1221
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1221
1222
|
if (!workspaceFile) return false;
|
|
1222
|
-
const yaml = await
|
|
1223
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1223
1224
|
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1224
1225
|
}
|
|
1225
1226
|
async function pnpm(options) {
|
|
@@ -1340,7 +1341,6 @@ async function pnpm(options) {
|
|
|
1340
1341
|
}
|
|
1341
1342
|
return configs;
|
|
1342
1343
|
}
|
|
1343
|
-
|
|
1344
1344
|
//#endregion
|
|
1345
1345
|
//#region src/configs/react.ts
|
|
1346
1346
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1357,24 +1357,12 @@ const ReactRouterPackages = [
|
|
|
1357
1357
|
"@react-router/dev"
|
|
1358
1358
|
];
|
|
1359
1359
|
const NextJsPackages = ["next"];
|
|
1360
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
1361
1360
|
async function react(options = {}) {
|
|
1362
|
-
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath
|
|
1363
|
-
await ensurePackages([
|
|
1364
|
-
"@eslint-react/eslint-plugin",
|
|
1365
|
-
"eslint-plugin-react-hooks",
|
|
1366
|
-
"eslint-plugin-react-refresh"
|
|
1367
|
-
]);
|
|
1361
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath } = options;
|
|
1362
|
+
await ensurePackages(["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"]);
|
|
1368
1363
|
const isTypeAware = !!tsconfigPath;
|
|
1369
|
-
const typeAwareRules = {
|
|
1370
|
-
|
|
1371
|
-
"react/no-implicit-key": "error"
|
|
1372
|
-
};
|
|
1373
|
-
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1374
|
-
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1375
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1376
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1377
|
-
]);
|
|
1364
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
|
|
1365
|
+
const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
|
|
1378
1366
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
1379
1367
|
const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
1380
1368
|
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
|
|
@@ -1385,13 +1373,7 @@ async function react(options = {}) {
|
|
|
1385
1373
|
name: "config/react/setup",
|
|
1386
1374
|
plugins: {
|
|
1387
1375
|
"react": plugins["@eslint-react"],
|
|
1388
|
-
"react-
|
|
1389
|
-
"react-hooks": pluginReactHooks,
|
|
1390
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1391
|
-
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1392
|
-
"react-refresh": pluginReactRefresh,
|
|
1393
|
-
"react-rsc": plugins["@eslint-react/rsc"],
|
|
1394
|
-
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1376
|
+
"react-refresh": pluginReactRefresh
|
|
1395
1377
|
}
|
|
1396
1378
|
},
|
|
1397
1379
|
{
|
|
@@ -1402,81 +1384,8 @@ async function react(options = {}) {
|
|
|
1402
1384
|
},
|
|
1403
1385
|
name: "config/react/rules",
|
|
1404
1386
|
rules: {
|
|
1405
|
-
|
|
1406
|
-
"react/jsx-uses-vars": "warn",
|
|
1407
|
-
"react/no-access-state-in-setstate": "error",
|
|
1408
|
-
"react/no-array-index-key": "warn",
|
|
1409
|
-
"react/no-children-count": "warn",
|
|
1410
|
-
"react/no-children-for-each": "warn",
|
|
1411
|
-
"react/no-children-map": "warn",
|
|
1412
|
-
"react/no-children-only": "warn",
|
|
1413
|
-
"react/no-children-to-array": "warn",
|
|
1414
|
-
"react/no-clone-element": "warn",
|
|
1415
|
-
"react/no-component-will-mount": "error",
|
|
1416
|
-
"react/no-component-will-receive-props": "error",
|
|
1417
|
-
"react/no-component-will-update": "error",
|
|
1418
|
-
"react/no-context-provider": "warn",
|
|
1419
|
-
"react/no-create-ref": "error",
|
|
1420
|
-
"react/no-default-props": "error",
|
|
1421
|
-
"react/no-direct-mutation-state": "error",
|
|
1422
|
-
"react/no-forward-ref": "warn",
|
|
1423
|
-
"react/no-missing-key": "error",
|
|
1424
|
-
"react/no-nested-component-definitions": "error",
|
|
1425
|
-
"react/no-nested-lazy-component-declarations": "error",
|
|
1426
|
-
"react/no-prop-types": "error",
|
|
1427
|
-
"react/no-redundant-should-component-update": "error",
|
|
1428
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1429
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1430
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1431
|
-
"react/no-unused-class-component-members": "warn",
|
|
1432
|
-
"react/no-string-refs": "error",
|
|
1433
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1434
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1435
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1436
|
-
"react/no-use-context": "warn",
|
|
1437
|
-
"react/no-useless-forward-ref": "warn",
|
|
1438
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1387
|
+
...pluginReact.configs.recommended.rules,
|
|
1439
1388
|
"react/prefer-namespace-import": "error",
|
|
1440
|
-
"react-rsc/function-definition": "error",
|
|
1441
|
-
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1442
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1443
|
-
"react-dom/no-find-dom-node": "error",
|
|
1444
|
-
"react-dom/no-flush-sync": "error",
|
|
1445
|
-
"react-dom/no-hydrate": "error",
|
|
1446
|
-
"react-dom/no-namespace": "error",
|
|
1447
|
-
"react-dom/no-render": "error",
|
|
1448
|
-
"react-dom/no-render-return-value": "error",
|
|
1449
|
-
"react-dom/no-script-url": "warn",
|
|
1450
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1451
|
-
"react-dom/no-use-form-state": "error",
|
|
1452
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1453
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1454
|
-
"react-naming-convention/context-name": "warn",
|
|
1455
|
-
"react-naming-convention/ref-name": "warn",
|
|
1456
|
-
"react-naming-convention/use-state": "warn",
|
|
1457
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1458
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1459
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1460
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1461
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1462
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1463
|
-
...reactCompiler ? {
|
|
1464
|
-
"react-hooks/config": "error",
|
|
1465
|
-
"react-hooks/error-boundaries": "error",
|
|
1466
|
-
"react-hooks/component-hook-factories": "error",
|
|
1467
|
-
"react-hooks/gating": "error",
|
|
1468
|
-
"react-hooks/globals": "error",
|
|
1469
|
-
"react-hooks/immutability": "error",
|
|
1470
|
-
"react-hooks/preserve-manual-memoization": "error",
|
|
1471
|
-
"react-hooks/purity": "error",
|
|
1472
|
-
"react-hooks/refs": "error",
|
|
1473
|
-
"react-hooks/set-state-in-effect": "error",
|
|
1474
|
-
"react-hooks/set-state-in-render": "error",
|
|
1475
|
-
"react-hooks/static-components": "error",
|
|
1476
|
-
"react-hooks/unsupported-syntax": "warn",
|
|
1477
|
-
"react-hooks/use-memo": "error",
|
|
1478
|
-
"react-hooks/incompatible-library": "warn"
|
|
1479
|
-
} : {},
|
|
1480
1389
|
"react-refresh/only-export-components": ["error", {
|
|
1481
1390
|
allowConstantExport: isAllowConstantExport,
|
|
1482
1391
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1513,10 +1422,7 @@ async function react(options = {}) {
|
|
|
1513
1422
|
rules: {
|
|
1514
1423
|
"react-dom/no-string-style-prop": "off",
|
|
1515
1424
|
"react-dom/no-unknown-property": "off",
|
|
1516
|
-
"react/jsx-no-duplicate-props": "off"
|
|
1517
|
-
"react/jsx-no-undef": "off",
|
|
1518
|
-
"react/jsx-uses-react": "off",
|
|
1519
|
-
"react/jsx-uses-vars": "off"
|
|
1425
|
+
"react/jsx-no-duplicate-props": "off"
|
|
1520
1426
|
}
|
|
1521
1427
|
},
|
|
1522
1428
|
...isTypeAware ? [{
|
|
@@ -1527,7 +1433,6 @@ async function react(options = {}) {
|
|
|
1527
1433
|
}] : []
|
|
1528
1434
|
];
|
|
1529
1435
|
}
|
|
1530
|
-
|
|
1531
1436
|
//#endregion
|
|
1532
1437
|
//#region src/configs/regexp.ts
|
|
1533
1438
|
async function regexp(options = {}) {
|
|
@@ -1545,7 +1450,6 @@ async function regexp(options = {}) {
|
|
|
1545
1450
|
}
|
|
1546
1451
|
}];
|
|
1547
1452
|
}
|
|
1548
|
-
|
|
1549
1453
|
//#endregion
|
|
1550
1454
|
//#region src/configs/solid.ts
|
|
1551
1455
|
async function solid(options = {}) {
|
|
@@ -1600,7 +1504,6 @@ async function solid(options = {}) {
|
|
|
1600
1504
|
}
|
|
1601
1505
|
}];
|
|
1602
1506
|
}
|
|
1603
|
-
|
|
1604
1507
|
//#endregion
|
|
1605
1508
|
//#region src/configs/sort.ts
|
|
1606
1509
|
/**
|
|
@@ -1834,7 +1737,6 @@ function sortTsconfig() {
|
|
|
1834
1737
|
] }
|
|
1835
1738
|
}];
|
|
1836
1739
|
}
|
|
1837
|
-
|
|
1838
1740
|
//#endregion
|
|
1839
1741
|
//#region src/configs/svelte.ts
|
|
1840
1742
|
async function svelte(options = {}) {
|
|
@@ -1910,7 +1812,6 @@ async function svelte(options = {}) {
|
|
|
1910
1812
|
}
|
|
1911
1813
|
}];
|
|
1912
1814
|
}
|
|
1913
|
-
|
|
1914
1815
|
//#endregion
|
|
1915
1816
|
//#region src/configs/tailwindcss.ts
|
|
1916
1817
|
const tailwindPackages = ["eslint-plugin-tailwindcss"];
|
|
@@ -1945,7 +1846,6 @@ async function tailwindcss(options = {}) {
|
|
|
1945
1846
|
}
|
|
1946
1847
|
}];
|
|
1947
1848
|
}
|
|
1948
|
-
|
|
1949
1849
|
//#endregion
|
|
1950
1850
|
//#region src/configs/test.ts
|
|
1951
1851
|
let _pluginTest;
|
|
@@ -1976,6 +1876,7 @@ async function test(options = {}) {
|
|
|
1976
1876
|
"test/prefer-hooks-in-order": "error",
|
|
1977
1877
|
"test/prefer-lowercase-title": "error",
|
|
1978
1878
|
"antfu/no-top-level-await": "off",
|
|
1879
|
+
"e18e/prefer-static-regex": "off",
|
|
1979
1880
|
"no-unused-expressions": "off",
|
|
1980
1881
|
"node/prefer-global/process": "off",
|
|
1981
1882
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1983,7 +1884,6 @@ async function test(options = {}) {
|
|
|
1983
1884
|
}
|
|
1984
1885
|
}];
|
|
1985
1886
|
}
|
|
1986
|
-
|
|
1987
1887
|
//#endregion
|
|
1988
1888
|
//#region src/configs/toml.ts
|
|
1989
1889
|
async function toml(options = {}) {
|
|
@@ -2024,18 +1924,17 @@ async function toml(options = {}) {
|
|
|
2024
1924
|
}
|
|
2025
1925
|
}];
|
|
2026
1926
|
}
|
|
2027
|
-
|
|
2028
1927
|
//#endregion
|
|
2029
1928
|
//#region src/configs/typescript.ts
|
|
2030
1929
|
async function typescript(options = {}) {
|
|
2031
1930
|
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
2032
1931
|
const files = options.files ?? [
|
|
2033
|
-
|
|
2034
|
-
|
|
1932
|
+
"**/*.?([cm])ts",
|
|
1933
|
+
"**/*.?([cm])tsx",
|
|
2035
1934
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
2036
1935
|
];
|
|
2037
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
2038
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1936
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
1937
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`, "**/*.astro/*.ts"];
|
|
2039
1938
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
2040
1939
|
const isTypeAware = !!tsconfigPath;
|
|
2041
1940
|
const typeAwareRules = {
|
|
@@ -2168,7 +2067,6 @@ async function typescript(options = {}) {
|
|
|
2168
2067
|
}] : []
|
|
2169
2068
|
];
|
|
2170
2069
|
}
|
|
2171
|
-
|
|
2172
2070
|
//#endregion
|
|
2173
2071
|
//#region src/configs/unicorn.ts
|
|
2174
2072
|
async function unicorn(options = {}) {
|
|
@@ -2198,7 +2096,6 @@ async function unicorn(options = {}) {
|
|
|
2198
2096
|
}
|
|
2199
2097
|
}];
|
|
2200
2098
|
}
|
|
2201
|
-
|
|
2202
2099
|
//#endregion
|
|
2203
2100
|
//#region src/configs/unocss.ts
|
|
2204
2101
|
async function unocss(options = {}) {
|
|
@@ -2215,7 +2112,6 @@ async function unocss(options = {}) {
|
|
|
2215
2112
|
}
|
|
2216
2113
|
}];
|
|
2217
2114
|
}
|
|
2218
|
-
|
|
2219
2115
|
//#endregion
|
|
2220
2116
|
//#region src/configs/vue.ts
|
|
2221
2117
|
async function vue(options = {}) {
|
|
@@ -2424,7 +2320,6 @@ async function vue(options = {}) {
|
|
|
2424
2320
|
}
|
|
2425
2321
|
}];
|
|
2426
2322
|
}
|
|
2427
|
-
|
|
2428
2323
|
//#endregion
|
|
2429
2324
|
//#region src/configs/yaml.ts
|
|
2430
2325
|
async function yaml(options = {}) {
|
|
@@ -2467,7 +2362,6 @@ async function yaml(options = {}) {
|
|
|
2467
2362
|
}
|
|
2468
2363
|
}];
|
|
2469
2364
|
}
|
|
2470
|
-
|
|
2471
2365
|
//#endregion
|
|
2472
2366
|
//#region src/factory.ts
|
|
2473
2367
|
const flatConfigProps = [
|
|
@@ -2488,8 +2382,9 @@ const VuePackages = [
|
|
|
2488
2382
|
const defaultPluginRenaming = {
|
|
2489
2383
|
"@eslint-react": "react",
|
|
2490
2384
|
"@eslint-react/dom": "react-dom",
|
|
2491
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2492
2385
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2386
|
+
"@eslint-react/rsc": "react-rsc",
|
|
2387
|
+
"@eslint-react/web-api": "react-web-api",
|
|
2493
2388
|
"@next/next": "next",
|
|
2494
2389
|
"@stylistic": "style",
|
|
2495
2390
|
"@typescript-eslint": "ts",
|
|
@@ -2508,7 +2403,7 @@ const defaultPluginRenaming = {
|
|
|
2508
2403
|
* The merged ESLint configurations.
|
|
2509
2404
|
*/
|
|
2510
2405
|
function eslintFlatConfig(options = {}, ...userConfigs) {
|
|
2511
|
-
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, svelte: enableSvelte = false, solid: enableSolid = false, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, tailwindcss: enableTailwindcss = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2406
|
+
const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = false, 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, svelte: enableSvelte = false, solid: enableSolid = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, tailwindcss: enableTailwindcss = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2512
2407
|
let isInEditor = options.isInEditor;
|
|
2513
2408
|
if (isInEditor == null) {
|
|
2514
2409
|
isInEditor = isInEditorEnv();
|
|
@@ -2537,6 +2432,10 @@ function eslintFlatConfig(options = {}, ...userConfigs) {
|
|
|
2537
2432
|
stylistic: stylisticOptions,
|
|
2538
2433
|
...resolveSubOptions(options, "imports")
|
|
2539
2434
|
}));
|
|
2435
|
+
if (enableE18e) configs.push(e18e({
|
|
2436
|
+
isInEditor,
|
|
2437
|
+
...enableE18e === true ? {} : enableE18e
|
|
2438
|
+
}));
|
|
2540
2439
|
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2541
2440
|
if (enableVue) componentExts.push("vue");
|
|
2542
2441
|
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
@@ -2544,7 +2443,7 @@ function eslintFlatConfig(options = {}, ...userConfigs) {
|
|
|
2544
2443
|
...typescriptOptions,
|
|
2545
2444
|
componentExts,
|
|
2546
2445
|
overrides: getOverrides(options, "typescript"),
|
|
2547
|
-
type:
|
|
2446
|
+
type: appType
|
|
2548
2447
|
}));
|
|
2549
2448
|
if (stylisticOptions) configs.push(stylistic({
|
|
2550
2449
|
...stylisticOptions,
|
|
@@ -2642,7 +2541,6 @@ function getOverrides(options, key) {
|
|
|
2642
2541
|
const sub = resolveSubOptions(options, key);
|
|
2643
2542
|
return { ..."overrides" in sub ? sub.overrides : {} };
|
|
2644
2543
|
}
|
|
2645
|
-
|
|
2646
2544
|
//#endregion
|
|
2647
2545
|
//#region src/config-presets.ts
|
|
2648
2546
|
const CONFIG_PRESET_FULL_ON = {
|
|
@@ -2658,7 +2556,7 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2658
2556
|
nextjs: true,
|
|
2659
2557
|
node: true,
|
|
2660
2558
|
pnpm: true,
|
|
2661
|
-
react:
|
|
2559
|
+
react: true,
|
|
2662
2560
|
regexp: true,
|
|
2663
2561
|
solid: true,
|
|
2664
2562
|
stylistic: { experimental: true },
|
|
@@ -2700,10 +2598,8 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2700
2598
|
vue: false,
|
|
2701
2599
|
yaml: false
|
|
2702
2600
|
};
|
|
2703
|
-
|
|
2704
2601
|
//#endregion
|
|
2705
2602
|
//#region src/index.ts
|
|
2706
2603
|
var src_default = eslintFlatConfig;
|
|
2707
|
-
|
|
2708
2604
|
//#endregion
|
|
2709
|
-
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, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, eslintFlatConfig, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pluginAntfu, pluginComments, pluginImportLite, pluginNode, pluginPerfectionist, pluginUnicorn, pluginUnusedImports, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
|
2605
|
+
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, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, e18e, ensurePackages, eslintFlatConfig, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pluginAntfu, pluginComments, pluginE18e, pluginImportLite, pluginNode, pluginPerfectionist, pluginUnicorn, pluginUnusedImports, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|