@coderwyd/eslint-config 2.4.1 → 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 +5 -4
- package/dist/cli.js +5 -4
- package/dist/index.cjs +93 -48
- package/dist/index.d.cts +222 -828
- package/dist/index.d.ts +222 -828
- package/dist/index.js +93 -48
- package/package.json +14 -13
package/dist/cli.cjs
CHANGED
|
@@ -46,18 +46,19 @@ 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
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",
|
|
@@ -71,7 +72,7 @@ var devDependencies = {
|
|
|
71
72
|
svelte: "^4.2.17",
|
|
72
73
|
"svelte-eslint-parser": "^0.36.0",
|
|
73
74
|
tsup: "^8.0.2",
|
|
74
|
-
tsx: "^4.10.
|
|
75
|
+
tsx: "^4.10.5",
|
|
75
76
|
typescript: "^5.4.5"
|
|
76
77
|
};
|
|
77
78
|
|
package/dist/cli.js
CHANGED
|
@@ -17,18 +17,19 @@ 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
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",
|
|
@@ -42,7 +43,7 @@ var devDependencies = {
|
|
|
42
43
|
svelte: "^4.2.17",
|
|
43
44
|
"svelte-eslint-parser": "^0.36.0",
|
|
44
45
|
tsup: "^8.0.2",
|
|
45
|
-
tsx: "^4.10.
|
|
46
|
+
tsx: "^4.10.5",
|
|
46
47
|
typescript: "^5.4.5"
|
|
47
48
|
};
|
|
48
49
|
|
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";
|
|
@@ -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
|
|
@@ -1904,7 +1949,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1904
1949
|
configs2.push(
|
|
1905
1950
|
react({
|
|
1906
1951
|
overrides: getOverrides(options, "react"),
|
|
1907
|
-
|
|
1952
|
+
tsconfigPath: getOverrides(options, "typescript").tsconfigPath
|
|
1908
1953
|
})
|
|
1909
1954
|
);
|
|
1910
1955
|
}
|