Skip to content

Commit d089bee

Browse files
authored
Deprecate react-x/no-forbidden-props rule (#1304)
1 parent 9712cbd commit d089bee

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

apps/website/content/docs/removed.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ full: true
1414
| `react-x/jsx-no-duplicate-props` | [`react-x/jsx-no-duplicate-props`](/docs/rules/jsx-no-duplicate-props) | 2.0.0 | renamed |
1515
| `react-x/no-comment-textnodes` | [`react-x/jsx-no-comment-textnodes`](/docs/rules/jsx-no-comment-textnodes) | 2.0.0 | renamed |
1616
| `react-x/no-complicated-conditional-rendering` | | 2.0.0 | discontinued |
17+
| `react-x/no-forbidden-props` | | 2.3.1 | deprecated |
1718
| `react-x/no-nested-components` | [`react-x/no-nested-component-definitions`](/docs/rules/no-nested-component-definitions) | 2.0.0 | renamed |
1819
| `react-x/prefer-react-namespace-import` | [`react-x/prefer-namespace-import`](/docs/rules/prefer-namespace-import) | 2.0.0 | renamed |
1920
| `react-x/prefer-shorthand-boolean` | [`react-x/jsx-shorthand-boolean`](/docs/rules/jsx-shorthand-boolean) | 2.0.0 | consolidated |

apps/website/content/docs/rules/overview.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ full: true
5555
| [`no-default-props`](./no-default-props) | 2️⃣ 2️⃣ | | Disallow `defaultProps` property in favor of ES6 default parameters | |
5656
| [`no-direct-mutation-state`](./no-direct-mutation-state) | 2️⃣ 2️⃣ | | Disallow direct mutation of `this.state` | |
5757
| [`no-duplicate-key`](./no-duplicate-key) | 2️⃣ 2️⃣ | | Disallow duplicate `key` on elements in the same array or a list of `children` | |
58-
| [`no-forbidden-props`](./no-forbidden-props) | 1️⃣ 1️⃣ | `🔧` | Disallow certain props on components | |
5958
| [`no-forward-ref`](./no-forward-ref) | 1️⃣ 1️⃣ | `🔄` | Replaces usages of `forwardRef` with passing `ref` as a prop | >=19.0.0 |
6059
| [`no-implicit-key`](./no-implicit-key) | 1️⃣ 1️⃣ | `🧪` | Prevents `key` from not being explicitly specified (e.g. spreading `key` from objects) | |
6160
| [`no-leaked-conditional-rendering`](./no-leaked-conditional-rendering) | 1️⃣ 1️⃣ | `💭` | Prevents problematic leaked values from being rendered | |

packages/plugins/eslint-plugin-react-x/src/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export const plugin: CompatiblePlugin = {
100100
"no-default-props": noDefaultProps,
101101
"no-direct-mutation-state": noDirectMutationState,
102102
"no-duplicate-key": noDuplicateKey,
103-
"no-forbidden-props": noForbiddenProps,
104103
"no-forward-ref": noForwardRef,
105104
"no-implicit-key": noImplicitKey,
106105
"no-leaked-conditional-rendering": noLeakedConditionalRendering,
@@ -135,5 +134,10 @@ export const plugin: CompatiblePlugin = {
135134
"prefer-namespace-import": preferNamespaceImport,
136135
"prefer-read-only-props": preferReadOnlyProps,
137136
"prefer-use-state-lazy-initialization": preferUseStateLazyInitialization,
137+
138+
/**
139+
* @deprecated Use no-restricted-syntax or type checking instead.
140+
*/
141+
"no-forbidden-props": noForbiddenProps,
138142
},
139143
};

packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ react-x/no-forbidden-props
1818

1919
`🔧` `🧪`
2020

21+
<Callout type="warning" title="Deprecated">
22+
This rule is deprecated. AST-based component props restrictions can be easily bypassed and this rule is not significantly more effective than using `no-restricted-syntax` to achieve the same result. For similar prop restriction requirements, we recommend using static type checking instead.
23+
</Callout>
24+
2125
## Description
2226

2327
Disallow certain props on components. This rule helps enforce consistent prop naming conventions and prevents the use of specific props that may be problematic or against your team's coding standards.

packages/plugins/eslint-plugin-react-x/src/rules/no-forbidden-props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default createRule<Options, MessageID>({
3333
meta: {
3434
type: "problem",
3535
defaultOptions: [...defaultOptions],
36+
deprecated: true,
3637
docs: {
3738
description: "Disallow certain props on components.",
3839
},

0 commit comments

Comments
 (0)