From 8fb3970daaca13d960cb26defade64e0ba6c6a6b Mon Sep 17 00:00:00 2001 From: Rel1cx Date: Wed, 13 Aug 2025 14:28:51 +0800 Subject: [PATCH] fix: export 'react-x/no-forbidden-props' rule and add it to rules overview page --- .pkgs/configs/package.json | 2 +- .pkgs/eslint-plugin-local/package.json | 2 +- apps/website/content/docs/rules/meta.json | 1 + apps/website/content/docs/rules/overview.mdx | 1 + .../rspeedy-react-lynx-app/lynx.config.ts | 2 - examples/rspeedy-react-lynx-app/package.json | 4 +- examples/rspeedy-react-lynx-app/src/App.css | 3 -- examples/rspeedy-react-lynx-app/src/App.tsx | 11 +++-- .../rspeedy-react-lynx-app/tailwind.config.js | 7 ---- .../eslint-plugin-react-x/src/plugin.ts | 2 + .../src/rules/no-forbidden-props.ts | 7 ++-- pnpm-lock.yaml | 40 ++++--------------- 12 files changed, 23 insertions(+), 59 deletions(-) delete mode 100644 examples/rspeedy-react-lynx-app/tailwind.config.js diff --git a/.pkgs/configs/package.json b/.pkgs/configs/package.json index b01a7f8b90..3fb2a05c81 100644 --- a/.pkgs/configs/package.json +++ b/.pkgs/configs/package.json @@ -23,7 +23,7 @@ "@stylistic/eslint-plugin": "^5.2.3", "eslint-plugin-de-morgan": "^1.3.1", "eslint-plugin-function": "^0.0.22", - "eslint-plugin-jsdoc": "^53.0.1", + "eslint-plugin-jsdoc": "^54.0.0", "eslint-plugin-perfectionist": "^4.15.0", "eslint-plugin-regexp": "^2.10.0", "eslint-plugin-unicorn": "^60.0.0", diff --git a/.pkgs/eslint-plugin-local/package.json b/.pkgs/eslint-plugin-local/package.json index cff8d1f7df..5be971870d 100644 --- a/.pkgs/eslint-plugin-local/package.json +++ b/.pkgs/eslint-plugin-local/package.json @@ -33,7 +33,7 @@ "@typescript-eslint/types": "^8.39.1", "@typescript-eslint/utils": "^8.39.1", "eslint-plugin-de-morgan": "^1.3.1", - "eslint-plugin-jsdoc": "^53.0.1", + "eslint-plugin-jsdoc": "^54.0.0", "eslint-plugin-perfectionist": "^4.15.0", "eslint-plugin-regexp": "^2.10.0", "eslint-plugin-unicorn": "^60.0.0", diff --git a/apps/website/content/docs/rules/meta.json b/apps/website/content/docs/rules/meta.json index cbe0000694..7f33a02f12 100644 --- a/apps/website/content/docs/rules/meta.json +++ b/apps/website/content/docs/rules/meta.json @@ -31,6 +31,7 @@ "no-direct-set-state-in-use-effect", "no-direct-set-state-in-use-layout-effect", "no-duplicate-key", + "no-forbidden-props", "no-forward-ref", "no-implicit-key", "no-leaked-conditional-rendering", diff --git a/apps/website/content/docs/rules/overview.mdx b/apps/website/content/docs/rules/overview.mdx index 39a3d598ff..a584b5c5ec 100644 --- a/apps/website/content/docs/rules/overview.mdx +++ b/apps/website/content/docs/rules/overview.mdx @@ -58,6 +58,7 @@ The `jsx-*` rules check for issues exclusive to JSX syntax, which are absent fro | [`no-default-props`](./no-default-props) | 2️⃣ | | Disallow `defaultProps` property in favor of ES6 default parameters | | | [`no-direct-mutation-state`](./no-direct-mutation-state) | 2️⃣ | | Disallow direct mutation of `this.state` | | | [`no-duplicate-key`](./no-duplicate-key) | 2️⃣ | | Disallow duplicate `key` on elements in the same array or a list of `children` | | +| [`no-forbidden-props`](./no-forbidden-props) | 1️⃣ | `🔧` | Disallow certain props on components | | | [`no-forward-ref`](./no-forward-ref) | 1️⃣ | `🔄` | Replaces usages of `forwardRef` with passing `ref` as a prop | >=19.0.0 | | [`no-implicit-key`](./no-implicit-key) | 1️⃣ | `🧪` | Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects) | | | [`no-leaked-conditional-rendering`](./no-leaked-conditional-rendering) | 1️⃣ | `💭` | Prevents problematic leaked values from being rendered | | diff --git a/examples/rspeedy-react-lynx-app/lynx.config.ts b/examples/rspeedy-react-lynx-app/lynx.config.ts index 922d82558a..b2df0a6ebc 100644 --- a/examples/rspeedy-react-lynx-app/lynx.config.ts +++ b/examples/rspeedy-react-lynx-app/lynx.config.ts @@ -2,13 +2,11 @@ import { pluginQRCode } from "@lynx-js/qrcode-rsbuild-plugin"; import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin"; import { defineConfig } from "@lynx-js/rspeedy"; import { pluginTypeCheck } from "@rsbuild/plugin-type-check"; -import { pluginTailwindCSS } from "rsbuild-plugin-tailwindcss"; export default defineConfig({ plugins: [ pluginReactLynx(), pluginQRCode(), - pluginTailwindCSS(), pluginTypeCheck(), ], environments: { diff --git a/examples/rspeedy-react-lynx-app/package.json b/examples/rspeedy-react-lynx-app/package.json index 1c655d88a8..c131bf0eef 100644 --- a/examples/rspeedy-react-lynx-app/package.json +++ b/examples/rspeedy-react-lynx-app/package.json @@ -20,7 +20,6 @@ "devDependencies": { "@eslint/config-inspector": "^1.1.0", "@eslint/js": "^9.33.0", - "@lynx-contrib/tailwind-preset": "^0.0.2", "@lynx-js/qrcode-rsbuild-plugin": "^0.4.0", "@lynx-js/react-rsbuild-plugin": "^0.10.11", "@lynx-js/rspeedy": "^0.10.6", @@ -29,7 +28,6 @@ "@rsbuild/plugin-type-check": "^1.2.4", "@types/react": "^19.1.10", "eslint-plugin-react-hooks": "^5.2.0", - "eslint-plugin-react-x": "workspace:*", - "rsbuild-plugin-tailwindcss": "^0.2.3" + "eslint-plugin-react-x": "workspace:*" } } diff --git a/examples/rspeedy-react-lynx-app/src/App.css b/examples/rspeedy-react-lynx-app/src/App.css index b5c61c9567..e69de29bb2 100644 --- a/examples/rspeedy-react-lynx-app/src/App.css +++ b/examples/rspeedy-react-lynx-app/src/App.css @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; diff --git a/examples/rspeedy-react-lynx-app/src/App.tsx b/examples/rspeedy-react-lynx-app/src/App.tsx index c5e8d4210e..906d34e57b 100644 --- a/examples/rspeedy-react-lynx-app/src/App.tsx +++ b/examples/rspeedy-react-lynx-app/src/App.tsx @@ -7,26 +7,25 @@ export function App() { return ( - - + + ReactLynx + TailwindCSS - + Start building amazing things with ReactLynx. - + Count: {count} - + 01 02 03 diff --git a/examples/rspeedy-react-lynx-app/tailwind.config.js b/examples/rspeedy-react-lynx-app/tailwind.config.js deleted file mode 100644 index b69032abfe..0000000000 --- a/examples/rspeedy-react-lynx-app/tailwind.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import preset from "@lynx-contrib/tailwind-preset"; - -export default { - presets: [ - preset, - ], -}; diff --git a/packages/plugins/eslint-plugin-react-x/src/plugin.ts b/packages/plugins/eslint-plugin-react-x/src/plugin.ts index 5df3b29b6a..d6547bf57b 100644 --- a/packages/plugins/eslint-plugin-react-x/src/plugin.ts +++ b/packages/plugins/eslint-plugin-react-x/src/plugin.ts @@ -27,6 +27,7 @@ import noCreateRef from "./rules/no-create-ref"; import noDefaultProps from "./rules/no-default-props"; import noDirectMutationState from "./rules/no-direct-mutation-state"; import noDuplicateKey from "./rules/no-duplicate-key"; +import noForbiddenProps from "./rules/no-forbidden-props"; import noForwardRef from "./rules/no-forward-ref"; import noImplicitKey from "./rules/no-implicit-key"; import noLeakedConditionalRendering from "./rules/no-leaked-conditional-rendering"; @@ -104,6 +105,7 @@ export const plugin = { "no-default-props": noDefaultProps, "no-direct-mutation-state": noDirectMutationState, "no-duplicate-key": noDuplicateKey, + "no-forbidden-props": noForbiddenProps, "no-forward-ref": noForwardRef, "no-implicit-key": noImplicitKey, "no-leaked-conditional-rendering": noLeakedConditionalRendering, diff --git a/packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.ts b/packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.ts index e83806252e..67295fe08b 100644 --- a/packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.ts +++ b/packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.ts @@ -1,5 +1,5 @@ import type { RuleListener } from "@typescript-eslint/utils/ts-eslint"; -import { type RuleContext, type RuleFeature, RegExp } from "@eslint-react/kit"; +import { RegExp as RE, type RuleContext, type RuleFeature } from "@eslint-react/kit"; import { AST_NODE_TYPES as T } from "@typescript-eslint/types"; import { camelCase, type CamelCase } from "string-ts"; @@ -8,7 +8,9 @@ import { createRule } from "../utils"; export const RULE_NAME = "no-forbidden-props"; export const RULE_FEATURES = ["CFG"] as const satisfies RuleFeature[]; + export type MessageID = CamelCase; + const messageId = camelCase(RULE_NAME); type Options = readonly [ @@ -113,7 +115,7 @@ export function create(context: RuleContext, [option]: Optio } const forbiddenProp = typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop; - const forbiddenPropRegExp = RegExp.toRegExp(forbiddenProp); + const forbiddenPropRegExp = RE.toRegExp(forbiddenProp); if (forbiddenPropRegExp.test(name)) { context.report({ messageId, @@ -121,7 +123,6 @@ export function create(context: RuleContext, [option]: Optio data: { name }, }); } - } } }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9330d5d06..4aa503d4ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -167,8 +167,8 @@ importers: specifier: ^0.0.22 version: 0.0.22(eslint@9.33.0(jiti@2.5.1))(ts-api-utils@2.1.0(typescript@5.9.2))(typescript@5.9.2) eslint-plugin-jsdoc: - specifier: ^53.0.1 - version: 53.0.1(eslint@9.33.0(jiti@2.5.1)) + specifier: ^54.0.0 + version: 54.0.0(eslint@9.33.0(jiti@2.5.1)) eslint-plugin-perfectionist: specifier: ^4.15.0 version: 4.15.0(eslint@9.33.0(jiti@2.5.1))(typescript@5.9.2) @@ -224,8 +224,8 @@ importers: specifier: ^1.3.1 version: 1.3.1(eslint@9.33.0(jiti@2.5.1)) eslint-plugin-jsdoc: - specifier: ^53.0.1 - version: 53.0.1(eslint@9.33.0(jiti@2.5.1)) + specifier: ^54.0.0 + version: 54.0.0(eslint@9.33.0(jiti@2.5.1)) eslint-plugin-perfectionist: specifier: ^4.15.0 version: 4.15.0(eslint@9.33.0(jiti@2.5.1))(typescript@5.9.2) @@ -485,9 +485,6 @@ importers: '@eslint/js': specifier: ^9.33.0 version: 9.33.0 - '@lynx-contrib/tailwind-preset': - specifier: ^0.0.2 - version: 0.0.2 '@lynx-js/qrcode-rsbuild-plugin': specifier: ^0.4.0 version: 0.4.0 @@ -515,9 +512,6 @@ importers: eslint-plugin-react-x: specifier: workspace:* version: link:../../packages/plugins/eslint-plugin-react-x - rsbuild-plugin-tailwindcss: - specifier: ^0.2.3 - version: 0.2.3(@rsbuild/core@1.4.15)(tailwindcss@4.1.11) examples/vite-react-dom-app: dependencies: @@ -2746,9 +2740,6 @@ packages: peerDependencies: tslib: ^2.8.1 - '@lynx-contrib/tailwind-preset@0.0.2': - resolution: {integrity: sha512-lVLCvsiM/V6SpoAdH3EP3v8P0lA1wgznPRFGoRxqI+YK7yRfrlOpgQxM3eMnKwCl8Nl2TIyd8/PDtJQCiLDojA==} - '@lynx-js/chunk-loading-webpack-plugin@0.3.0': resolution: {integrity: sha512-otZBLgYR3FK1aLpKIuLjZugZRG1QeUchilvSEl5iLkZn9X6mYeURf+DtURtPEcXUyq7Qjn6IXAE0y98EdiiwdQ==} engines: {node: '>=18'} @@ -5849,8 +5840,8 @@ packages: ts-api-utils: ^2.1.0 typescript: ^5.9.2 - eslint-plugin-jsdoc@53.0.1: - resolution: {integrity: sha512-9gYQy6pXAHnJXPFMATQS56O3js39okRrve61VlaXhKyaa9dZuuvTlReStF3eQ+ygG5vybFl7YTw6MkYkrf2GUQ==} + eslint-plugin-jsdoc@54.0.0: + resolution: {integrity: sha512-8w5c8OmmD5WD5MNQy1AhmYbiyV4IlSscXUyg5MwvN3BI/bLUmRpeEXc+Mj37y2UZsLhzvHyCscQenUzvbLxQ7Q==} engines: {node: '>=20.11.0'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 @@ -8121,15 +8112,6 @@ packages: roughjs@4.6.6: resolution: {integrity: sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==} - rsbuild-plugin-tailwindcss@0.2.3: - resolution: {integrity: sha512-UUARLNjMHLNQXvZ7JTVXES41KznawRIJKULt+ZLDBvzOV7buE0BrBYOSlP+r+7SYn8kcvtwdM9TANpOlNwHvZQ==} - peerDependencies: - '@rsbuild/core': ^1.1.0 - tailwindcss: ^3.1.0 - peerDependenciesMeta: - '@rsbuild/core': - optional: true - rslog@1.2.11: resolution: {integrity: sha512-YgMMzQf6lL9q4rD9WS/lpPWxVNJ1ttY9+dOXJ0+7vJrKCAOT4GH0EiRnBi9mKOitcHiOwjqJPV1n/HRqqgZmOQ==} @@ -10678,8 +10660,6 @@ snapshots: '@jsonjoy.com/codegen': 1.0.0(tslib@2.8.1) tslib: 2.8.1 - '@lynx-contrib/tailwind-preset@0.0.2': {} - '@lynx-js/chunk-loading-webpack-plugin@0.3.0(@rspack/core@1.4.11(@swc/helpers@0.5.17))': dependencies: '@lynx-js/webpack-runtime-globals': 0.0.5 @@ -14029,7 +14009,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-jsdoc@53.0.1(eslint@9.33.0(jiti@2.5.1)): + eslint-plugin-jsdoc@54.0.0(eslint@9.33.0(jiti@2.5.1)): dependencies: '@es-joy/jsdoccomment': 0.52.0 are-docs-informative: 0.0.2 @@ -16813,12 +16793,6 @@ snapshots: points-on-curve: 0.2.0 points-on-path: 0.2.1 - rsbuild-plugin-tailwindcss@0.2.3(@rsbuild/core@1.4.15)(tailwindcss@4.1.11): - dependencies: - tailwindcss: 4.1.11 - optionalDependencies: - '@rsbuild/core': 1.4.15 - rslog@1.2.11: {} run-applescript@7.0.0: {}