Skip to content

Commit 571c830

Browse files
committed
Merge branch 'codemods-v3' of github.com:codemod-com/react-codemod into codemods-v3
2 parents a012e7c + cba653b commit 571c830

30 files changed

+507
-71
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
parser: 'babel-eslint',
2+
parser: '@typescript-eslint/parser',
33

44
extends: './node_modules/fbjs-scripts/eslint/.eslintrc.js',
55

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ npx codemod react/19/replace-use-form-state --target <path>
127127
npx react-codemod replace-use-form-state <path>
128128
```
129129

130+
#### `replace-reactdom-render`
131+
132+
Replaces usages of ReactDom.render() with createRoot(node).render().
133+
134+
Run with `react-codemod` CLI for basic experience:
135+
136+
```sh
137+
npx react-codemod replace-reactdom-render <path>
138+
```
139+
140+
or use `codemod` CLI for better experience and support:
141+
142+
```sh
143+
npx codemod react/19/replace-reactdom-render --target <path>
144+
```
145+
130146
#### `create-element-to-jsx`
131147

132148
Converts calls to `React.createElement` into JSX elements.

bin/cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ const TRANSFORMER_INQUIRER_CHOICES = [
232232
'replace-string-ref: Replaces deprecated string ref with callback ref',
233233
value: 'replace-string-ref'
234234
},
235+
{
236+
name:
237+
'replace-reactdom-render: Replaces deprecated ReactDom.render',
238+
value: 'replace-reactdom-render'
239+
},
235240
];
236241

237242
const PARSER_INQUIRER_CHOICES = [

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"bin"
3131
],
3232
"transform": {
33-
"^.+\\.jsx?$": "babel-jest",
33+
"^.+\\.jsx?$": "babel-jest",
3434
"^.+\\.tsx?$": "ts-jest"
3535
}
3636
},
@@ -39,6 +39,7 @@
3939
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
4040
"@babel/preset-env": "^7.6.3",
4141
"@types/jest": "^24.9.0",
42+
"@typescript-eslint/parser": "^7.8.0",
4243
"babel-eslint": "^10.0.3",
4344
"babel-jest": "^24.9.0",
4445
"eslint": "^6.6.0",

transforms/__testfixtures__/custom-sort-group/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
parser: babel-eslint
23
plugins:
34
- react
45
rules:

transforms/__testfixtures__/custom-sort/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
parser: babel-eslint
23
plugins:
34
- react
45
rules:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as React1 from 'react';
2+
3+
const MyInput = React1.forwardRef((props, ref) => {
4+
return null;
5+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React1 from 'react';
2+
3+
const MyInput = (
4+
{
5+
ref,
6+
...props
7+
}
8+
) => {
9+
return null;
10+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { forwardRef } from 'react';
2+
const MyComponent = forwardRef(function Component(
3+
myProps: { a: 1 },
4+
myRef
5+
) {
6+
return null;
7+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const MyComponent = function Component(
2+
{
3+
ref: myRef,
4+
...myProps
5+
}: { a: 1 } & {
6+
ref: React.RefObject<unknown>
7+
}
8+
) {
9+
return null;
10+
};

0 commit comments

Comments
 (0)