@vinicunca/eslint-config 4.10.0 → 5.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/dist/index.mjs CHANGED
@@ -145,13 +145,17 @@ const GLOB_EXCLUDE = [
145
145
  "**/.output",
146
146
  "**/.vite-inspect",
147
147
  "**/.yarn",
148
- "**/vite.config.*.timestamp-*",
149
148
  "**/CHANGELOG*.md",
150
- "**/*.min.*",
151
149
  "**/LICENSE*",
150
+ "**/*.min.*",
152
151
  "**/__snapshots__",
152
+ "**/vite.config.*.timestamp-*",
153
153
  "**/auto-import?(s).d.ts",
154
- "**/components.d.ts"
154
+ "**/components.d.ts",
155
+ "**/.context",
156
+ "**/.claude",
157
+ "**/.agents",
158
+ "**/.*/skills"
155
159
  ];
156
160
  //#endregion
157
161
  //#region src/utils.ts
@@ -390,6 +394,9 @@ async function e18e(options = {}) {
390
394
  ...modernization ? { ...configs.modernization.rules } : {},
391
395
  ...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
392
396
  ...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
397
+ ...type === "lib" ? {} : { "e18e/prefer-static-regex": "off" },
398
+ "e18e/prefer-array-at": "off",
399
+ "e18e/prefer-array-from-map": "off",
393
400
  "e18e/prefer-array-to-reversed": "off",
394
401
  "e18e/prefer-array-to-sorted": "off",
395
402
  "e18e/prefer-array-to-spliced": "off",
@@ -637,8 +644,9 @@ async function formatters(options = {}, stylistic = {}) {
637
644
  }
638
645
  //#endregion
639
646
  //#region src/configs/ignores.ts
640
- async function ignores(userIgnores = []) {
647
+ async function ignores(userIgnores = [], ignoreTypeScript = false) {
641
648
  let ignores = [...GLOB_EXCLUDE];
649
+ if (ignoreTypeScript) ignores.push(GLOB_TS, GLOB_TSX);
642
650
  if (e$1(userIgnores)) ignores = userIgnores(ignores);
643
651
  else ignores = [...ignores, ...userIgnores];
644
652
  return [{
@@ -1369,21 +1377,12 @@ const ReactRouterPackages = [
1369
1377
  "@react-router/dev"
1370
1378
  ];
1371
1379
  const NextJsPackages = ["next"];
1372
- const ReactCompilerPackages = ["babel-plugin-react-compiler"];
1373
1380
  async function react(options = {}) {
1374
- const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, reactCompiler = ReactCompilerPackages.some((i) => isPackageExists(i)), tsconfigPath } = options;
1375
- await ensurePackages([
1376
- "@eslint-react/eslint-plugin",
1377
- "eslint-plugin-react-hooks",
1378
- "eslint-plugin-react-refresh"
1379
- ]);
1381
+ const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath } = options;
1382
+ await ensurePackages(["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"]);
1380
1383
  const isTypeAware = !!tsconfigPath;
1381
- const typeAwareRules = { "react/no-leaked-conditional-rendering": WARN };
1382
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1383
- interopDefault(import("@eslint-react/eslint-plugin")),
1384
- interopDefault(import("eslint-plugin-react-hooks")),
1385
- interopDefault(import("eslint-plugin-react-refresh"))
1386
- ]);
1384
+ const typeAwareRules = { "react/no-leaked-conditional-rendering": ERROR };
1385
+ const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
1387
1386
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
1388
1387
  const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
1389
1388
  const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
@@ -1395,8 +1394,6 @@ async function react(options = {}) {
1395
1394
  plugins: {
1396
1395
  "react": plugins["@eslint-react"],
1397
1396
  "react-dom": plugins["@eslint-react/dom"],
1398
- "react-hooks": pluginReactHooks,
1399
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1400
1397
  "react-naming-convention": plugins["@eslint-react/naming-convention"],
1401
1398
  "react-refresh": pluginReactRefresh,
1402
1399
  "react-rsc": plugins["@eslint-react/rsc"],
@@ -1411,89 +1408,9 @@ async function react(options = {}) {
1411
1408
  },
1412
1409
  name: "vinicunca/react/rules",
1413
1410
  rules: {
1414
- "react-dom/no-dangerously-set-innerhtml": WARN,
1415
- "react-dom/no-dangerously-set-innerhtml-with-children": ERROR,
1416
- "react-dom/no-find-dom-node": ERROR,
1417
- "react-dom/no-flush-sync": ERROR,
1418
- "react-dom/no-hydrate": ERROR,
1419
- "react-dom/no-missing-button-type": WARN,
1420
- "react-dom/no-missing-iframe-sandbox": WARN,
1421
- "react-dom/no-namespace": ERROR,
1422
- "react-dom/no-render": ERROR,
1423
- "react-dom/no-render-return-value": ERROR,
1424
- "react-dom/no-script-url": WARN,
1425
- "react-dom/no-unsafe-iframe-sandbox": WARN,
1426
- "react-dom/no-unsafe-target-blank": WARN,
1427
- "react-dom/no-use-form-state": ERROR,
1428
- "react-dom/no-void-elements-with-children": ERROR,
1429
- "react-hooks-extra/no-direct-set-state-in-use-effect": WARN,
1430
- "react-hooks/exhaustive-deps": WARN,
1431
- "react-hooks/rules-of-hooks": ERROR,
1432
- "react-naming-convention/context-name": WARN,
1433
- "react-naming-convention/ref-name": WARN,
1434
- "react-naming-convention/use-state": WARN,
1435
- "react-rsc/function-definition": ERROR,
1436
- "react-web-api/no-leaked-event-listener": WARN,
1437
- "react-web-api/no-leaked-interval": WARN,
1438
- "react-web-api/no-leaked-resize-observer": WARN,
1439
- "react-web-api/no-leaked-timeout": WARN,
1440
- "react/jsx-no-comment-textnodes": WARN,
1441
- "react/jsx-no-duplicate-props": WARN,
1442
- "react/jsx-uses-vars": WARN,
1443
- "react/no-access-state-in-setstate": ERROR,
1444
- "react/no-array-index-key": WARN,
1445
- "react/no-children-count": WARN,
1446
- "react/no-children-for-each": WARN,
1447
- "react/no-children-map": WARN,
1448
- "react/no-children-only": WARN,
1449
- "react/no-children-to-array": WARN,
1450
- "react/no-clone-element": WARN,
1451
- "react/no-component-will-mount": ERROR,
1452
- "react/no-component-will-receive-props": ERROR,
1453
- "react/no-component-will-update": ERROR,
1454
- "react/no-context-provider": WARN,
1455
- "react/no-create-ref": ERROR,
1456
- "react/no-default-props": ERROR,
1457
- "react/no-direct-mutation-state": ERROR,
1458
- "react/no-forward-ref": WARN,
1459
- "react/no-missing-key": ERROR,
1460
- "react/no-nested-component-definitions": ERROR,
1461
- "react/no-prop-types": ERROR,
1462
- "react/no-redundant-should-component-update": ERROR,
1463
- "react/no-set-state-in-component-did-mount": WARN,
1464
- "react/no-set-state-in-component-did-update": WARN,
1465
- "react/no-set-state-in-component-will-update": WARN,
1466
- "react/no-string-refs": ERROR,
1467
- "react/no-unnecessary-use-prefix": WARN,
1468
- "react/no-unsafe-component-will-mount": WARN,
1469
- "react/no-unsafe-component-will-receive-props": WARN,
1470
- "react/no-unsafe-component-will-update": WARN,
1471
- "react/no-unstable-context-value": WARN,
1472
- "react/no-unstable-default-props": WARN,
1473
- "react/no-unused-class-component-members": WARN,
1474
- "react/no-unused-state": WARN,
1475
- "react/no-use-context": WARN,
1476
- "react/no-useless-forward-ref": WARN,
1411
+ ...pluginReact.configs.recommended.rules,
1477
1412
  "react/prefer-namespace-import": ERROR,
1478
- "react/prefer-use-state-lazy-initialization": WARN,
1479
- ...reactCompiler ? {
1480
- "react-hooks/component-hook-factories": ERROR,
1481
- "react-hooks/config": ERROR,
1482
- "react-hooks/error-boundaries": ERROR,
1483
- "react-hooks/gating": ERROR,
1484
- "react-hooks/globals": ERROR,
1485
- "react-hooks/immutability": ERROR,
1486
- "react-hooks/incompatible-library": WARN,
1487
- "react-hooks/preserve-manual-memoization": ERROR,
1488
- "react-hooks/purity": ERROR,
1489
- "react-hooks/refs": ERROR,
1490
- "react-hooks/set-state-in-effect": ERROR,
1491
- "react-hooks/set-state-in-render": ERROR,
1492
- "react-hooks/static-components": ERROR,
1493
- "react-hooks/unsupported-syntax": WARN,
1494
- "react-hooks/use-memo": ERROR
1495
- } : {},
1496
- "react-refresh/only-export-components": [WARN, {
1413
+ "react-refresh/only-export-components": [ERROR, {
1497
1414
  allowConstantExport: isAllowConstantExport,
1498
1415
  allowExportNames: [...isUsingNext ? [
1499
1416
  "dynamic",
@@ -1503,12 +1420,13 @@ async function react(options = {}) {
1503
1420
  "runtime",
1504
1421
  "preferredRegion",
1505
1422
  "maxDuration",
1506
- "config",
1507
1423
  "generateStaticParams",
1508
1424
  "metadata",
1509
1425
  "generateMetadata",
1510
1426
  "viewport",
1511
- "generateViewport"
1427
+ "generateViewport",
1428
+ "generateImageMetadata",
1429
+ "generateSitemaps"
1512
1430
  ] : [], ...isUsingRemix || isUsingReactRouter ? [
1513
1431
  "meta",
1514
1432
  "links",
@@ -1529,11 +1447,7 @@ async function react(options = {}) {
1529
1447
  name: "vinicunca/react/typescript",
1530
1448
  rules: {
1531
1449
  "react-dom/no-string-style-prop": "off",
1532
- "react-dom/no-unknown-property": "off",
1533
- "react/jsx-no-duplicate-props": "off",
1534
- "react/jsx-no-undef": "off",
1535
- "react/jsx-uses-react": "off",
1536
- "react/jsx-uses-vars": "off"
1450
+ "react-dom/no-unknown-property": "off"
1537
1451
  }
1538
1452
  },
1539
1453
  ...isTypeAware ? [{
@@ -1615,11 +1529,13 @@ async function solid(options = {}) {
1615
1529
  //#region src/configs/sonar.ts
1616
1530
  async function sonar() {
1617
1531
  return [{
1532
+ files: [GLOB_SRC],
1618
1533
  name: "vinicunca/sonar/rules",
1619
1534
  plugins: { sonar: pluginSonar },
1620
1535
  rules: {
1621
- ...pluginSonar.configs.recommended.rules,
1536
+ ...(pluginSonar.configs?.recommended).rules,
1622
1537
  "sonar/cognitive-complexity": "off",
1538
+ "sonar/no-unused-import": "off",
1623
1539
  "sonar/no-unused-vars": "off",
1624
1540
  "sonar/pseudo-random": "off",
1625
1541
  "sonar/slow-regex": "off",
@@ -2165,7 +2081,7 @@ async function typescript(options = {}) {
2165
2081
  }] : [],
2166
2082
  ...erasableOnly ? [{
2167
2083
  name: "antfu/typescript/erasable-syntax-only",
2168
- plugins: { "erasable-syntax-only": await interopDefault(import("./lib-D3Kr7UIJ.mjs")) },
2084
+ plugins: { "erasable-syntax-only": await interopDefault(import("./lib-D13rzY6d.mjs")) },
2169
2085
  rules: {
2170
2086
  "erasable-syntax-only/enums": ERROR,
2171
2087
  "erasable-syntax-only/import-aliases": ERROR,
@@ -2487,8 +2403,9 @@ const VuePackages = [
2487
2403
  const defaultPluginRenaming = {
2488
2404
  "@eslint-react": "react",
2489
2405
  "@eslint-react/dom": "react-dom",
2490
- "@eslint-react/hooks-extra": "react-hooks-extra",
2491
2406
  "@eslint-react/naming-convention": "react-naming-convention",
2407
+ "@eslint-react/rsc": "react-rsc",
2408
+ "@eslint-react/web-api": "react-web-api",
2492
2409
  "@next/next": "next",
2493
2410
  "@stylistic": "style",
2494
2411
  "@typescript-eslint": "ts",
@@ -2509,7 +2426,7 @@ const defaultPluginRenaming = {
2509
2426
  * The merged ESLint configurations.
2510
2427
  */
2511
2428
  function vinicuncaESLint(options = {}, ...userConfigs) {
2512
- const { astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, 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, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2429
+ const { astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, 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, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2513
2430
  let isInEditor = options.isInEditor;
2514
2431
  if (isInEditor == null) {
2515
2432
  isInEditor = isInEditorEnv();
@@ -2528,10 +2445,10 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2528
2445
  })]));
2529
2446
  const typescriptOptions = resolveSubOptions(options, "typescript");
2530
2447
  const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2531
- configs.push(ignores(userIgnores), javascript({
2448
+ configs.push(ignores(userIgnores, !enableTypeScript), javascript({
2532
2449
  isInEditor,
2533
2450
  overrides: getOverrides(options, "javascript")
2534
- }), comments(), imports({ stylistic: stylisticOptions }), command(), perfectionist(), sonar());
2451
+ }), comments(), command(), perfectionist(), sonar());
2535
2452
  if (enableNode) configs.push(node());
2536
2453
  if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
2537
2454
  if (enableImports) configs.push(imports({