From 102d4e08cf5d4bb2a7233c82507a8e24cb447b4a Mon Sep 17 00:00:00 2001 From: REL1CX Date: Wed, 19 Feb 2025 05:03:10 +0800 Subject: [PATCH] feat: add recommended presets for each plugin (#940) --- .vscode/settings.json | 12 +- examples/dual-react-dom-lib/eslint.config.mjs | 23 ++- examples/dual-react-dom-lib/package.json | 6 +- package.json | 8 +- .../src/configs/all.ts | 15 ++ .../eslint-plugin-react-debug/src/index.ts | 44 +++--- .../eslint-plugin-react-debug/src/plugin.ts | 22 +++ .../src/configs/recommended.ts | 23 +++ .../eslint-plugin-react-dom/src/index.ts | 60 +++---- .../eslint-plugin-react-dom/src/plugin.ts | 38 +++++ .../src/configs/recommended.ts | 9 ++ .../src/index.ts | 54 +++---- .../src/plugin.ts | 32 ++++ .../src/configs/recommended.ts | 5 + .../src/index.ts | 40 +++-- .../src/plugin.ts | 18 +++ .../src/configs/recommended.ts | 15 ++ .../eslint-plugin-react-web-api/src/index.ts | 38 +++-- .../eslint-plugin-react-web-api/src/plugin.ts | 18 +++ .../src/configs/recommended-type-checked.ts | 15 ++ .../src/configs/recommended-typescript.ts | 16 ++ .../src/configs/recommended.ts | 49 ++++++ .../eslint-plugin-react-x/src/index.ts | 146 ++++-------------- .../eslint-plugin-react-x/src/plugin.ts | 120 ++++++++++++++ .../plugins/eslint-plugin/src/configs/core.ts | 4 +- packages/plugins/eslint-plugin/src/index.ts | 38 ++--- pnpm-lock.yaml | 26 +++- 27 files changed, 614 insertions(+), 280 deletions(-) create mode 100644 packages/plugins/eslint-plugin-react-debug/src/configs/all.ts create mode 100644 packages/plugins/eslint-plugin-react-debug/src/plugin.ts create mode 100644 packages/plugins/eslint-plugin-react-dom/src/configs/recommended.ts create mode 100644 packages/plugins/eslint-plugin-react-dom/src/plugin.ts create mode 100644 packages/plugins/eslint-plugin-react-hooks-extra/src/configs/recommended.ts create mode 100644 packages/plugins/eslint-plugin-react-hooks-extra/src/plugin.ts create mode 100644 packages/plugins/eslint-plugin-react-naming-convention/src/configs/recommended.ts create mode 100644 packages/plugins/eslint-plugin-react-naming-convention/src/plugin.ts create mode 100644 packages/plugins/eslint-plugin-react-web-api/src/configs/recommended.ts create mode 100644 packages/plugins/eslint-plugin-react-web-api/src/plugin.ts create mode 100644 packages/plugins/eslint-plugin-react-x/src/configs/recommended-type-checked.ts create mode 100644 packages/plugins/eslint-plugin-react-x/src/configs/recommended-typescript.ts create mode 100644 packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts create mode 100644 packages/plugins/eslint-plugin-react-x/src/plugin.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 2d6ca7065..59a1f994a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,17 +33,7 @@ "eslint.workingDirectories": [ { "changeProcessCWD": true, - "mode": "location" - }, - { - "changeProcessCWD": true, - "mode": "auto", - "pattern": "examples/*" - }, - { - "changeProcessCWD": true, - "mode": "auto", - "pattern": "apps/*" + "mode": "auto" } ], "files.exclude": { diff --git a/examples/dual-react-dom-lib/eslint.config.mjs b/examples/dual-react-dom-lib/eslint.config.mjs index 0c10b6a6c..913c4cb5e 100644 --- a/examples/dual-react-dom-lib/eslint.config.mjs +++ b/examples/dual-react-dom-lib/eslint.config.mjs @@ -1,6 +1,10 @@ import eslintJs from "@eslint/js"; -import eslintReact from "@eslint-react/eslint-plugin"; +import eslintPluginReactx from "eslint-plugin-react-x"; +import eslintPluginReactDom from "eslint-plugin-react-dom"; +import eslintPluginReactWebApi from "eslint-plugin-react-web-api"; import eslintPluginReactHooks from "eslint-plugin-react-hooks"; +import eslintPluginReactHooksExtra from "eslint-plugin-react-hooks-extra"; +import eslintPluginReactNamingConvention from "eslint-plugin-react-naming-convention"; import tseslint from "typescript-eslint"; import TSCONFIG from "./tsconfig.json" with { type: "json" }; @@ -45,12 +49,23 @@ export default tseslint.config( "no-console": "off", }, }, - // React configuration + // react specific configurations { files: TSCONFIG.include, - ...eslintReact.configs["recommended-type-checked"], + ...eslintPluginReactx.configs["recommended-type-checked"], + }, + { + files: TSCONFIG.include, + ...eslintPluginReactDom.configs.recommended, + }, + { + files: TSCONFIG.include, + ...eslintPluginReactWebApi.configs.recommended, + }, + { + files: TSCONFIG.include, + ...eslintPluginReactHooksExtra.configs.recommended, }, - // React Hooks configuration { files: TSCONFIG.include, plugins: { diff --git a/examples/dual-react-dom-lib/package.json b/examples/dual-react-dom-lib/package.json index 1292d23f7..45503dc59 100644 --- a/examples/dual-react-dom-lib/package.json +++ b/examples/dual-react-dom-lib/package.json @@ -31,7 +31,11 @@ "prepare": "pnpm run build" }, "devDependencies": { - "@eslint-react/eslint-plugin": "workspace:*", + "eslint-plugin-react-x": "workspace:*", + "eslint-plugin-react-dom": "workspace:*", + "eslint-plugin-react-web-api": "workspace:*", + "eslint-plugin-react-hooks-extra": "workspace:*", + "eslint-plugin-react-naming-convention": "workspace:*", "@eslint/js": "^9.20.0", "@tsconfig/node22": "^22.0.0", "@tsconfig/strictest": "^2.0.5", diff --git a/package.json b/package.json index 8fa7f7320..09381607a 100644 --- a/package.json +++ b/package.json @@ -115,18 +115,18 @@ }, "pnpm": { "overrides": { - "is-core-module": "npm:@socketregistry/is-core-module@^1.0.7", - "safe-buffer": "npm:@socketregistry/safe-buffer@^1.0.6", - "safer-buffer": "npm:@socketregistry/safer-buffer@^1.0.6", - "typedarray": "npm:@socketregistry/typedarray@^1.0.5", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "cross-spawn": "^7.0.6", "esbuild": "^0.25.0", + "is-core-module": "npm:@socketregistry/is-core-module@^1.0.7", "next": "^15.1.7", "react": "^19.0.0", "react-dom": "^19.0.0", + "safe-buffer": "npm:@socketregistry/safe-buffer@^1.0.6", + "safer-buffer": "npm:@socketregistry/safer-buffer@^1.0.6", "ts-api-utils": "^2.0.1", + "typedarray": "npm:@socketregistry/typedarray@^1.0.5", "typescript": "^5.7.3" } } diff --git a/packages/plugins/eslint-plugin-react-debug/src/configs/all.ts b/packages/plugins/eslint-plugin-react-debug/src/configs/all.ts new file mode 100644 index 000000000..f9b2a2501 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-debug/src/configs/all.ts @@ -0,0 +1,15 @@ +import type { RulePreset } from "@eslint-react/shared"; +import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; + +export const name = "react-debug/all"; + +export const rules = { + "react-debug/class-component": "warn", + "react-debug/function-component": "warn", + "react-debug/hook": "warn", + "react-debug/is-from-react": "off", +} as const satisfies RulePreset; + +export const settings = { + "react-x": DEFAULT_ESLINT_REACT_SETTINGS, +}; diff --git a/packages/plugins/eslint-plugin-react-debug/src/index.ts b/packages/plugins/eslint-plugin-react-debug/src/index.ts index 0ebef1849..297e1c1bd 100644 --- a/packages/plugins/eslint-plugin-react-debug/src/index.ts +++ b/packages/plugins/eslint-plugin-react-debug/src/index.ts @@ -1,22 +1,28 @@ -import { name, version } from "../package.json"; -import classComponent from "./rules/class-component"; -import functionComponent from "./rules/function-component"; -import hook from "./rules/hook"; -import isFromReact from "./rules/is-from-react"; +import type { RulePreset } from "@eslint-react/shared"; -export default { - meta: { - name, - version, - }, - rules: { - "class-component": classComponent, - "function-component": functionComponent, - hook: hook, - "is-from-react": isFromReact, +import * as allConfig from "./configs/all"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} - // Part: deprecated rules - /** @deprecated Use `hook` instead */ - "react-hooks": hook, +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} + +export default { + ...plugin, + configs: { + ["all"]: makeConfig(allConfig), + ["all-legacy"]: makeLegacyConfig(allConfig), }, -} as const; +}; diff --git a/packages/plugins/eslint-plugin-react-debug/src/plugin.ts b/packages/plugins/eslint-plugin-react-debug/src/plugin.ts new file mode 100644 index 000000000..476d26bf9 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-debug/src/plugin.ts @@ -0,0 +1,22 @@ +import { name, version } from "../package.json"; +import classComponent from "./rules/class-component"; +import functionComponent from "./rules/function-component"; +import hook from "./rules/hook"; +import isFromReact from "./rules/is-from-react"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "class-component": classComponent, + "function-component": functionComponent, + hook: hook, + "is-from-react": isFromReact, + + // Part: deprecated rules + /** @deprecated Use `hook` instead */ + "react-hooks": hook, + }, +} as const; diff --git a/packages/plugins/eslint-plugin-react-dom/src/configs/recommended.ts b/packages/plugins/eslint-plugin-react-dom/src/configs/recommended.ts new file mode 100644 index 000000000..069e68387 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-dom/src/configs/recommended.ts @@ -0,0 +1,23 @@ +import type { RulePreset } from "@eslint-react/shared"; +import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; + +export const name = "react-dom/recommended"; + +export const rules = { + "react-dom/no-dangerously-set-innerhtml": "warn", + "react-dom/no-dangerously-set-innerhtml-with-children": "error", + "react-dom/no-find-dom-node": "error", + "react-dom/no-missing-button-type": "warn", + "react-dom/no-missing-iframe-sandbox": "warn", + "react-dom/no-namespace": "error", + "react-dom/no-render-return-value": "error", + "react-dom/no-script-url": "warn", + "react-dom/no-unknown-property": "warn", + "react-dom/no-unsafe-iframe-sandbox": "warn", + "react-dom/no-unsafe-target-blank": "warn", + "react-dom/no-void-elements-with-children": "warn", +} as const satisfies RulePreset; + +export const settings = { + "react-x": DEFAULT_ESLINT_REACT_SETTINGS, +}; diff --git a/packages/plugins/eslint-plugin-react-dom/src/index.ts b/packages/plugins/eslint-plugin-react-dom/src/index.ts index 80770be5c..c09c06c8d 100644 --- a/packages/plugins/eslint-plugin-react-dom/src/index.ts +++ b/packages/plugins/eslint-plugin-react-dom/src/index.ts @@ -1,38 +1,28 @@ -import { name, version } from "../package.json"; -import noDangerouslySetInnerHTML from "./rules/no-dangerously-set-innerhtml"; -import noDangerouslySetInnerHTMLWithChildren from "./rules/no-dangerously-set-innerhtml-with-children"; -import noFindDomNode from "./rules/no-find-dom-node"; -import noMissingButtonType from "./rules/no-missing-button-type"; -import noMissingIframeSandbox from "./rules/no-missing-iframe-sandbox"; -import noNamespace from "./rules/no-namespace"; -import noRenderReturnValue from "./rules/no-render-return-value"; -import noScriptUrl from "./rules/no-script-url"; -import noUnknownProperty from "./rules/no-unknown-property"; -import noUnsafeIframeSandbox from "./rules/no-unsafe-iframe-sandbox"; -import noUnsafeTargetBlank from "./rules/no-unsafe-target-blank"; -import noVoidElementsWithChildren from "./rules/no-void-elements-with-children"; +import type { RulePreset } from "@eslint-react/shared"; -export default { - meta: { - name, - version, - }, - rules: { - "no-dangerously-set-innerhtml": noDangerouslySetInnerHTML, - "no-dangerously-set-innerhtml-with-children": noDangerouslySetInnerHTMLWithChildren, - "no-find-dom-node": noFindDomNode, - "no-missing-button-type": noMissingButtonType, - "no-missing-iframe-sandbox": noMissingIframeSandbox, - "no-namespace": noNamespace, - "no-render-return-value": noRenderReturnValue, - "no-script-url": noScriptUrl, - "no-unknown-property": noUnknownProperty, - "no-unsafe-iframe-sandbox": noUnsafeIframeSandbox, - "no-unsafe-target-blank": noUnsafeTargetBlank, - "no-void-elements-with-children": noVoidElementsWithChildren, +import * as recommendedConfig from "./configs/recommended"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} - // Part: deprecated rules - /** @deprecated Use `no-void-elements-with-children` instead */ - "no-children-in-void-dom-elements": noVoidElementsWithChildren, +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} + +export default { + ...plugin, + configs: { + ["recommended"]: makeConfig(recommendedConfig), + ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), }, -} as const; +}; diff --git a/packages/plugins/eslint-plugin-react-dom/src/plugin.ts b/packages/plugins/eslint-plugin-react-dom/src/plugin.ts new file mode 100644 index 000000000..41fbbca85 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-dom/src/plugin.ts @@ -0,0 +1,38 @@ +import { name, version } from "../package.json"; +import noDangerouslySetInnerHTML from "./rules/no-dangerously-set-innerhtml"; +import noDangerouslySetInnerHTMLWithChildren from "./rules/no-dangerously-set-innerhtml-with-children"; +import noFindDomNode from "./rules/no-find-dom-node"; +import noMissingButtonType from "./rules/no-missing-button-type"; +import noMissingIframeSandbox from "./rules/no-missing-iframe-sandbox"; +import noNamespace from "./rules/no-namespace"; +import noRenderReturnValue from "./rules/no-render-return-value"; +import noScriptUrl from "./rules/no-script-url"; +import noUnknownProperty from "./rules/no-unknown-property"; +import noUnsafeIframeSandbox from "./rules/no-unsafe-iframe-sandbox"; +import noUnsafeTargetBlank from "./rules/no-unsafe-target-blank"; +import noVoidElementsWithChildren from "./rules/no-void-elements-with-children"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "no-dangerously-set-innerhtml": noDangerouslySetInnerHTML, + "no-dangerously-set-innerhtml-with-children": noDangerouslySetInnerHTMLWithChildren, + "no-find-dom-node": noFindDomNode, + "no-missing-button-type": noMissingButtonType, + "no-missing-iframe-sandbox": noMissingIframeSandbox, + "no-namespace": noNamespace, + "no-render-return-value": noRenderReturnValue, + "no-script-url": noScriptUrl, + "no-unknown-property": noUnknownProperty, + "no-unsafe-iframe-sandbox": noUnsafeIframeSandbox, + "no-unsafe-target-blank": noUnsafeTargetBlank, + "no-void-elements-with-children": noVoidElementsWithChildren, + + // Part: deprecated rules + /** @deprecated Use `no-void-elements-with-children` instead */ + "no-children-in-void-dom-elements": noVoidElementsWithChildren, + }, +} as const; diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/configs/recommended.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/configs/recommended.ts new file mode 100644 index 000000000..3f09f320d --- /dev/null +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/configs/recommended.ts @@ -0,0 +1,9 @@ +import type { RulePreset } from "@eslint-react/shared"; + +export const name = "react-hooks-extra/recommended"; + +export const rules = { + "react-hooks-extra/no-direct-set-state-in-use-effect": "warn", + "react-hooks-extra/no-useless-custom-hooks": "warn", + "react-hooks-extra/prefer-use-state-lazy-initialization": "warn", +} as const satisfies RulePreset; diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/index.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/index.ts index 5669d5e9a..c09c06c8d 100644 --- a/packages/plugins/eslint-plugin-react-hooks-extra/src/index.ts +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/index.ts @@ -1,32 +1,28 @@ -import { name, version } from "../package.json"; -import noDirectSetStateInUseEffect from "./rules/no-direct-set-state-in-use-effect"; -import noDirectSetStateInUseLayoutEffect from "./rules/no-direct-set-state-in-use-layout-effect"; -import noUnnecessaryUseCallback from "./rules/no-unnecessary-use-callback"; -import noUnnecessaryUseMemo from "./rules/no-unnecessary-use-memo"; -import noUselessCustomHooks from "./rules/no-useless-custom-hooks"; -import preferUseStateLazyInitialization from "./rules/prefer-use-state-lazy-initialization"; +import type { RulePreset } from "@eslint-react/shared"; -export default { - meta: { - name, - version, - }, - rules: { - "no-direct-set-state-in-use-effect": noDirectSetStateInUseEffect, - "no-direct-set-state-in-use-layout-effect": noDirectSetStateInUseLayoutEffect, - "no-unnecessary-use-callback": noUnnecessaryUseCallback, - "no-unnecessary-use-memo": noUnnecessaryUseMemo, - "no-useless-custom-hooks": noUselessCustomHooks, - "prefer-use-state-lazy-initialization": preferUseStateLazyInitialization, +import * as recommendedConfig from "./configs/recommended"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} - // Part: deprecated rules - /** @deprecated Use `no-useless-custom-hooks` instead */ - "ensure-custom-hooks-using-other-hooks": noUselessCustomHooks, - /** @deprecated Use `no-unnecessary-use-callback` instead */ - "ensure-use-callback-has-non-empty-deps": noUnnecessaryUseCallback, - /** @deprecated Use `no-unnecessary-use-memo` instead */ - "ensure-use-memo-has-non-empty-deps": noUnnecessaryUseMemo, - /** @deprecated Use `no-useless-custom-hooks` instead */ - "no-redundant-custom-hook": noUselessCustomHooks, +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} + +export default { + ...plugin, + configs: { + ["recommended"]: makeConfig(recommendedConfig), + ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), }, -} as const; +}; diff --git a/packages/plugins/eslint-plugin-react-hooks-extra/src/plugin.ts b/packages/plugins/eslint-plugin-react-hooks-extra/src/plugin.ts new file mode 100644 index 000000000..1bdb6ba82 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-hooks-extra/src/plugin.ts @@ -0,0 +1,32 @@ +import { name, version } from "../package.json"; +import noDirectSetStateInUseEffect from "./rules/no-direct-set-state-in-use-effect"; +import noDirectSetStateInUseLayoutEffect from "./rules/no-direct-set-state-in-use-layout-effect"; +import noUnnecessaryUseCallback from "./rules/no-unnecessary-use-callback"; +import noUnnecessaryUseMemo from "./rules/no-unnecessary-use-memo"; +import noUselessCustomHooks from "./rules/no-useless-custom-hooks"; +import preferUseStateLazyInitialization from "./rules/prefer-use-state-lazy-initialization"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "no-direct-set-state-in-use-effect": noDirectSetStateInUseEffect, + "no-direct-set-state-in-use-layout-effect": noDirectSetStateInUseLayoutEffect, + "no-unnecessary-use-callback": noUnnecessaryUseCallback, + "no-unnecessary-use-memo": noUnnecessaryUseMemo, + "no-useless-custom-hooks": noUselessCustomHooks, + "prefer-use-state-lazy-initialization": preferUseStateLazyInitialization, + + // Part: deprecated rules + /** @deprecated Use `no-useless-custom-hooks` instead */ + "ensure-custom-hooks-using-other-hooks": noUselessCustomHooks, + /** @deprecated Use `no-unnecessary-use-callback` instead */ + "ensure-use-callback-has-non-empty-deps": noUnnecessaryUseCallback, + /** @deprecated Use `no-unnecessary-use-memo` instead */ + "ensure-use-memo-has-non-empty-deps": noUnnecessaryUseMemo, + /** @deprecated Use `no-useless-custom-hooks` instead */ + "no-redundant-custom-hook": noUselessCustomHooks, + }, +} as const; diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/configs/recommended.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/configs/recommended.ts new file mode 100644 index 000000000..a1b91c890 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/configs/recommended.ts @@ -0,0 +1,5 @@ +import type { RulePreset } from "@eslint-react/shared"; + +export const name = "react-naming-convention/recommended"; + +export const rules = {} as const satisfies RulePreset; diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/index.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/index.ts index 150fd3ef5..c09c06c8d 100644 --- a/packages/plugins/eslint-plugin-react-naming-convention/src/index.ts +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/index.ts @@ -1,18 +1,28 @@ -import { name, version } from "../package.json"; -import componentName from "./rules/component-name"; -import filename from "./rules/filename"; -import filenameExtension from "./rules/filename-extension"; -import useState from "./rules/use-state"; +import type { RulePreset } from "@eslint-react/shared"; + +import * as recommendedConfig from "./configs/recommended"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} + +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} export default { - meta: { - name, - version, - }, - rules: { - "component-name": componentName, - filename, - "filename-extension": filenameExtension, - "use-state": useState, + ...plugin, + configs: { + ["recommended"]: makeConfig(recommendedConfig), + ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), }, -} as const; +}; diff --git a/packages/plugins/eslint-plugin-react-naming-convention/src/plugin.ts b/packages/plugins/eslint-plugin-react-naming-convention/src/plugin.ts new file mode 100644 index 000000000..e25bd14b0 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-naming-convention/src/plugin.ts @@ -0,0 +1,18 @@ +import { name, version } from "../package.json"; +import componentName from "./rules/component-name"; +import filename from "./rules/filename"; +import filenameExtension from "./rules/filename-extension"; +import useState from "./rules/use-state"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "component-name": componentName, + filename, + "filename-extension": filenameExtension, + "use-state": useState, + }, +} as const; diff --git a/packages/plugins/eslint-plugin-react-web-api/src/configs/recommended.ts b/packages/plugins/eslint-plugin-react-web-api/src/configs/recommended.ts new file mode 100644 index 000000000..5f191a0c9 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-web-api/src/configs/recommended.ts @@ -0,0 +1,15 @@ +import type { RulePreset } from "@eslint-react/shared"; +import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; + +export const name = "react-web-api/recommended"; + +export const rules = { + "react-web-api/no-leaked-event-listener": "warn", + "react-web-api/no-leaked-interval": "warn", + "react-web-api/no-leaked-resize-observer": "warn", + "react-web-api/no-leaked-timeout": "warn", +} as const satisfies RulePreset; + +export const settings = { + "react-x": DEFAULT_ESLINT_REACT_SETTINGS, +}; diff --git a/packages/plugins/eslint-plugin-react-web-api/src/index.ts b/packages/plugins/eslint-plugin-react-web-api/src/index.ts index 91c870722..c09c06c8d 100644 --- a/packages/plugins/eslint-plugin-react-web-api/src/index.ts +++ b/packages/plugins/eslint-plugin-react-web-api/src/index.ts @@ -1,18 +1,28 @@ -import { name, version } from "../package.json"; -import noLeakedEventListener from "./rules/no-leaked-event-listener"; -import noLeakedInterval from "./rules/no-leaked-interval"; -import noLeakedResizeObserver from "./rules/no-leaked-resize-observer"; -import noLeakedTimeout from "./rules/no-leaked-timeout"; +import type { RulePreset } from "@eslint-react/shared"; + +import * as recommendedConfig from "./configs/recommended"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} + +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} export default { - meta: { - name, - version, - }, - rules: { - "no-leaked-event-listener": noLeakedEventListener, - "no-leaked-interval": noLeakedInterval, - "no-leaked-resize-observer": noLeakedResizeObserver, - "no-leaked-timeout": noLeakedTimeout, + ...plugin, + configs: { + ["recommended"]: makeConfig(recommendedConfig), + ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), }, }; diff --git a/packages/plugins/eslint-plugin-react-web-api/src/plugin.ts b/packages/plugins/eslint-plugin-react-web-api/src/plugin.ts new file mode 100644 index 000000000..ae79482a4 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-web-api/src/plugin.ts @@ -0,0 +1,18 @@ +import { name, version } from "../package.json"; +import noLeakedEventListener from "./rules/no-leaked-event-listener"; +import noLeakedInterval from "./rules/no-leaked-interval"; +import noLeakedResizeObserver from "./rules/no-leaked-resize-observer"; +import noLeakedTimeout from "./rules/no-leaked-timeout"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "no-leaked-event-listener": noLeakedEventListener, + "no-leaked-interval": noLeakedInterval, + "no-leaked-resize-observer": noLeakedResizeObserver, + "no-leaked-timeout": noLeakedTimeout, + }, +} as const; diff --git a/packages/plugins/eslint-plugin-react-x/src/configs/recommended-type-checked.ts b/packages/plugins/eslint-plugin-react-x/src/configs/recommended-type-checked.ts new file mode 100644 index 000000000..f6ae7c988 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-x/src/configs/recommended-type-checked.ts @@ -0,0 +1,15 @@ +import type { RulePreset } from "@eslint-react/shared"; + +import * as recommendedTypeScript from "./recommended-typescript"; + +export const name = "react-x/recommended-type-checked"; + +export const rules = { + ...recommendedTypeScript.rules, + "react-x/no-leaked-conditional-rendering": "warn", + // "react-x/prefer-read-only-props": "warn", +} as const satisfies RulePreset; + +export const settings = { + ...recommendedTypeScript.settings, +}; diff --git a/packages/plugins/eslint-plugin-react-x/src/configs/recommended-typescript.ts b/packages/plugins/eslint-plugin-react-x/src/configs/recommended-typescript.ts new file mode 100644 index 000000000..904fcc212 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-x/src/configs/recommended-typescript.ts @@ -0,0 +1,16 @@ +import type { RulePreset } from "@eslint-react/shared"; + +import * as recommended from "./recommended"; + +export const name = "react-x/recommended-typescript"; + +export const rules = { + ...recommended.rules, + "react-x/dom/no-unknown-property": "off", + "react-x/no-duplicate-jsx-props": "off", + "react-x/use-jsx-vars": "off", +} as const satisfies RulePreset; + +export const settings = { + ...recommended.settings, +}; diff --git a/packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts b/packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts new file mode 100644 index 000000000..0ea5303d9 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-x/src/configs/recommended.ts @@ -0,0 +1,49 @@ +import type { RulePreset } from "@eslint-react/shared"; +import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; + +export const name = "react-x/recommended"; + +export const rules = { + "react-x/ensure-forward-ref-using-ref": "warn", + "react-x/no-access-state-in-setstate": "error", + "react-x/no-array-index-key": "warn", + "react-x/no-children-count": "warn", + "react-x/no-children-for-each": "warn", + "react-x/no-children-map": "warn", + "react-x/no-children-only": "warn", + "react-x/no-children-to-array": "warn", + "react-x/no-clone-element": "warn", + "react-x/no-comment-textnodes": "warn", + "react-x/no-component-will-mount": "error", + "react-x/no-component-will-receive-props": "error", + "react-x/no-component-will-update": "error", + "react-x/no-context-provider": "warn", + "react-x/no-create-ref": "error", + "react-x/no-default-props": "error", + "react-x/no-direct-mutation-state": "error", + "react-x/no-duplicate-jsx-props": "warn", + "react-x/no-duplicate-key": "warn", + "react-x/no-forward-ref": "warn", + "react-x/no-implicit-key": "warn", + "react-x/no-missing-key": "error", + "react-x/no-nested-components": "error", + "react-x/no-prop-types": "error", + "react-x/no-redundant-should-component-update": "error", + "react-x/no-set-state-in-component-did-mount": "warn", + "react-x/no-set-state-in-component-did-update": "warn", + "react-x/no-set-state-in-component-will-update": "warn", + "react-x/no-string-refs": "error", + "react-x/no-unsafe-component-will-mount": "warn", + "react-x/no-unsafe-component-will-receive-props": "warn", + "react-x/no-unsafe-component-will-update": "warn", + "react-x/no-unstable-context-value": "warn", + "react-x/no-unstable-default-props": "warn", + "react-x/no-unused-class-component-members": "warn", + "react-x/no-unused-state": "warn", + "react-x/no-use-context": "warn", + "react-x/use-jsx-vars": "warn", +} as const satisfies RulePreset; + +export const settings = { + "react-x": DEFAULT_ESLINT_REACT_SETTINGS, +}; diff --git a/packages/plugins/eslint-plugin-react-x/src/index.ts b/packages/plugins/eslint-plugin-react-x/src/index.ts index f62dcff06..9e9b488bd 100644 --- a/packages/plugins/eslint-plugin-react-x/src/index.ts +++ b/packages/plugins/eslint-plugin-react-x/src/index.ts @@ -1,120 +1,34 @@ -import { name, version } from "../package.json"; -import avoidShorthandBoolean from "./rules/avoid-shorthand-boolean"; -import avoidShorthandFragment from "./rules/avoid-shorthand-fragment"; -import forwardRefUsingRef from "./rules/ensure-forward-ref-using-ref"; -import noAccessStateInSetstate from "./rules/no-access-state-in-setstate"; -import noArrayIndexKey from "./rules/no-array-index-key"; -import noChildrenCount from "./rules/no-children-count"; -import noChildrenForEach from "./rules/no-children-for-each"; -import noChildrenMap from "./rules/no-children-map"; -import noChildrenOnly from "./rules/no-children-only"; -import noChildrenProp from "./rules/no-children-prop"; -import noChildrenToArray from "./rules/no-children-to-array"; -import noClassComponent from "./rules/no-class-component"; -import noCloneElement from "./rules/no-clone-element"; -import noCommentTextnodes from "./rules/no-comment-textnodes"; -import noComplexConditionalRendering from "./rules/no-complex-conditional-rendering"; -import noComponentWillMount from "./rules/no-component-will-mount"; -import noComponentWillReceiveProps from "./rules/no-component-will-receive-props"; -import noComponentWillUpdate from "./rules/no-component-will-update"; -import noContextProvider from "./rules/no-context-provider"; -import noCreateRef from "./rules/no-create-ref"; -import noDefaultProps from "./rules/no-default-props"; -import noDirectMutationState from "./rules/no-direct-mutation-state"; -import noDuplicateJsxProps from "./rules/no-duplicate-jsx-props"; -import noDuplicateKey from "./rules/no-duplicate-key"; -import noForwardRef from "./rules/no-forward-ref"; -import noImplicitKey from "./rules/no-implicit-key"; -import noLeakedConditionalRendering from "./rules/no-leaked-conditional-rendering"; -import noMissingComponentDisplayName from "./rules/no-missing-component-display-name"; -import noMissingKey from "./rules/no-missing-key"; -import noNestedComponents from "./rules/no-nested-components"; -import noPropTypes from "./rules/no-prop-types"; -import noRedundantShouldComponentUpdate from "./rules/no-redundant-should-component-update"; -import noSetStateInComponentDidMount from "./rules/no-set-state-in-component-did-mount"; -import noSetStateInComponentDidUpdate from "./rules/no-set-state-in-component-did-update"; -import noSetStateInComponentWillUpdate from "./rules/no-set-state-in-component-will-update"; -import noStringRefs from "./rules/no-string-refs"; -import noUnsafeComponentWillMount from "./rules/no-unsafe-component-will-mount"; -import noUnsafeComponentWillReceiveProps from "./rules/no-unsafe-component-will-receive-props"; -import noUnsafeComponentWillUpdate from "./rules/no-unsafe-component-will-update"; -import noUnstableContextValue from "./rules/no-unstable-context-value"; -import noUnstableDefaultProps from "./rules/no-unstable-default-props"; -import noUnusedClassComponentMembers from "./rules/no-unused-class-component-members"; -import noUnusedState from "./rules/no-unused-state"; -import noUseContext from "./rules/no-use-context"; -import noUselessFragment from "./rules/no-useless-fragment"; -import preferDestructuringAssignment from "./rules/prefer-destructuring-assignment"; -import preferReactNamespaceImport from "./rules/prefer-react-namespace-import"; -import preferReadOnlyProps from "./rules/prefer-read-only-props"; -import preferShorthandBoolean from "./rules/prefer-shorthand-boolean"; -import preferShorthandFragment from "./rules/prefer-shorthand-fragment"; -import useJsxVars from "./rules/use-jsx-vars"; +import type { RulePreset } from "@eslint-react/shared"; -export default { - meta: { - name, - version, - }, - rules: { - "avoid-shorthand-boolean": avoidShorthandBoolean, - "avoid-shorthand-fragment": avoidShorthandFragment, - "ensure-forward-ref-using-ref": forwardRefUsingRef, - "no-access-state-in-setstate": noAccessStateInSetstate, - "no-array-index-key": noArrayIndexKey, - "no-children-count": noChildrenCount, - "no-children-for-each": noChildrenForEach, - "no-children-map": noChildrenMap, - "no-children-only": noChildrenOnly, - "no-children-prop": noChildrenProp, - "no-children-to-array": noChildrenToArray, - "no-class-component": noClassComponent, - "no-clone-element": noCloneElement, - "no-comment-textnodes": noCommentTextnodes, - "no-complex-conditional-rendering": noComplexConditionalRendering, - "no-component-will-mount": noComponentWillMount, - "no-component-will-receive-props": noComponentWillReceiveProps, - "no-component-will-update": noComponentWillUpdate, - "no-context-provider": noContextProvider, - "no-create-ref": noCreateRef, - "no-default-props": noDefaultProps, - "no-direct-mutation-state": noDirectMutationState, - "no-duplicate-jsx-props": noDuplicateJsxProps, - "no-duplicate-key": noDuplicateKey, - "no-forward-ref": noForwardRef, - "no-implicit-key": noImplicitKey, - "no-leaked-conditional-rendering": noLeakedConditionalRendering, - "no-missing-component-display-name": noMissingComponentDisplayName, - "no-missing-key": noMissingKey, - "no-nested-components": noNestedComponents, - "no-prop-types": noPropTypes, - "no-redundant-should-component-update": noRedundantShouldComponentUpdate, - "no-set-state-in-component-did-mount": noSetStateInComponentDidMount, - "no-set-state-in-component-did-update": noSetStateInComponentDidUpdate, - "no-set-state-in-component-will-update": noSetStateInComponentWillUpdate, - "no-string-refs": noStringRefs, - "no-unsafe-component-will-mount": noUnsafeComponentWillMount, - "no-unsafe-component-will-receive-props": noUnsafeComponentWillReceiveProps, - "no-unsafe-component-will-update": noUnsafeComponentWillUpdate, - "no-unstable-context-value": noUnstableContextValue, - "no-unstable-default-props": noUnstableDefaultProps, - "no-unused-class-component-members": noUnusedClassComponentMembers, - "no-unused-state": noUnusedState, - "no-use-context": noUseContext, - "no-useless-fragment": noUselessFragment, - "prefer-destructuring-assignment": preferDestructuringAssignment, - "prefer-react-namespace-import": preferReactNamespaceImport, - "prefer-read-only-props": preferReadOnlyProps, - "prefer-shorthand-boolean": preferShorthandBoolean, - "prefer-shorthand-fragment": preferShorthandFragment, - "use-jsx-vars": useJsxVars, +import * as recommendedConfig from "./configs/recommended"; +import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checked"; +import * as recommendedTypeScriptConfig from "./configs/recommended-typescript"; +import { plugin } from "./plugin"; + +function makeConfig(config: { name: string; rules: RulePreset }) { + return { + ...config, + plugins: { + "react-x": plugin, + }, + }; +} - // Part: deprecated rules - /** @deprecated Use `no-duplicate-jsx-props` instead. */ - "jsx-no-duplicate-props": noDuplicateJsxProps, - /** @deprecated Use `use-jsx-vars` instead. */ - "jsx-uses-vars": useJsxVars, - /** @deprecated Use `no-complex-conditional-rendering` instead. */ - "no-complicated-conditional-rendering": noComplexConditionalRendering, +function makeLegacyConfig(config: { rules: RulePreset }) { + return { + plugins: ["react-x"], + rules: config.rules, + }; +} + +export default { + ...plugin, + configs: { + ["recommended"]: makeConfig(recommendedConfig), + ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), + ["recommended-type-checked"]: makeConfig(recommendedTypeCheckedConfig), + ["recommended-type-checked-legacy"]: makeLegacyConfig(recommendedTypeCheckedConfig), + ["recommended-typescript"]: makeConfig(recommendedTypeScriptConfig), + ["recommended-typescript-legacy"]: makeLegacyConfig(recommendedTypeScriptConfig), }, }; diff --git a/packages/plugins/eslint-plugin-react-x/src/plugin.ts b/packages/plugins/eslint-plugin-react-x/src/plugin.ts new file mode 100644 index 000000000..b6cbfa971 --- /dev/null +++ b/packages/plugins/eslint-plugin-react-x/src/plugin.ts @@ -0,0 +1,120 @@ +import { name, version } from "../package.json"; +import avoidShorthandBoolean from "./rules/avoid-shorthand-boolean"; +import avoidShorthandFragment from "./rules/avoid-shorthand-fragment"; +import forwardRefUsingRef from "./rules/ensure-forward-ref-using-ref"; +import noAccessStateInSetstate from "./rules/no-access-state-in-setstate"; +import noArrayIndexKey from "./rules/no-array-index-key"; +import noChildrenCount from "./rules/no-children-count"; +import noChildrenForEach from "./rules/no-children-for-each"; +import noChildrenMap from "./rules/no-children-map"; +import noChildrenOnly from "./rules/no-children-only"; +import noChildrenProp from "./rules/no-children-prop"; +import noChildrenToArray from "./rules/no-children-to-array"; +import noClassComponent from "./rules/no-class-component"; +import noCloneElement from "./rules/no-clone-element"; +import noCommentTextnodes from "./rules/no-comment-textnodes"; +import noComplexConditionalRendering from "./rules/no-complex-conditional-rendering"; +import noComponentWillMount from "./rules/no-component-will-mount"; +import noComponentWillReceiveProps from "./rules/no-component-will-receive-props"; +import noComponentWillUpdate from "./rules/no-component-will-update"; +import noContextProvider from "./rules/no-context-provider"; +import noCreateRef from "./rules/no-create-ref"; +import noDefaultProps from "./rules/no-default-props"; +import noDirectMutationState from "./rules/no-direct-mutation-state"; +import noDuplicateJsxProps from "./rules/no-duplicate-jsx-props"; +import noDuplicateKey from "./rules/no-duplicate-key"; +import noForwardRef from "./rules/no-forward-ref"; +import noImplicitKey from "./rules/no-implicit-key"; +import noLeakedConditionalRendering from "./rules/no-leaked-conditional-rendering"; +import noMissingComponentDisplayName from "./rules/no-missing-component-display-name"; +import noMissingKey from "./rules/no-missing-key"; +import noNestedComponents from "./rules/no-nested-components"; +import noPropTypes from "./rules/no-prop-types"; +import noRedundantShouldComponentUpdate from "./rules/no-redundant-should-component-update"; +import noSetStateInComponentDidMount from "./rules/no-set-state-in-component-did-mount"; +import noSetStateInComponentDidUpdate from "./rules/no-set-state-in-component-did-update"; +import noSetStateInComponentWillUpdate from "./rules/no-set-state-in-component-will-update"; +import noStringRefs from "./rules/no-string-refs"; +import noUnsafeComponentWillMount from "./rules/no-unsafe-component-will-mount"; +import noUnsafeComponentWillReceiveProps from "./rules/no-unsafe-component-will-receive-props"; +import noUnsafeComponentWillUpdate from "./rules/no-unsafe-component-will-update"; +import noUnstableContextValue from "./rules/no-unstable-context-value"; +import noUnstableDefaultProps from "./rules/no-unstable-default-props"; +import noUnusedClassComponentMembers from "./rules/no-unused-class-component-members"; +import noUnusedState from "./rules/no-unused-state"; +import noUseContext from "./rules/no-use-context"; +import noUselessFragment from "./rules/no-useless-fragment"; +import preferDestructuringAssignment from "./rules/prefer-destructuring-assignment"; +import preferReactNamespaceImport from "./rules/prefer-react-namespace-import"; +import preferReadOnlyProps from "./rules/prefer-read-only-props"; +import preferShorthandBoolean from "./rules/prefer-shorthand-boolean"; +import preferShorthandFragment from "./rules/prefer-shorthand-fragment"; +import useJsxVars from "./rules/use-jsx-vars"; + +export const plugin = { + meta: { + name, + version, + }, + rules: { + "avoid-shorthand-boolean": avoidShorthandBoolean, + "avoid-shorthand-fragment": avoidShorthandFragment, + "ensure-forward-ref-using-ref": forwardRefUsingRef, + "no-access-state-in-setstate": noAccessStateInSetstate, + "no-array-index-key": noArrayIndexKey, + "no-children-count": noChildrenCount, + "no-children-for-each": noChildrenForEach, + "no-children-map": noChildrenMap, + "no-children-only": noChildrenOnly, + "no-children-prop": noChildrenProp, + "no-children-to-array": noChildrenToArray, + "no-class-component": noClassComponent, + "no-clone-element": noCloneElement, + "no-comment-textnodes": noCommentTextnodes, + "no-complex-conditional-rendering": noComplexConditionalRendering, + "no-component-will-mount": noComponentWillMount, + "no-component-will-receive-props": noComponentWillReceiveProps, + "no-component-will-update": noComponentWillUpdate, + "no-context-provider": noContextProvider, + "no-create-ref": noCreateRef, + "no-default-props": noDefaultProps, + "no-direct-mutation-state": noDirectMutationState, + "no-duplicate-jsx-props": noDuplicateJsxProps, + "no-duplicate-key": noDuplicateKey, + "no-forward-ref": noForwardRef, + "no-implicit-key": noImplicitKey, + "no-leaked-conditional-rendering": noLeakedConditionalRendering, + "no-missing-component-display-name": noMissingComponentDisplayName, + "no-missing-key": noMissingKey, + "no-nested-components": noNestedComponents, + "no-prop-types": noPropTypes, + "no-redundant-should-component-update": noRedundantShouldComponentUpdate, + "no-set-state-in-component-did-mount": noSetStateInComponentDidMount, + "no-set-state-in-component-did-update": noSetStateInComponentDidUpdate, + "no-set-state-in-component-will-update": noSetStateInComponentWillUpdate, + "no-string-refs": noStringRefs, + "no-unsafe-component-will-mount": noUnsafeComponentWillMount, + "no-unsafe-component-will-receive-props": noUnsafeComponentWillReceiveProps, + "no-unsafe-component-will-update": noUnsafeComponentWillUpdate, + "no-unstable-context-value": noUnstableContextValue, + "no-unstable-default-props": noUnstableDefaultProps, + "no-unused-class-component-members": noUnusedClassComponentMembers, + "no-unused-state": noUnusedState, + "no-use-context": noUseContext, + "no-useless-fragment": noUselessFragment, + "prefer-destructuring-assignment": preferDestructuringAssignment, + "prefer-react-namespace-import": preferReactNamespaceImport, + "prefer-read-only-props": preferReadOnlyProps, + "prefer-shorthand-boolean": preferShorthandBoolean, + "prefer-shorthand-fragment": preferShorthandFragment, + "use-jsx-vars": useJsxVars, + + // Part: deprecated rules + /** @deprecated Use `no-duplicate-jsx-props` instead. */ + "jsx-no-duplicate-props": noDuplicateJsxProps, + /** @deprecated Use `use-jsx-vars` instead. */ + "jsx-uses-vars": useJsxVars, + /** @deprecated Use `no-complex-conditional-rendering` instead. */ + "no-complicated-conditional-rendering": noComplexConditionalRendering, + }, +} as const; diff --git a/packages/plugins/eslint-plugin/src/configs/core.ts b/packages/plugins/eslint-plugin/src/configs/core.ts index 7e83aa7a9..737ec666c 100644 --- a/packages/plugins/eslint-plugin/src/configs/core.ts +++ b/packages/plugins/eslint-plugin/src/configs/core.ts @@ -1,6 +1,6 @@ import type { RulePreset } from "@eslint-react/shared"; import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared"; -import react from "eslint-plugin-react-x"; +import reactx from "eslint-plugin-react-x"; export const name = "@eslint-react/core"; @@ -46,7 +46,7 @@ export const rules = { } as const satisfies RulePreset; export const plugins = { - "@eslint-react": react, + "@eslint-react": reactx, }; export const settings = { diff --git a/packages/plugins/eslint-plugin/src/index.ts b/packages/plugins/eslint-plugin/src/index.ts index e5c273dfe..0389b243d 100644 --- a/packages/plugins/eslint-plugin/src/index.ts +++ b/packages/plugins/eslint-plugin/src/index.ts @@ -21,17 +21,10 @@ import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checke import * as recommendedTypeScriptConfig from "./configs/recommended-typescript"; import { padKeysLeft } from "./utils"; -type Config = { - name: string; - rules: RulePreset; -}; - -function makeLegacyConfig(config: A) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { name: drop, ...rest } = config; +function toLegacyConfig(config: { rules: RulePreset }) { return { - ...rest, plugins: ["@eslint-react"], + rules: config.rules, }; } @@ -42,35 +35,34 @@ export default { }, configs: { ["all"]: allConfig, + ["all-legacy"]: toLegacyConfig(allConfig), ["core"]: coreConfig, + ["core-legacy"]: toLegacyConfig(coreConfig), ["debug"]: debugConfig, + ["debug-legacy"]: toLegacyConfig(debugConfig), ["disable-debug"]: disableDebugConfig, + ["disable-debug-legacy"]: toLegacyConfig(disableDebugConfig), ["disable-dom"]: disableDomConfig, + ["disable-dom-legacy"]: toLegacyConfig(disableDomConfig), ["disable-type-checked"]: disableTypeCheckedConfig, + ["disable-type-checked-legacy"]: toLegacyConfig(disableTypeCheckedConfig), ["disable-web-api"]: disableWebApiConfig, + ["disable-web-api-legacy"]: toLegacyConfig(disableWebApiConfig), ["dom"]: domConfig, + ["dom-legacy"]: toLegacyConfig(domConfig), ["off"]: offConfig, + ["off-legacy"]: toLegacyConfig(offConfig), ["recommended"]: recommendedConfig, + ["recommended-legacy"]: toLegacyConfig(recommendedConfig), ["recommended-type-checked"]: recommendedTypeCheckedConfig, + ["recommended-type-checked-legacy"]: toLegacyConfig(recommendedTypeCheckedConfig), ["recommended-typescript"]: recommendedTypeScriptConfig, - // Part: legacy presets - ["all-legacy"]: makeLegacyConfig(allConfig), - ["core-legacy"]: makeLegacyConfig(coreConfig), - ["debug-legacy"]: makeLegacyConfig(debugConfig), - ["disable-debug-legacy"]: makeLegacyConfig(disableDebugConfig), - ["disable-dom-legacy"]: makeLegacyConfig(disableDomConfig), - ["disable-type-checked-legacy"]: makeLegacyConfig(disableTypeCheckedConfig), - ["disable-web-api-legacy"]: makeLegacyConfig(disableWebApiConfig), - ["dom-legacy"]: makeLegacyConfig(domConfig), - ["off-legacy"]: makeLegacyConfig(offConfig), - ["recommended-legacy"]: makeLegacyConfig(recommendedConfig), - ["recommended-type-checked-legacy"]: makeLegacyConfig(recommendedTypeCheckedConfig), - ["recommended-typescript-legacy"]: makeLegacyConfig(recommendedTypeScriptConfig), + ["recommended-typescript-legacy"]: toLegacyConfig(recommendedTypeScriptConfig), // Part: deprecated presets /** @deprecated Use `disable-dom` instead */ ["off-dom"]: disableDomConfig, /** @deprecated Use `disable-dom-legacy` instead */ - ["off-dom-legacy"]: makeLegacyConfig(disableDomConfig), + ["off-dom-legacy"]: toLegacyConfig(disableDomConfig), }, rules: { ...react.rules, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f4ac2d65..f830e6d48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,18 +5,18 @@ settings: excludeLinksFromLockfile: false overrides: - is-core-module: npm:@socketregistry/is-core-module@^1.0.7 - safe-buffer: npm:@socketregistry/safe-buffer@^1.0.6 - safer-buffer: npm:@socketregistry/safer-buffer@^1.0.6 - typedarray: npm:@socketregistry/typedarray@^1.0.5 '@types/react': ^19.0.10 '@types/react-dom': ^19.0.4 cross-spawn: ^7.0.6 esbuild: ^0.25.0 + is-core-module: npm:@socketregistry/is-core-module@^1.0.7 next: ^15.1.7 react: ^19.0.0 react-dom: ^19.0.0 + safe-buffer: npm:@socketregistry/safe-buffer@^1.0.6 + safer-buffer: npm:@socketregistry/safer-buffer@^1.0.6 ts-api-utils: ^2.0.1 + typedarray: npm:@socketregistry/typedarray@^1.0.5 typescript: ^5.7.3 importers: @@ -390,9 +390,6 @@ importers: examples/dual-react-dom-lib: devDependencies: - '@eslint-react/eslint-plugin': - specifier: workspace:* - version: link:../../packages/plugins/eslint-plugin '@eslint/js': specifier: ^9.20.0 version: 9.20.0 @@ -411,9 +408,24 @@ importers: eslint: specifier: ^9.20.1 version: 9.20.1(jiti@2.4.2) + eslint-plugin-react-dom: + specifier: workspace:* + version: link:../../packages/plugins/eslint-plugin-react-dom eslint-plugin-react-hooks: specifier: ^5.1.0 version: 5.1.0(eslint@9.20.1(jiti@2.4.2)) + eslint-plugin-react-hooks-extra: + specifier: workspace:* + version: link:../../packages/plugins/eslint-plugin-react-hooks-extra + eslint-plugin-react-naming-convention: + specifier: workspace:* + version: link:../../packages/plugins/eslint-plugin-react-naming-convention + eslint-plugin-react-web-api: + specifier: workspace:* + version: link:../../packages/plugins/eslint-plugin-react-web-api + eslint-plugin-react-x: + specifier: workspace:* + version: link:../../packages/plugins/eslint-plugin-react-x eslint-plugin-vitest: specifier: ^0.5.4 version: 0.5.4(eslint@9.20.1(jiti@2.4.2))(typescript@5.7.3)(vitest@3.0.6)