@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/index.js
CHANGED
|
@@ -41,7 +41,6 @@ async function comments() {
|
|
|
41
41
|
// src/constants/glob.ts
|
|
42
42
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
43
43
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
44
|
-
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
45
44
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
46
45
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
47
46
|
var GLOB_VUE = "**/*.vue";
|
|
@@ -1392,86 +1391,132 @@ async function perfectionist() {
|
|
|
1392
1391
|
// src/configs/react.ts
|
|
1393
1392
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1394
1393
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
1394
|
+
var RemixPackages = [
|
|
1395
|
+
"@remix-run/node",
|
|
1396
|
+
"@remix-run/react",
|
|
1397
|
+
"@remix-run/serve",
|
|
1398
|
+
"@remix-run/dev"
|
|
1399
|
+
];
|
|
1400
|
+
var NextJsPackages = ["next"];
|
|
1395
1401
|
async function react(options = {}) {
|
|
1396
|
-
const {
|
|
1397
|
-
files = [GLOB_JSX, GLOB_TSX],
|
|
1398
|
-
overrides = {},
|
|
1399
|
-
typescript: typescript2 = true
|
|
1400
|
-
} = options;
|
|
1402
|
+
const { files = [GLOB_TS, GLOB_TSX], overrides = {} } = options;
|
|
1401
1403
|
await ensurePackages([
|
|
1402
|
-
"eslint-plugin
|
|
1404
|
+
"@eslint-react/eslint-plugin",
|
|
1403
1405
|
"eslint-plugin-react-hooks",
|
|
1404
1406
|
"eslint-plugin-react-refresh"
|
|
1405
1407
|
]);
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1408
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1409
|
+
const isTypeAware = !!tsconfigPath;
|
|
1410
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
|
|
1411
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1412
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1413
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
1414
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1415
|
+
]);
|
|
1413
1416
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1414
1417
|
(i) => isPackageExists2(i)
|
|
1415
1418
|
);
|
|
1419
|
+
const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
|
|
1420
|
+
const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
|
|
1421
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
1416
1422
|
return [
|
|
1417
1423
|
{
|
|
1418
1424
|
name: "coderwyd/react/setup",
|
|
1419
1425
|
plugins: {
|
|
1420
|
-
react:
|
|
1426
|
+
react: plugins["@eslint-react"],
|
|
1427
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
1421
1428
|
"react-hooks": pluginReactHooks,
|
|
1429
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1430
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1422
1431
|
"react-refresh": pluginReactRefresh
|
|
1423
|
-
},
|
|
1424
|
-
settings: {
|
|
1425
|
-
react: {
|
|
1426
|
-
version: "detect"
|
|
1427
|
-
}
|
|
1428
1432
|
}
|
|
1429
1433
|
},
|
|
1430
1434
|
{
|
|
1431
1435
|
files,
|
|
1432
1436
|
languageOptions: {
|
|
1437
|
+
parser: parserTs,
|
|
1433
1438
|
parserOptions: {
|
|
1434
1439
|
ecmaFeatures: {
|
|
1435
1440
|
jsx: true
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1441
|
+
},
|
|
1442
|
+
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1443
|
+
},
|
|
1444
|
+
sourceType: "module"
|
|
1438
1445
|
},
|
|
1439
1446
|
name: "coderwyd/react/rules",
|
|
1440
1447
|
rules: {
|
|
1448
|
+
// recommended rules from @eslint-react/dom
|
|
1449
|
+
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
1450
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1451
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1452
|
+
"react-dom/no-find-dom-node": "error",
|
|
1453
|
+
"react-dom/no-missing-button-type": "warn",
|
|
1454
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
1455
|
+
"react-dom/no-namespace": "error",
|
|
1456
|
+
"react-dom/no-render-return-value": "error",
|
|
1457
|
+
"react-dom/no-script-url": "warn",
|
|
1458
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1459
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
1441
1460
|
// recommended rules react-hooks
|
|
1442
1461
|
"react-hooks/exhaustive-deps": "warn",
|
|
1443
1462
|
"react-hooks/rules-of-hooks": "error",
|
|
1444
1463
|
// react refresh
|
|
1445
1464
|
"react-refresh/only-export-components": [
|
|
1446
1465
|
"warn",
|
|
1447
|
-
{
|
|
1466
|
+
{
|
|
1467
|
+
allowConstantExport: isAllowConstantExport,
|
|
1468
|
+
allowExportNames: [
|
|
1469
|
+
...isUsingNext ? [
|
|
1470
|
+
"config",
|
|
1471
|
+
"generateStaticParams",
|
|
1472
|
+
"metadata",
|
|
1473
|
+
"generateMetadata",
|
|
1474
|
+
"viewport",
|
|
1475
|
+
"generateViewport"
|
|
1476
|
+
] : [],
|
|
1477
|
+
...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
|
|
1478
|
+
]
|
|
1479
|
+
}
|
|
1448
1480
|
],
|
|
1449
|
-
// recommended rules react
|
|
1450
|
-
"react/
|
|
1451
|
-
"react/
|
|
1452
|
-
"react/
|
|
1453
|
-
"react/
|
|
1454
|
-
"react/
|
|
1455
|
-
"react/
|
|
1456
|
-
"react/
|
|
1457
|
-
"react/
|
|
1458
|
-
"react/no-children-
|
|
1459
|
-
"react/no-
|
|
1460
|
-
"react/no-
|
|
1481
|
+
// recommended rules from @eslint-react
|
|
1482
|
+
"react/ensure-forward-ref-using-ref": "warn",
|
|
1483
|
+
"react/no-access-state-in-setstate": "error",
|
|
1484
|
+
"react/no-array-index-key": "warn",
|
|
1485
|
+
"react/no-children-count": "warn",
|
|
1486
|
+
"react/no-children-for-each": "warn",
|
|
1487
|
+
"react/no-children-map": "warn",
|
|
1488
|
+
"react/no-children-only": "warn",
|
|
1489
|
+
"react/no-children-prop": "warn",
|
|
1490
|
+
"react/no-children-to-array": "warn",
|
|
1491
|
+
"react/no-clone-element": "warn",
|
|
1492
|
+
"react/no-comment-textnodes": "warn",
|
|
1493
|
+
"react/no-component-will-mount": "error",
|
|
1494
|
+
"react/no-component-will-receive-props": "error",
|
|
1495
|
+
"react/no-component-will-update": "error",
|
|
1496
|
+
"react/no-create-ref": "error",
|
|
1461
1497
|
"react/no-direct-mutation-state": "error",
|
|
1462
|
-
"react/no-
|
|
1463
|
-
"react/no-
|
|
1464
|
-
"react/no-
|
|
1498
|
+
"react/no-duplicate-key": "error",
|
|
1499
|
+
"react/no-implicit-key": "error",
|
|
1500
|
+
"react/no-missing-key": "error",
|
|
1501
|
+
"react/no-nested-components": "warn",
|
|
1502
|
+
"react/no-redundant-should-component-update": "error",
|
|
1503
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
1504
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
1505
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
1465
1506
|
"react/no-string-refs": "error",
|
|
1466
|
-
"react/no-
|
|
1467
|
-
"react/no-
|
|
1468
|
-
"react/no-unsafe": "
|
|
1469
|
-
"react/
|
|
1470
|
-
"react/
|
|
1471
|
-
"react/
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1507
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
1508
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1509
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
1510
|
+
"react/no-unstable-context-value": "error",
|
|
1511
|
+
"react/no-unstable-default-props": "error",
|
|
1512
|
+
"react/no-unused-class-component-members": "warn",
|
|
1513
|
+
"react/no-unused-state": "warn",
|
|
1514
|
+
"react/no-useless-fragment": "warn",
|
|
1515
|
+
"react/prefer-destructuring-assignment": "warn",
|
|
1516
|
+
"react/prefer-shorthand-boolean": "warn",
|
|
1517
|
+
"react/prefer-shorthand-fragment": "warn",
|
|
1518
|
+
...isTypeAware ? {
|
|
1519
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1475
1520
|
} : {},
|
|
1476
1521
|
// overrides
|
|
1477
1522
|
...overrides
|
|
@@ -1858,7 +1903,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1858
1903
|
configs2.push(
|
|
1859
1904
|
react({
|
|
1860
1905
|
overrides: getOverrides(options, "react"),
|
|
1861
|
-
|
|
1906
|
+
tsconfigPath: getOverrides(options, "typescript").tsconfigPath
|
|
1862
1907
|
})
|
|
1863
1908
|
);
|
|
1864
1909
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.2",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"node": ">=18.18.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
+
"@eslint-react/eslint-plugin": "^1.5.8",
|
|
39
40
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
40
41
|
"eslint": "^8.56.0 || ^9.0.0",
|
|
41
|
-
"eslint-plugin-react": "^7.33.2",
|
|
42
42
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
43
43
|
"eslint-plugin-react-refresh": "^0.4.4",
|
|
44
44
|
"eslint-plugin-svelte": "^2.34.1",
|
|
45
45
|
"svelte-eslint-parser": "^0.33.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
|
-
"@
|
|
48
|
+
"@eslint-react/eslint-plugin": {
|
|
49
49
|
"optional": true
|
|
50
50
|
},
|
|
51
|
-
"eslint-plugin
|
|
51
|
+
"@unocss/eslint-plugin": {
|
|
52
52
|
"optional": true
|
|
53
53
|
},
|
|
54
54
|
"eslint-plugin-react-hooks": {
|
|
@@ -72,27 +72,27 @@
|
|
|
72
72
|
"eslint-config-flat-gitignore": "^0.1.5",
|
|
73
73
|
"eslint-config-prettier": "^9.1.0",
|
|
74
74
|
"eslint-plugin-antfu": "^2.2.0",
|
|
75
|
-
"eslint-plugin-command": "^0.2.
|
|
75
|
+
"eslint-plugin-command": "^0.2.3",
|
|
76
76
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
77
77
|
"eslint-plugin-import-x": "^0.5.0",
|
|
78
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
78
|
+
"eslint-plugin-jsdoc": "^48.2.5",
|
|
79
79
|
"eslint-plugin-jsonc": "^2.15.1",
|
|
80
|
-
"eslint-plugin-n": "^17.
|
|
80
|
+
"eslint-plugin-n": "^17.7.0",
|
|
81
81
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
82
82
|
"eslint-plugin-perfectionist": "^2.10.0",
|
|
83
83
|
"eslint-plugin-prettier": "^5.1.3",
|
|
84
84
|
"eslint-plugin-regexp": "^2.5.0",
|
|
85
|
-
"eslint-plugin-tailwindcss": "^3.15.
|
|
85
|
+
"eslint-plugin-tailwindcss": "^3.15.2",
|
|
86
86
|
"eslint-plugin-unicorn": "^53.0.0",
|
|
87
87
|
"eslint-plugin-unused-imports": "^3.2.0",
|
|
88
88
|
"eslint-plugin-vitest": "^0.5.4",
|
|
89
89
|
"eslint-plugin-vue": "^9.26.0",
|
|
90
90
|
"eslint-typegen": "^0.2.4",
|
|
91
|
-
"globals": "^15.
|
|
91
|
+
"globals": "^15.3.0",
|
|
92
92
|
"jsonc-eslint-parser": "^2.4.0",
|
|
93
93
|
"local-pkg": "^0.5.0",
|
|
94
94
|
"parse-gitignore": "^2.0.0",
|
|
95
|
-
"picocolors": "^1.0.
|
|
95
|
+
"picocolors": "^1.0.1",
|
|
96
96
|
"prettier": "^3.2.5",
|
|
97
97
|
"prettier-plugin-toml": "^2.0.1",
|
|
98
98
|
"prompts": "^2.4.2",
|
|
@@ -101,15 +101,16 @@
|
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@antfu/ni": "^0.21.12",
|
|
104
|
+
"@eslint-react/eslint-plugin": "^1.5.12",
|
|
104
105
|
"@eslint/config-inspector": "^0.4.8",
|
|
105
106
|
"@types/eslint": "^8.56.10",
|
|
106
107
|
"@types/fs-extra": "^11.0.4",
|
|
107
|
-
"@types/node": "^20.12.
|
|
108
|
+
"@types/node": "^20.12.12",
|
|
108
109
|
"@types/prompts": "^2.4.9",
|
|
109
110
|
"@types/yargs": "^17.0.32",
|
|
110
111
|
"@unocss/eslint-plugin": "^0.60.2",
|
|
111
112
|
"bumpp": "^9.4.1",
|
|
112
|
-
"eslint": "9.
|
|
113
|
+
"eslint": "^9.3.0",
|
|
113
114
|
"eslint-plugin-react": "^7.34.1",
|
|
114
115
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
115
116
|
"eslint-plugin-react-refresh": "^0.4.7",
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
"svelte": "^4.2.17",
|
|
124
125
|
"svelte-eslint-parser": "^0.36.0",
|
|
125
126
|
"tsup": "^8.0.2",
|
|
126
|
-
"tsx": "^4.10.
|
|
127
|
+
"tsx": "^4.10.5",
|
|
127
128
|
"typescript": "^5.4.5"
|
|
128
129
|
},
|
|
129
130
|
"simple-git-hooks": {
|