@coderwyd/eslint-config 2.4.0 → 2.4.2
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/cli.cjs +11 -10
- package/dist/cli.js +11 -10
- package/dist/index.cjs +153 -80
- package/dist/index.d.cts +831 -860
- package/dist/index.d.ts +831 -860
- package/dist/index.js +153 -80
- package/package.json +25 -23
package/dist/cli.cjs
CHANGED
|
@@ -46,32 +46,33 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.4.
|
|
49
|
+
var version = "2.4.2";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/ni": "^0.21.12",
|
|
52
|
+
"@eslint-react/eslint-plugin": "^1.5.12",
|
|
52
53
|
"@eslint/config-inspector": "^0.4.8",
|
|
53
54
|
"@types/eslint": "^8.56.10",
|
|
54
55
|
"@types/fs-extra": "^11.0.4",
|
|
55
|
-
"@types/node": "^20.12.
|
|
56
|
+
"@types/node": "^20.12.12",
|
|
56
57
|
"@types/prompts": "^2.4.9",
|
|
57
58
|
"@types/yargs": "^17.0.32",
|
|
58
|
-
"@unocss/eslint-plugin": "^0.60.
|
|
59
|
+
"@unocss/eslint-plugin": "^0.60.2",
|
|
59
60
|
bumpp: "^9.4.1",
|
|
60
|
-
eslint: "9.
|
|
61
|
+
eslint: "^9.3.0",
|
|
61
62
|
"eslint-plugin-react": "^7.34.1",
|
|
62
63
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
63
64
|
"eslint-plugin-react-refresh": "^0.4.7",
|
|
64
|
-
"eslint-plugin-svelte": "2.
|
|
65
|
-
execa: "^9.0
|
|
65
|
+
"eslint-plugin-svelte": "2.39.0",
|
|
66
|
+
execa: "^9.1.0",
|
|
66
67
|
"fast-glob": "^3.3.2",
|
|
67
68
|
"fs-extra": "^11.2.0",
|
|
68
69
|
"lint-staged": "^15.2.2",
|
|
69
|
-
rimraf: "^5.0.
|
|
70
|
+
rimraf: "^5.0.7",
|
|
70
71
|
"simple-git-hooks": "^2.11.1",
|
|
71
|
-
svelte: "^4.2.
|
|
72
|
+
svelte: "^4.2.17",
|
|
72
73
|
"svelte-eslint-parser": "^0.36.0",
|
|
73
74
|
tsup: "^8.0.2",
|
|
74
|
-
tsx: "^4.
|
|
75
|
+
tsx: "^4.10.5",
|
|
75
76
|
typescript: "^5.4.5"
|
|
76
77
|
};
|
|
77
78
|
|
|
@@ -239,7 +240,7 @@ ${coderwydConfig}
|
|
|
239
240
|
console.log(import_picocolors2.default.green(`${CHECK} created .vscode/settings.json`));
|
|
240
241
|
} else {
|
|
241
242
|
let settingsContent = await import_promises.default.readFile(settingsPath, "utf8");
|
|
242
|
-
settingsContent = settingsContent.trim().replace(/\s
|
|
243
|
+
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
243
244
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
244
245
|
settingsContent += `${vscodeSettingsString}}
|
|
245
246
|
`;
|
package/dist/cli.js
CHANGED
|
@@ -17,32 +17,33 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.4.
|
|
20
|
+
var version = "2.4.2";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/ni": "^0.21.12",
|
|
23
|
+
"@eslint-react/eslint-plugin": "^1.5.12",
|
|
23
24
|
"@eslint/config-inspector": "^0.4.8",
|
|
24
25
|
"@types/eslint": "^8.56.10",
|
|
25
26
|
"@types/fs-extra": "^11.0.4",
|
|
26
|
-
"@types/node": "^20.12.
|
|
27
|
+
"@types/node": "^20.12.12",
|
|
27
28
|
"@types/prompts": "^2.4.9",
|
|
28
29
|
"@types/yargs": "^17.0.32",
|
|
29
|
-
"@unocss/eslint-plugin": "^0.60.
|
|
30
|
+
"@unocss/eslint-plugin": "^0.60.2",
|
|
30
31
|
bumpp: "^9.4.1",
|
|
31
|
-
eslint: "9.
|
|
32
|
+
eslint: "^9.3.0",
|
|
32
33
|
"eslint-plugin-react": "^7.34.1",
|
|
33
34
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
34
35
|
"eslint-plugin-react-refresh": "^0.4.7",
|
|
35
|
-
"eslint-plugin-svelte": "2.
|
|
36
|
-
execa: "^9.0
|
|
36
|
+
"eslint-plugin-svelte": "2.39.0",
|
|
37
|
+
execa: "^9.1.0",
|
|
37
38
|
"fast-glob": "^3.3.2",
|
|
38
39
|
"fs-extra": "^11.2.0",
|
|
39
40
|
"lint-staged": "^15.2.2",
|
|
40
|
-
rimraf: "^5.0.
|
|
41
|
+
rimraf: "^5.0.7",
|
|
41
42
|
"simple-git-hooks": "^2.11.1",
|
|
42
|
-
svelte: "^4.2.
|
|
43
|
+
svelte: "^4.2.17",
|
|
43
44
|
"svelte-eslint-parser": "^0.36.0",
|
|
44
45
|
tsup: "^8.0.2",
|
|
45
|
-
tsx: "^4.
|
|
46
|
+
tsx: "^4.10.5",
|
|
46
47
|
typescript: "^5.4.5"
|
|
47
48
|
};
|
|
48
49
|
|
|
@@ -210,7 +211,7 @@ ${coderwydConfig}
|
|
|
210
211
|
console.log(c2.green(`${CHECK} created .vscode/settings.json`));
|
|
211
212
|
} else {
|
|
212
213
|
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
213
|
-
settingsContent = settingsContent.trim().replace(/\s
|
|
214
|
+
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
214
215
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
215
216
|
settingsContent += `${vscodeSettingsString}}
|
|
216
217
|
`;
|
package/dist/index.cjs
CHANGED
|
@@ -87,7 +87,6 @@ async function comments() {
|
|
|
87
87
|
// src/constants/glob.ts
|
|
88
88
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
89
89
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
90
|
-
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
91
90
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
92
91
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
93
92
|
var GLOB_VUE = "**/*.vue";
|
|
@@ -495,8 +494,8 @@ var parserPlain = {
|
|
|
495
494
|
}
|
|
496
495
|
})
|
|
497
496
|
};
|
|
498
|
-
async function combine(...
|
|
499
|
-
const resolved = await Promise.all(
|
|
497
|
+
async function combine(...configs2) {
|
|
498
|
+
const resolved = await Promise.all(configs2);
|
|
500
499
|
return resolved.flat();
|
|
501
500
|
}
|
|
502
501
|
function renameRules(rules, map) {
|
|
@@ -510,8 +509,8 @@ function renameRules(rules, map) {
|
|
|
510
509
|
})
|
|
511
510
|
);
|
|
512
511
|
}
|
|
513
|
-
function renamePluginInConfigs(
|
|
514
|
-
return
|
|
512
|
+
function renamePluginInConfigs(configs2, map) {
|
|
513
|
+
return configs2.map((i) => {
|
|
515
514
|
const clone = { ...i };
|
|
516
515
|
if (clone.rules)
|
|
517
516
|
clone.rules = renameRules(clone.rules, map);
|
|
@@ -940,7 +939,7 @@ async function prettier(rules = {}) {
|
|
|
940
939
|
const pRules = {
|
|
941
940
|
...rules
|
|
942
941
|
};
|
|
943
|
-
const
|
|
942
|
+
const configs2 = [
|
|
944
943
|
{
|
|
945
944
|
name: "coderwyd/prettier/setup",
|
|
946
945
|
plugins: {
|
|
@@ -959,7 +958,7 @@ async function prettier(rules = {}) {
|
|
|
959
958
|
}
|
|
960
959
|
}
|
|
961
960
|
];
|
|
962
|
-
return
|
|
961
|
+
return configs2;
|
|
963
962
|
}
|
|
964
963
|
|
|
965
964
|
// src/configs/typescript.ts
|
|
@@ -1128,7 +1127,7 @@ async function unicorn() {
|
|
|
1128
1127
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1129
1128
|
},
|
|
1130
1129
|
rules: {
|
|
1131
|
-
|
|
1130
|
+
// 'unicorn/better-regex': 'error',
|
|
1132
1131
|
"unicorn/catch-error-name": "error",
|
|
1133
1132
|
"unicorn/custom-error-definition": "error",
|
|
1134
1133
|
"unicorn/error-message": "error",
|
|
@@ -1182,7 +1181,7 @@ async function unicorn() {
|
|
|
1182
1181
|
"unicorn/prefer-prototype-methods": "error",
|
|
1183
1182
|
"unicorn/prefer-query-selector": "error",
|
|
1184
1183
|
"unicorn/prefer-reflect-apply": "error",
|
|
1185
|
-
|
|
1184
|
+
// 'unicorn/prefer-regexp-test': 'error',
|
|
1186
1185
|
"unicorn/prefer-string-replace-all": "error",
|
|
1187
1186
|
"unicorn/prefer-string-slice": "error",
|
|
1188
1187
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
@@ -1438,86 +1437,132 @@ async function perfectionist() {
|
|
|
1438
1437
|
// src/configs/react.ts
|
|
1439
1438
|
var import_local_pkg2 = require("local-pkg");
|
|
1440
1439
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
1440
|
+
var RemixPackages = [
|
|
1441
|
+
"@remix-run/node",
|
|
1442
|
+
"@remix-run/react",
|
|
1443
|
+
"@remix-run/serve",
|
|
1444
|
+
"@remix-run/dev"
|
|
1445
|
+
];
|
|
1446
|
+
var NextJsPackages = ["next"];
|
|
1441
1447
|
async function react(options = {}) {
|
|
1442
|
-
const {
|
|
1443
|
-
files = [GLOB_JSX, GLOB_TSX],
|
|
1444
|
-
overrides = {},
|
|
1445
|
-
typescript: typescript2 = true
|
|
1446
|
-
} = options;
|
|
1448
|
+
const { files = [GLOB_TS, GLOB_TSX], overrides = {} } = options;
|
|
1447
1449
|
await ensurePackages([
|
|
1448
|
-
"eslint-plugin
|
|
1450
|
+
"@eslint-react/eslint-plugin",
|
|
1449
1451
|
"eslint-plugin-react-hooks",
|
|
1450
1452
|
"eslint-plugin-react-refresh"
|
|
1451
1453
|
]);
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1454
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1455
|
+
const isTypeAware = !!tsconfigPath;
|
|
1456
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
|
|
1457
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1458
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1459
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
1460
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1461
|
+
]);
|
|
1459
1462
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1460
1463
|
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
1461
1464
|
);
|
|
1465
|
+
const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
1466
|
+
const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
1467
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
1462
1468
|
return [
|
|
1463
1469
|
{
|
|
1464
1470
|
name: "coderwyd/react/setup",
|
|
1465
1471
|
plugins: {
|
|
1466
|
-
react:
|
|
1472
|
+
react: plugins["@eslint-react"],
|
|
1473
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
1467
1474
|
"react-hooks": pluginReactHooks,
|
|
1475
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1476
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1468
1477
|
"react-refresh": pluginReactRefresh
|
|
1469
|
-
},
|
|
1470
|
-
settings: {
|
|
1471
|
-
react: {
|
|
1472
|
-
version: "detect"
|
|
1473
|
-
}
|
|
1474
1478
|
}
|
|
1475
1479
|
},
|
|
1476
1480
|
{
|
|
1477
1481
|
files,
|
|
1478
1482
|
languageOptions: {
|
|
1483
|
+
parser: parserTs,
|
|
1479
1484
|
parserOptions: {
|
|
1480
1485
|
ecmaFeatures: {
|
|
1481
1486
|
jsx: true
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1487
|
+
},
|
|
1488
|
+
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1489
|
+
},
|
|
1490
|
+
sourceType: "module"
|
|
1484
1491
|
},
|
|
1485
1492
|
name: "coderwyd/react/rules",
|
|
1486
1493
|
rules: {
|
|
1494
|
+
// recommended rules from @eslint-react/dom
|
|
1495
|
+
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
1496
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1497
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1498
|
+
"react-dom/no-find-dom-node": "error",
|
|
1499
|
+
"react-dom/no-missing-button-type": "warn",
|
|
1500
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
1501
|
+
"react-dom/no-namespace": "error",
|
|
1502
|
+
"react-dom/no-render-return-value": "error",
|
|
1503
|
+
"react-dom/no-script-url": "warn",
|
|
1504
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1505
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
1487
1506
|
// recommended rules react-hooks
|
|
1488
1507
|
"react-hooks/exhaustive-deps": "warn",
|
|
1489
1508
|
"react-hooks/rules-of-hooks": "error",
|
|
1490
1509
|
// react refresh
|
|
1491
1510
|
"react-refresh/only-export-components": [
|
|
1492
1511
|
"warn",
|
|
1493
|
-
{
|
|
1512
|
+
{
|
|
1513
|
+
allowConstantExport: isAllowConstantExport,
|
|
1514
|
+
allowExportNames: [
|
|
1515
|
+
...isUsingNext ? [
|
|
1516
|
+
"config",
|
|
1517
|
+
"generateStaticParams",
|
|
1518
|
+
"metadata",
|
|
1519
|
+
"generateMetadata",
|
|
1520
|
+
"viewport",
|
|
1521
|
+
"generateViewport"
|
|
1522
|
+
] : [],
|
|
1523
|
+
...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
|
|
1524
|
+
]
|
|
1525
|
+
}
|
|
1494
1526
|
],
|
|
1495
|
-
// recommended rules react
|
|
1496
|
-
"react/
|
|
1497
|
-
"react/
|
|
1498
|
-
"react/
|
|
1499
|
-
"react/
|
|
1500
|
-
"react/
|
|
1501
|
-
"react/
|
|
1502
|
-
"react/
|
|
1503
|
-
"react/
|
|
1504
|
-
"react/no-children-
|
|
1505
|
-
"react/no-
|
|
1506
|
-
"react/no-
|
|
1527
|
+
// recommended rules from @eslint-react
|
|
1528
|
+
"react/ensure-forward-ref-using-ref": "warn",
|
|
1529
|
+
"react/no-access-state-in-setstate": "error",
|
|
1530
|
+
"react/no-array-index-key": "warn",
|
|
1531
|
+
"react/no-children-count": "warn",
|
|
1532
|
+
"react/no-children-for-each": "warn",
|
|
1533
|
+
"react/no-children-map": "warn",
|
|
1534
|
+
"react/no-children-only": "warn",
|
|
1535
|
+
"react/no-children-prop": "warn",
|
|
1536
|
+
"react/no-children-to-array": "warn",
|
|
1537
|
+
"react/no-clone-element": "warn",
|
|
1538
|
+
"react/no-comment-textnodes": "warn",
|
|
1539
|
+
"react/no-component-will-mount": "error",
|
|
1540
|
+
"react/no-component-will-receive-props": "error",
|
|
1541
|
+
"react/no-component-will-update": "error",
|
|
1542
|
+
"react/no-create-ref": "error",
|
|
1507
1543
|
"react/no-direct-mutation-state": "error",
|
|
1508
|
-
"react/no-
|
|
1509
|
-
"react/no-
|
|
1510
|
-
"react/no-
|
|
1544
|
+
"react/no-duplicate-key": "error",
|
|
1545
|
+
"react/no-implicit-key": "error",
|
|
1546
|
+
"react/no-missing-key": "error",
|
|
1547
|
+
"react/no-nested-components": "warn",
|
|
1548
|
+
"react/no-redundant-should-component-update": "error",
|
|
1549
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
1550
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
1551
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
1511
1552
|
"react/no-string-refs": "error",
|
|
1512
|
-
"react/no-
|
|
1513
|
-
"react/no-
|
|
1514
|
-
"react/no-unsafe": "
|
|
1515
|
-
"react/
|
|
1516
|
-
"react/
|
|
1517
|
-
"react/
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1553
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
1554
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1555
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
1556
|
+
"react/no-unstable-context-value": "error",
|
|
1557
|
+
"react/no-unstable-default-props": "error",
|
|
1558
|
+
"react/no-unused-class-component-members": "warn",
|
|
1559
|
+
"react/no-unused-state": "warn",
|
|
1560
|
+
"react/no-useless-fragment": "warn",
|
|
1561
|
+
"react/prefer-destructuring-assignment": "warn",
|
|
1562
|
+
"react/prefer-shorthand-boolean": "warn",
|
|
1563
|
+
"react/prefer-shorthand-fragment": "warn",
|
|
1564
|
+
...isTypeAware ? {
|
|
1565
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1521
1566
|
} : {},
|
|
1522
1567
|
// overrides
|
|
1523
1568
|
...overrides
|
|
@@ -1594,7 +1639,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1594
1639
|
};
|
|
1595
1640
|
return config;
|
|
1596
1641
|
}
|
|
1597
|
-
const
|
|
1642
|
+
const configs2 = [
|
|
1598
1643
|
{
|
|
1599
1644
|
name: "coderwyd/formatter/setup",
|
|
1600
1645
|
plugins: {
|
|
@@ -1604,34 +1649,34 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1604
1649
|
];
|
|
1605
1650
|
if (html) {
|
|
1606
1651
|
const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
|
|
1607
|
-
|
|
1652
|
+
configs2.push(htmlConfig);
|
|
1608
1653
|
}
|
|
1609
1654
|
if (css) {
|
|
1610
1655
|
const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
|
|
1611
1656
|
const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
|
|
1612
1657
|
const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
|
|
1613
|
-
|
|
1658
|
+
configs2.push(cssConfig, scssConfig, lessConfig);
|
|
1614
1659
|
}
|
|
1615
1660
|
if (markdown) {
|
|
1616
1661
|
const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
|
|
1617
|
-
|
|
1662
|
+
configs2.push(markdownConfig);
|
|
1618
1663
|
}
|
|
1619
1664
|
if (graphql) {
|
|
1620
1665
|
const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
|
|
1621
|
-
|
|
1666
|
+
configs2.push(graphqlConfig);
|
|
1622
1667
|
}
|
|
1623
1668
|
if (yaml) {
|
|
1624
1669
|
const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
|
|
1625
|
-
|
|
1670
|
+
configs2.push(yamlConfig);
|
|
1626
1671
|
}
|
|
1627
1672
|
if (toml) {
|
|
1628
1673
|
await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
|
|
1629
1674
|
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
|
|
1630
1675
|
"prettier-plugin-toml"
|
|
1631
1676
|
]);
|
|
1632
|
-
|
|
1677
|
+
configs2.push(tomlConfig);
|
|
1633
1678
|
}
|
|
1634
|
-
return
|
|
1679
|
+
return configs2;
|
|
1635
1680
|
}
|
|
1636
1681
|
|
|
1637
1682
|
// src/configs/svelte.ts
|
|
@@ -1766,6 +1811,31 @@ async function command() {
|
|
|
1766
1811
|
];
|
|
1767
1812
|
}
|
|
1768
1813
|
|
|
1814
|
+
// src/configs/regexp.ts
|
|
1815
|
+
var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
1816
|
+
async function regexp(options = {}) {
|
|
1817
|
+
const config = import_eslint_plugin_regexp.configs["flat/recommended"];
|
|
1818
|
+
const rules = {
|
|
1819
|
+
...config.rules
|
|
1820
|
+
};
|
|
1821
|
+
if (options.level === "warn") {
|
|
1822
|
+
Object.keys(rules).forEach((key) => {
|
|
1823
|
+
if (rules[key] === "error")
|
|
1824
|
+
rules[key] = "warn";
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
return [
|
|
1828
|
+
{
|
|
1829
|
+
...config,
|
|
1830
|
+
name: "coderwyd/regexp/rules",
|
|
1831
|
+
rules: {
|
|
1832
|
+
...rules,
|
|
1833
|
+
...options.overrides
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
];
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1769
1839
|
// src/env.ts
|
|
1770
1840
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
1771
1841
|
var import_local_pkg3 = require("local-pkg");
|
|
@@ -1805,6 +1875,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1805
1875
|
gitignore: enableGitignore = true,
|
|
1806
1876
|
isInEditor: isInEditor2 = isInEditor,
|
|
1807
1877
|
react: enableReact = false,
|
|
1878
|
+
regexp: enableRegexp = true,
|
|
1808
1879
|
svelte: enableSvelte = false,
|
|
1809
1880
|
tailwindcss: enableTailwindCSS = hasTailwindCSS,
|
|
1810
1881
|
typescript: enableTypeScript = hasTypeScript,
|
|
@@ -1812,24 +1883,24 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1812
1883
|
usePrettierrc = true,
|
|
1813
1884
|
vue: enableVue = hasVue
|
|
1814
1885
|
} = options;
|
|
1815
|
-
const
|
|
1886
|
+
const configs2 = [];
|
|
1816
1887
|
if (enableGitignore) {
|
|
1817
1888
|
if (typeof enableGitignore !== "boolean") {
|
|
1818
|
-
|
|
1889
|
+
configs2.push(
|
|
1819
1890
|
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
1820
1891
|
r(enableGitignore)
|
|
1821
1892
|
])
|
|
1822
1893
|
);
|
|
1823
1894
|
} else {
|
|
1824
1895
|
if (import_node_fs.default.existsSync(".gitignore"))
|
|
1825
|
-
|
|
1896
|
+
configs2.push(
|
|
1826
1897
|
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
1827
1898
|
r()
|
|
1828
1899
|
])
|
|
1829
1900
|
);
|
|
1830
1901
|
}
|
|
1831
1902
|
}
|
|
1832
|
-
|
|
1903
|
+
configs2.push(
|
|
1833
1904
|
ignores(),
|
|
1834
1905
|
javascript({
|
|
1835
1906
|
isInEditor: isInEditor2,
|
|
@@ -1847,7 +1918,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1847
1918
|
if (enableVue)
|
|
1848
1919
|
componentExts.push("vue");
|
|
1849
1920
|
if (enableTypeScript) {
|
|
1850
|
-
|
|
1921
|
+
configs2.push(
|
|
1851
1922
|
typescript({
|
|
1852
1923
|
...resolveSubOptions(options, "typescript"),
|
|
1853
1924
|
componentExts,
|
|
@@ -1855,8 +1926,10 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1855
1926
|
})
|
|
1856
1927
|
);
|
|
1857
1928
|
}
|
|
1929
|
+
if (enableRegexp)
|
|
1930
|
+
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1858
1931
|
if (options.test ?? true) {
|
|
1859
|
-
|
|
1932
|
+
configs2.push(
|
|
1860
1933
|
test({
|
|
1861
1934
|
isInEditor: isInEditor2,
|
|
1862
1935
|
overrides: getOverrides(options, "test")
|
|
@@ -1864,7 +1937,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1864
1937
|
);
|
|
1865
1938
|
}
|
|
1866
1939
|
if (enableVue) {
|
|
1867
|
-
|
|
1940
|
+
configs2.push(
|
|
1868
1941
|
vue({
|
|
1869
1942
|
...resolveSubOptions(options, "vue"),
|
|
1870
1943
|
overrides: getOverrides(options, "typescript"),
|
|
@@ -1873,15 +1946,15 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1873
1946
|
);
|
|
1874
1947
|
}
|
|
1875
1948
|
if (enableReact) {
|
|
1876
|
-
|
|
1949
|
+
configs2.push(
|
|
1877
1950
|
react({
|
|
1878
1951
|
overrides: getOverrides(options, "react"),
|
|
1879
|
-
|
|
1952
|
+
tsconfigPath: getOverrides(options, "typescript").tsconfigPath
|
|
1880
1953
|
})
|
|
1881
1954
|
);
|
|
1882
1955
|
}
|
|
1883
1956
|
if (enableSvelte) {
|
|
1884
|
-
|
|
1957
|
+
configs2.push(
|
|
1885
1958
|
svelte({
|
|
1886
1959
|
overrides: getOverrides(options, "svelte"),
|
|
1887
1960
|
typescript: !!enableTypeScript
|
|
@@ -1889,7 +1962,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1889
1962
|
);
|
|
1890
1963
|
}
|
|
1891
1964
|
if (enableUnoCSS) {
|
|
1892
|
-
|
|
1965
|
+
configs2.push(
|
|
1893
1966
|
unocss({
|
|
1894
1967
|
...resolveSubOptions(options, "unocss"),
|
|
1895
1968
|
overrides: getOverrides(options, "unocss")
|
|
@@ -1897,7 +1970,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1897
1970
|
);
|
|
1898
1971
|
}
|
|
1899
1972
|
if (enableTailwindCSS) {
|
|
1900
|
-
|
|
1973
|
+
configs2.push(
|
|
1901
1974
|
tailwindcss({
|
|
1902
1975
|
...resolveSubOptions(options, "tailwindcss"),
|
|
1903
1976
|
overrides: getOverrides(options, "tailwindcss")
|
|
@@ -1905,7 +1978,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1905
1978
|
);
|
|
1906
1979
|
}
|
|
1907
1980
|
if (options.jsonc ?? true) {
|
|
1908
|
-
|
|
1981
|
+
configs2.push(
|
|
1909
1982
|
jsonc({
|
|
1910
1983
|
overrides: getOverrides(options, "jsonc")
|
|
1911
1984
|
}),
|
|
@@ -1926,12 +1999,12 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1926
1999
|
);
|
|
1927
2000
|
Object.assign(prettierRules2, prettierConfig);
|
|
1928
2001
|
}
|
|
1929
|
-
|
|
2002
|
+
configs2.push(
|
|
1930
2003
|
prettier(prettierRules2),
|
|
1931
2004
|
formatter(formatterOptions, prettierRules2)
|
|
1932
2005
|
);
|
|
1933
2006
|
} else {
|
|
1934
|
-
|
|
2007
|
+
configs2.push(prettier());
|
|
1935
2008
|
}
|
|
1936
2009
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1937
2010
|
if (key in options)
|
|
@@ -1939,8 +2012,8 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1939
2012
|
return acc;
|
|
1940
2013
|
}, {});
|
|
1941
2014
|
if (Object.keys(fusedConfig).length > 0)
|
|
1942
|
-
|
|
1943
|
-
const merged = await combine(...
|
|
2015
|
+
configs2.push([fusedConfig]);
|
|
2016
|
+
const merged = await combine(...configs2, ...userConfigs);
|
|
1944
2017
|
if (autoRenamePlugins)
|
|
1945
2018
|
return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
1946
2019
|
return merged;
|