Suppose one of components has a bunch of properties, and just passes them to child component <SomeChild {...this.props} />. In this case no-unused-prop-types rule will mark all properties as unused. Although rule could be manually disabled for the component, I'd like to see that rule can handle that situation, maybe with an additional option in configuration.
That goes far beyond what a linter is capable of. Spread props are dynamic at runtime and defy static analysis.
{...this.props}{...this.props}, e.g. "Potentially unused property foo" or "Property foo is not used explicitly"The rule's severity is all or nothing - either it's an error (when the rule is configured as an error), or it doesn't report at all.
IMO configured severity is sort of upper bound, and linter may report some issues with lower severity
@victor-homyakov that's not how eslint works. Rules only have one "report" function, and everything matches the configured severity.
:(
OK, what about adding new option to silence this rule when spread operator {... this.props} is used?
I think only when the entire props object is spread, it makes sense to mark all properties as used.
I hope there is a chance this could be explored deeper.
The only false positives I get anymore are from using { ...this.props }.
I am also running into this. Having to turn off that rule around my proptypes fairly frequently.
@ljharb this issue can be closed. Fixed in #1303.
The test case discussed in the thread is line 1319 here
Most helpful comment
I think only when the entire props object is spread, it makes sense to mark all properties as used.