eslint-plugin-react-19-upgrade
v1.9.0
Published
An ESLint plugin to identify and fix breaking changes when upgrading React 18 to React 19
Readme
eslint-plugin-react-19-upgrade
An ESLint plugin to identify and fix breaking changes when upgrading React 18 to React 19
Installation
You'll first need to install ESLint:
$ npm install eslint --save-devNext, install eslint-plugin-react-19-upgrade:
$ npm install eslint-plugin-react-19-upgrade --save-devUsage
Add react-19-upgrade to the plugins section of your .eslintrc or equivalent configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": ["react-19-upgrade"]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"react-19-upgrade/no-default-props": "error",
"react-19-upgrade/no-prop-types": "warn",
"react-19-upgrade/no-legacy-context": "error",
"react-19-upgrade/no-string-refs": "error",
"react-19-upgrade/no-factories": "error",
"react-19-upgrade/no-legacy-react-dom": "error",
"react-19-upgrade/no-legacy-react-dom-server": "error",
"react-19-upgrade/no-legacy-test-utils-act": "error"
}
}Supported Rules
no-default-props: MovedefaultPropsto default parameters in the destructured props. Fixable by ESLint.no-prop-types: Avoid usingpropTypesas they are now ignored in React 19.no-legacy-context: Disallow the use of legacy context APIs in React class components.no-string-refs: Disallow the use of string refs in React components.no-factories: Disallow module pattern factories and React.createFactory.no-legacy-react-dom: Disallow removedreact-domAPIs (render,hydrate,unmountComponentAtNode,findDOMNode). UsecreateRoot/hydrateRootfromreact-dom/client, or refs, instead.no-legacy-react-dom-server: DisallowrenderToNodeStreamandrenderToStaticNodeStreamfromreact-dom/server. UserenderToPipeableStreaminstead (note: different signature).no-legacy-test-utils-act: Importactfromreact, notreact-dom/test-utils. Fixable by ESLint.
element.ref access
React 19 makes ref a regular prop, so element.ref becomes element.props.ref. This plugin does not lint for it — any sound static heuristic either misses real cases or produces false positives on valid code. Use the official React codemod instead: npx codemod@latest react/19/replace-ref-access.
