Conversation
| "react/no-unused-prop-types": "error", | ||
| "react/no-unused-state": "error", | ||
| "react/prefer-es6-class": "error", | ||
| "react/require-default-props": [ "error", { ignoreFunctionalComponents: true } ], |
There was a problem hiding this comment.
With ignoreFunctionalComponents being deprecated, lets use their replacement to enforce adopting the new way. Otherwise I fear we'll have a lot of default props to remove in one big sweep when it's time to switch to React 19.
// This will turn into an `error` in the future. It's a warning to give us time to adapt.
"react/require-default-props": [ "warn", { classes: "defaultProps", functions: "defaultArguments" } ],
We can set --max-warning thresholds and slowly work towards 0 warnings.
There was a problem hiding this comment.
Done with error. If consumers want to warn they can add an exemption for themselves?
There was a problem hiding this comment.
Discussed on Slack: we concluded that we slightly prefer warn over error: with error, all offending consumers would have to overwrite this rule, matching the arguments too. This means that we'll likely end up with 10 copies of the same rule. All copies will also need to be updated when it's time to more strictly enforce.
Having one central warn rule allows all consumers to just accept it and increase their max-warnings without copying and maintaining the rule definition.
d48ac28 to
a327280
Compare
`ignoreFunctionalComponents` is deprecated. Using `functions` instead. This shifts the default prop checks for functions to the arguments instead. Using warn to ease into the new arguments.
Due to it being in the recommended rules, just removing is not enough here.
a327280 to
87699db
Compare
Context
In React 18.3, in preparation for React 19, the prop types are deprecated.
Specifically,
propTypesanddefaultPropswill be removed for functions (thoughdefaultPropswill continue to be supported for class components)https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-deprecated-react-apis
We should adapt accordingly. I'm not entirely sure if that also mean the prop-types package will be unsupported.
Either way, we should:
defaultPropsto be handled by defaults in the object instead. E.g. move to inline ES6.We talked about it in the tech-council, see the meeting notes.
ESLint Rules
react/require-default-propsreact/prop-typesFixes https://github.com/Yoast/reserved-tasks/issues/551