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
The change to defaultProps is of particular interest because it has a runtime impact (ignoring any caveats/special cases for propTypes in this issue) - for like for like behaviour consumers are now forced to migrate to ES6 style default arguments (or alternatives, e.g. hoist the default to the parent component etc).
I would be interested to test appetite for either a new rule, or adjustments to existing rule(s), to allow consumers of this lint plugin to forbid usage of defaultProps on non-class components (assuming I’ve not overlooked existing support for this in some form).
Eventually I could see such a rule becoming redundant once sufficient time has passed such that the general React community has forgotten about defaultProps etc., but in the meantime such a rule would help to protect React community component authors from themselves where years of habit results in them reaching for the API which silently does nothing (*silent in production, with logged warnings/errors in development).
Because of this habit I suspect current themes of disabling certain rule capabilities (manually or automatically by detecting R19+) in other issues doesn’t quite cut it? Some form of opt-in (manual or automatically for R19+) behaviour to warn users that they’ve accidentally introduced defaultProps would be fab.
One totally valid option is to suggest out of scope for this package and consumers reach for this other solutions. It would be personal (and maybe reflects other consumers of this package?) preference to avoid linter package proliferation by consolidating on just this package.
React 19 sees the dropping of
propTypes
anddefaultProps
for function components.The change to
defaultProps
is of particular interest because it has a runtime impact (ignoring any caveats/special cases forpropTypes
in this issue) - for like for like behaviour consumers are now forced to migrate to ES6 style default arguments (or alternatives, e.g. hoist the default to the parent component etc).I would be interested to test appetite for either a new rule, or adjustments to existing rule(s), to allow consumers of this lint plugin to forbid usage of
defaultProps
on non-class components (assuming I’ve not overlooked existing support for this in some form).Eventually I could see such a rule becoming redundant once sufficient time has passed such that the general React community has forgotten about
defaultProps
etc., but in the meantime such a rule would help to protect React community component authors from themselves where years of habit results in them reaching for the API which silently does nothing (*silent in production, with logged warnings/errors in development).Because of this habit I suspect current themes of disabling certain rule capabilities (manually or automatically by detecting R19+) in other issues doesn’t quite cut it? Some form of opt-in (manual or automatically for R19+) behaviour to warn users that they’ve accidentally introduced
defaultProps
would be fab.Related discussions:
react/prop-types
from the recommended config #3753The text was updated successfully, but these errors were encountered: