@antfu/eslint-config 7.7.2 → 8.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/README.md +1 -1
- package/dist/cli.mjs +8 -13
- package/dist/index.d.mts +410 -490
- package/dist/index.mjs +14 -104
- package/dist/{lib-D3Kr7UIJ.mjs → lib-EoktVv6C.mjs} +2793 -2278
- package/package.json +44 -49
package/dist/index.mjs
CHANGED
|
@@ -1360,24 +1360,12 @@ const ReactRouterPackages = [
|
|
|
1360
1360
|
"@react-router/dev"
|
|
1361
1361
|
];
|
|
1362
1362
|
const NextJsPackages = ["next"];
|
|
1363
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
1364
1363
|
async function react(options = {}) {
|
|
1365
|
-
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath
|
|
1366
|
-
await ensurePackages([
|
|
1367
|
-
"@eslint-react/eslint-plugin",
|
|
1368
|
-
"eslint-plugin-react-hooks",
|
|
1369
|
-
"eslint-plugin-react-refresh"
|
|
1370
|
-
]);
|
|
1364
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath } = options;
|
|
1365
|
+
await ensurePackages(["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"]);
|
|
1371
1366
|
const isTypeAware = !!tsconfigPath;
|
|
1372
|
-
const typeAwareRules = {
|
|
1373
|
-
|
|
1374
|
-
"react/no-implicit-key": "error"
|
|
1375
|
-
};
|
|
1376
|
-
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1377
|
-
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1378
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1379
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1380
|
-
]);
|
|
1367
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "error" };
|
|
1368
|
+
const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
|
|
1381
1369
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
1382
1370
|
const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
1383
1371
|
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
|
|
@@ -1389,8 +1377,6 @@ async function react(options = {}) {
|
|
|
1389
1377
|
plugins: {
|
|
1390
1378
|
"react": plugins["@eslint-react"],
|
|
1391
1379
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1392
|
-
"react-hooks": pluginReactHooks,
|
|
1393
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1394
1380
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1395
1381
|
"react-refresh": pluginReactRefresh,
|
|
1396
1382
|
"react-rsc": plugins["@eslint-react/rsc"],
|
|
@@ -1405,85 +1391,8 @@ async function react(options = {}) {
|
|
|
1405
1391
|
},
|
|
1406
1392
|
name: "antfu/react/rules",
|
|
1407
1393
|
rules: {
|
|
1408
|
-
|
|
1409
|
-
"react/jsx-no-comment-textnodes": "warn",
|
|
1410
|
-
"react/jsx-no-duplicate-props": "warn",
|
|
1411
|
-
"react/jsx-uses-react": "warn",
|
|
1412
|
-
"react/jsx-uses-vars": "warn",
|
|
1413
|
-
"react/no-access-state-in-setstate": "error",
|
|
1414
|
-
"react/no-array-index-key": "warn",
|
|
1415
|
-
"react/no-children-count": "warn",
|
|
1416
|
-
"react/no-children-for-each": "warn",
|
|
1417
|
-
"react/no-children-map": "warn",
|
|
1418
|
-
"react/no-children-only": "warn",
|
|
1419
|
-
"react/no-children-to-array": "warn",
|
|
1420
|
-
"react/no-clone-element": "warn",
|
|
1421
|
-
"react/no-component-will-mount": "error",
|
|
1422
|
-
"react/no-component-will-receive-props": "error",
|
|
1423
|
-
"react/no-component-will-update": "error",
|
|
1424
|
-
"react/no-context-provider": "warn",
|
|
1425
|
-
"react/no-create-ref": "error",
|
|
1426
|
-
"react/no-default-props": "error",
|
|
1427
|
-
"react/no-direct-mutation-state": "error",
|
|
1428
|
-
"react/no-forward-ref": "warn",
|
|
1429
|
-
"react/no-missing-key": "error",
|
|
1430
|
-
"react/no-nested-component-definitions": "error",
|
|
1431
|
-
"react/no-nested-lazy-component-declarations": "error",
|
|
1432
|
-
"react/no-prop-types": "error",
|
|
1433
|
-
"react/no-redundant-should-component-update": "error",
|
|
1434
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1435
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1436
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1437
|
-
"react/no-string-refs": "error",
|
|
1438
|
-
"react/no-unnecessary-use-prefix": "warn",
|
|
1439
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1440
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1441
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1442
|
-
"react/no-unused-class-component-members": "warn",
|
|
1443
|
-
"react/no-use-context": "warn",
|
|
1444
|
-
"react/no-useless-forward-ref": "warn",
|
|
1445
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1394
|
+
...pluginReact.configs.recommended.rules,
|
|
1446
1395
|
"react/prefer-namespace-import": "error",
|
|
1447
|
-
"react-rsc/function-definition": "error",
|
|
1448
|
-
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1449
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1450
|
-
"react-dom/no-find-dom-node": "error",
|
|
1451
|
-
"react-dom/no-flush-sync": "error",
|
|
1452
|
-
"react-dom/no-hydrate": "error",
|
|
1453
|
-
"react-dom/no-namespace": "error",
|
|
1454
|
-
"react-dom/no-render": "error",
|
|
1455
|
-
"react-dom/no-render-return-value": "error",
|
|
1456
|
-
"react-dom/no-script-url": "warn",
|
|
1457
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1458
|
-
"react-dom/no-use-form-state": "error",
|
|
1459
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1460
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1461
|
-
"react-naming-convention/context-name": "warn",
|
|
1462
|
-
"react-naming-convention/ref-name": "warn",
|
|
1463
|
-
"react-naming-convention/use-state": "warn",
|
|
1464
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1465
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1466
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1467
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1468
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1469
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1470
|
-
...reactCompiler ? {
|
|
1471
|
-
"react-hooks/config": "error",
|
|
1472
|
-
"react-hooks/error-boundaries": "error",
|
|
1473
|
-
"react-hooks/component-hook-factories": "error",
|
|
1474
|
-
"react-hooks/gating": "error",
|
|
1475
|
-
"react-hooks/globals": "error",
|
|
1476
|
-
"react-hooks/immutability": "error",
|
|
1477
|
-
"react-hooks/preserve-manual-memoization": "error",
|
|
1478
|
-
"react-hooks/purity": "error",
|
|
1479
|
-
"react-hooks/refs": "error",
|
|
1480
|
-
"react-hooks/set-state-in-effect": "error",
|
|
1481
|
-
"react-hooks/set-state-in-render": "error",
|
|
1482
|
-
"react-hooks/static-components": "error",
|
|
1483
|
-
"react-hooks/unsupported-syntax": "warn",
|
|
1484
|
-
"react-hooks/use-memo": "error",
|
|
1485
|
-
"react-hooks/incompatible-library": "warn"
|
|
1486
|
-
} : {},
|
|
1487
1396
|
"react-refresh/only-export-components": ["error", {
|
|
1488
1397
|
allowConstantExport: isAllowConstantExport,
|
|
1489
1398
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1521,11 +1430,7 @@ async function react(options = {}) {
|
|
|
1521
1430
|
name: "antfu/react/typescript",
|
|
1522
1431
|
rules: {
|
|
1523
1432
|
"react-dom/no-string-style-prop": "off",
|
|
1524
|
-
"react-dom/no-unknown-property": "off"
|
|
1525
|
-
"react/jsx-no-duplicate-props": "off",
|
|
1526
|
-
"react/jsx-no-undef": "off",
|
|
1527
|
-
"react/jsx-uses-react": "off",
|
|
1528
|
-
"react/jsx-uses-vars": "off"
|
|
1433
|
+
"react-dom/no-unknown-property": "off"
|
|
1529
1434
|
}
|
|
1530
1435
|
},
|
|
1531
1436
|
...isTypeAware ? [{
|
|
@@ -2121,7 +2026,7 @@ async function typescript(options = {}) {
|
|
|
2121
2026
|
}] : [],
|
|
2122
2027
|
...erasableOnly ? [{
|
|
2123
2028
|
name: "antfu/typescript/erasable-syntax-only",
|
|
2124
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
2029
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-EoktVv6C.mjs")) },
|
|
2125
2030
|
rules: {
|
|
2126
2031
|
"erasable-syntax-only/enums": "error",
|
|
2127
2032
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -2435,6 +2340,10 @@ async function e18e(options = {}) {
|
|
|
2435
2340
|
...modernization ? { ...configs.modernization.rules } : {},
|
|
2436
2341
|
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
2437
2342
|
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
2343
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
2344
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
2345
|
+
"e18e/prefer-array-to-spliced": "off",
|
|
2346
|
+
"e18e/prefer-spread-syntax": "off",
|
|
2438
2347
|
...overrides
|
|
2439
2348
|
}
|
|
2440
2349
|
}];
|
|
@@ -2459,8 +2368,9 @@ const VuePackages = [
|
|
|
2459
2368
|
const defaultPluginRenaming = {
|
|
2460
2369
|
"@eslint-react": "react",
|
|
2461
2370
|
"@eslint-react/dom": "react-dom",
|
|
2462
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2463
2371
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2372
|
+
"@eslint-react/rsc": "react-rsc",
|
|
2373
|
+
"@eslint-react/web-api": "react-web-api",
|
|
2464
2374
|
"@next/next": "next",
|
|
2465
2375
|
"@stylistic": "style",
|
|
2466
2376
|
"@typescript-eslint": "ts",
|
|
@@ -2632,7 +2542,7 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2632
2542
|
nextjs: true,
|
|
2633
2543
|
node: true,
|
|
2634
2544
|
pnpm: true,
|
|
2635
|
-
react:
|
|
2545
|
+
react: true,
|
|
2636
2546
|
regexp: true,
|
|
2637
2547
|
solid: true,
|
|
2638
2548
|
stylistic: { experimental: true },
|