Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c02d42a
bootstrap new rule
ulrichstark Jul 21, 2025
ac323a5
add first tests and make them pass
ulrichstark Jul 22, 2025
d5c321f
add more tests
ulrichstark Jul 22, 2025
961ba4e
add basic examples to doc page
ulrichstark Jul 22, 2025
8e31ac6
remove rule from examples for now
ulrichstark Jul 23, 2025
7a31396
Merge branch '2.0.0-beta' into no-unused-props
Rel1cx Jul 25, 2025
64e2fb1
comment out no-unused-props in x preset
Rel1cx Jul 25, 2025
d72e304
fix: comment out no-unused-props rule in 'all' config
Rel1cx Jul 25, 2025
c7e4608
only report on property key and not the whole declaration
ulrichstark Jul 25, 2025
ba34768
add valid test and make it pass
ulrichstark Jul 25, 2025
f0b5e3b
add more tests to avoid false positives
ulrichstark Jul 25, 2025
1393016
track properties of rest element, add more tests and comments
ulrichstark Jul 25, 2025
aa343f2
make it work in node 20
ulrichstark Jul 26, 2025
8ed5807
refactor to avoid false positives, detect more cases, add tests
ulrichstark Jul 26, 2025
c52d0a2
simplify code
ulrichstark Jul 26, 2025
f7032d9
two more tests
ulrichstark Jul 26, 2025
3ee1ae9
fix crash if declaration is in another file
ulrichstark Jul 26, 2025
7891387
add a second sentence to the description
ulrichstark Jul 26, 2025
68c0d8f
some final hopefully correct docs changes
ulrichstark Jul 28, 2025
d229530
test: add test cases related to `PropsWithChildren` and `forwardRef`
Rel1cx Jul 31, 2025
9010cf4
test: add multiple components case
Rel1cx Jul 31, 2025
638c3c3
test: remove todo for multiple components case
Rel1cx Aug 1, 2025
3461a5b
chore: minor fixes
Rel1cx Aug 1, 2025
67ccee8
outline differences to original rule in docs description and example
ulrichstark Aug 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/website/content/docs/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ The following table compares all rules from `eslint-plugin-react` with their ESL
| [`no-unsafe`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md) | [`no-unsafe-component-will-mount`](/docs/rules/no-unsafe-component-will-mount) + [`no-unsafe-component-will-receive-props`](/docs/rules/no-unsafe-component-will-receive-props) + [`no-unsafe-component-will-update`](/docs/rules/no-unsafe-component-will-update) | ✅ | 🟡 |
| [`no-unstable-nested-components`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md) | [`no-nested-component-definitions`](/docs/rules/no-nested-component-definitions) | ✅ | ✅ |
| [`no-unused-class-component-methods`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md) | [`no-unused-class-component-members`](/docs/rules/no-unused-class-component-members) | ✅ | 🚫 |
| [`no-unused-prop-types`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md) | [`no-prop-types`](/docs/rules/no-prop-types) | ✅ | 🚫 |
| [`no-unused-prop-types`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md) | [`no-unused-props`](/docs/rules/no-unused-props) | ✅ | 🚫 |
| [`no-unused-state`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md) | [`no-unused-state`](/docs/rules/no-unused-state) | ✅ | 🚫 |
| [`no-will-update-set-state`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md) | [`no-set-state-in-component-will-update`](/docs/rules/no-set-state-in-component-will-update) | ✅ | ✅ |
| [`prefer-es6-class`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) | [`no-prop-types`](/docs/rules/no-prop-types) | ✅ | 🚫 |
Expand Down
1 change: 1 addition & 0 deletions apps/website/content/docs/rules/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"no-unstable-context-value",
"no-unstable-default-props",
"no-unused-class-component-members",
"no-unused-props",
"no-unused-state",
"no-use-context",
"no-useless-forward-ref",
Expand Down
1 change: 1 addition & 0 deletions apps/website/content/docs/rules/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The `jsx-*` rules check for issues exclusive to JSX syntax, which are absent fro
| [`no-unstable-context-value`](./no-unstable-context-value) | 1️⃣ | | Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider` | |
| [`no-unstable-default-props`](./no-unstable-default-props) | 1️⃣ | | Prevents using referential-type values as default props in object destructuring | |
| [`no-unused-class-component-members`](./no-unused-class-component-members) | 1️⃣ | | Warns unused class component methods and properties | |
| [`no-unused-props`](./no-unused-props) | 0️⃣ | | Warns about unused component prop declarations | |
| [`no-unused-state`](./no-unused-state) | 1️⃣ | | Warns unused class component state | |
| [`no-use-context`](./no-use-context) | 1️⃣ | `🔄` | Replaces usages of `useContext` with `use` | >=19.0.0 |
| [`no-useless-forward-ref`](./no-useless-forward-ref) | 1️⃣ | | Disallow useless `forwardRef` calls on components that don't use `ref`s | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const rules = {
"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-props": "warn",
"react-x/no-unused-state": "warn",
"react-x/no-use-context": "warn",
"react-x/no-useless-forward-ref": "warn",
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/eslint-plugin-react-x/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ 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 noUnusedProps from "./rules/no-unused-props";
import noUnusedState from "./rules/no-unused-state";
import noUseContext from "./rules/no-use-context";
import noUselessForwardRef from "./rules/no-useless-forward-ref";
Expand Down Expand Up @@ -127,6 +128,7 @@ export const plugin = {
"no-unstable-context-value": noUnstableContextValue,
"no-unstable-default-props": noUnstableDefaultProps,
"no-unused-class-component-members": noUnusedClassComponentMembers,
"no-unused-props": noUnusedProps,
"no-unused-state": noUnusedState,
"no-use-context": noUseContext,
"no-useless-forward-ref": noUselessForwardRef,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: no-unused-props
---

**Full Name in `eslint-plugin-react-x`**

```sh copy
react-x/no-unused-props
```

**Full Name in `@eslint-react/eslint-plugin`**

```sh copy
@eslint-react/no-unused-props
```

## Description

Warns about unused component prop declarations.

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.

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

- doesn't support the legacy propTypes syntax
- combines the used props of one type definition declared by multiple components

## Examples

### Failing

```tsx
interface Props {
abc: string; // used
hello: string; // NOT used
}

function Component(props: Props) {
const { abc } = props; // `hello` isn't accessed from `props`
return null;
}
```

### Passing

```tsx
interface Props {
abc: string; // used
hello: string; // used
}

function Component(props: Props) {
const { abc, hello } = props;
return null;
}
```

```tsx
interface Props {
abc: string; // used by Component1
hello: string; // used by Component2
}

function Component1({ abc }: Props) {
return null;
}

function Component2({ hello }: Props) {
return null;
}
```

## Implementation

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

## See Also

- [`no-prop-types`](/docs/rules/no-prop-types)\
Disallows `propTypes`
Loading
Loading