Skip to content

Commit 67ccee8

Browse files
committed
outline differences to original rule in docs description and example
1 parent 3461a5b commit 67ccee8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-unused-props.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ Warns about unused component prop declarations.
2020

2121
Unused props increase maintenance overhead and may mislead consumers of the component into thinking the prop is required or meaningful, even when it has no effect.
2222

23-
This is the TypeScript-only version of [`eslint-plugin-react/no-unused-prop-types`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md).
23+
This is the TypeScript-only version of [`eslint-plugin-react/no-unused-prop-types`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md). In contrast to the original rule, this rule
24+
25+
- doesn't support the legacy propTypes syntax
26+
- combines the used props of one type definition declared by multiple components
2427

2528
## Examples
2629

@@ -52,6 +55,21 @@ function Component(props: Props) {
5255
}
5356
```
5457

58+
```tsx
59+
interface Props {
60+
abc: string; // used by Component1
61+
hello: string; // used by Component2
62+
}
63+
64+
function Component1({ abc }: Props) {
65+
return null;
66+
}
67+
68+
function Component2({ hello }: Props) {
69+
return null;
70+
}
71+
```
72+
5573
## Implementation
5674

5775
- [Rule source](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x/src/rules/no-unused-props.ts)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ ruleTesterWithTypes.run(RULE_NAME, rule, {
607607
hello: string;
608608
}
609609
610-
function Component({ abc }: Props) {
610+
function Component1({ abc }: Props) {
611611
return null;
612612
}
613613

0 commit comments

Comments
 (0)