You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ljharb
changed the title
[Bug]: react/no-unused-prop-types returns no errors when using the spread operator in JXS element
[Bug]: react/no-unused-prop-types returns no errors when using the spread operator in JSX element
May 3, 2023
When you're spreading the props object, the rule intentionally stops warning on things, because if you're doing this (don't) you've basically given up on anyone, human or linter, from being able to figure out what's in that object by reading the code.
This specific case is weird because you're not spreading the props object, so I wouldn't expect this to affect anything.
Is there an existing issue for this?
Description Overview
When using the spread operator within a JSX component, the rule
react/no-unused-prop-types
no longer detects any errors.Demo Code
package.json
.eslintrc.js
Demo.tsx
What is happening?
With spread operator
No error is detected when a prop type is unused within the component a spread operator is used in an element for attributes.
Without spread operator
When removing the spread operator, the unused prop is detected
![CleanShot 2023-04-27 at 14 10 33@2x](https://user-images.githubusercontent.com/1824649/234857994-073c3ae4-d93f-4c9d-acad-69cfc598c081.png)
Steps to reproduce
yarn lint
Expected Behavior
bar
should be marked as a linting erroreslint-plugin-react version
v7.32.2
eslint version
v8.39.0
node version
v18.11.0
The text was updated successfully, but these errors were encountered: