Skip to content

Comments

[Fix] no-unused-prop-types: detect used props in nested components#3955

Open
avaice wants to merge 2 commits intojsx-eslint:masterfrom
avaice:fix-nested-wrapper-unused-props
Open

[Fix] no-unused-prop-types: detect used props in nested components#3955
avaice wants to merge 2 commits intojsx-eslint:masterfrom
avaice:fix-nested-wrapper-unused-props

Conversation

@avaice
Copy link

@avaice avaice commented Sep 22, 2025

Fixes #3524

This PR fixes a bug where react/no-unused-prop-types was not properly detecting unused props in components wrapped with nested wrapper functions like React.memo(React.forwardRef()).

  • Enhanced component detection logic to properly traverse nested wrapper functions when looking for propType definitions
  • Added logic to find the actual component node that declares propTypes when dealing with nested wrapper patterns
  • The fix ensures that prop usage is correctly detected by finding the component that actually defines the propTypes, regardless of how many wrapper functions are nested

@avaice avaice marked this pull request as ready for review September 22, 2025 09:42
@ljharb
Copy link
Member

ljharb commented Feb 18, 2026

Sorry for the delay, but this needs rebasing, and untyped test cases.

@ljharb ljharb marked this pull request as draft February 18, 2026 18:07
@avaice avaice force-pushed the fix-nested-wrapper-unused-props branch from 630b84c to 3dea9bb Compare February 19, 2026 09:27
@avaice
Copy link
Author

avaice commented Feb 19, 2026

@ljharb
Thanks! I rebased and added untyped test cases.

@avaice avaice marked this pull request as ready for review February 19, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: False positive on react/no-unused-prop-types with memo + forwardRef

2 participants