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
Copy file name to clipboardExpand all lines: README.md
+36-34Lines changed: 36 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,28 +59,33 @@ Examples:
59
59
60
60
## Available transforms
61
61
62
+
The transforms are meant to migrate old code.
63
+
The transformed code is not intended to be used as a pattern for new code.
64
+
62
65
Some transforms change code they shouldn't actually change.
63
66
Fixing all of these requires a lot of implementation effort.
64
67
When considering false-positives vs false-negatives, codemods opt for false-positives.
65
68
The reason being that a false-positive can be reverted easily (assuming you have the changed code in Version Control e.g. git) while a false-negative requires manual input.
66
69
67
70
-`preset-18`
68
-
-`deprecated-react-type`
69
-
-`deprecated-sfc-element`
70
-
-`deprecated-sfc`
71
-
-`deprecated-stateless-component`
72
-
-`context-any`
73
-
-`implicit-children`
74
-
-`useCallback-implicit-any`
71
+
-`deprecated-react-type`
72
+
-`deprecated-sfc-element`
73
+
-`deprecated-sfc`
74
+
-`deprecated-stateless-component`
75
+
-`context-any`
76
+
-`implicit-children`
77
+
-`useCallback-implicit-any`
75
78
-`preset-19`
76
-
-`deprecated-prop-types-types`
77
-
-`deprecated-legacy-ref`
78
-
-`deprecated-react-child`
79
-
-`deprecated-react-text`
80
-
-`deprecated-void-function-component`
81
-
-`refobject-defaults`
82
-
-`scoped-jsx`
83
-
-`useRef-required-initial`
79
+
-`deprecated-prop-types-types`
80
+
-`deprecated-legacy-ref`
81
+
-`deprecated-react-child`
82
+
-`deprecated-react-text`
83
+
-`deprecated-void-function-component`
84
+
-`no-implicit-ref-callback-return` (off by default)
85
+
-`react-element-default-any` (off by default)
86
+
-`refobject-defaults`
87
+
-`scoped-jsx`
88
+
-`useRef-required-initial`
84
89
85
90
### `preset-18`
86
91
@@ -90,7 +95,7 @@ By default, the codemods that are definitely required to upgrade to `@types/reac
90
95
The other codemods may or may not be required.
91
96
You should select all and audit the changed files regardless.
92
97
93
-
### `context-any`
98
+
### `context-any` (React 18)
94
99
95
100
```diff
96
101
class Component extends React.Component<Props> {
@@ -160,7 +165,7 @@ They simply rename identifiers with a specific name.
160
165
If you have a type with the same name from a different package, then the rename results in a false positive.
161
166
For example, `ink` also has a `StatelessComponent` but you don't need to rename that type since it's not deprecated.
162
167
163
-
### `implicit-children`
168
+
### `implicit-children` (React 18)
164
169
165
170
```diff
166
171
-React.FunctionComponent<Props>
@@ -187,7 +192,7 @@ Redundant `PropsWithChildren` are only problematic stylistically.
187
192
In other words, the transform will not wrap `Props` in `React.PropsWithChildren`.
188
193
The transform would need to implement scope tracking for this pattern to get fixed.
189
194
190
-
### `useCallback-implicit-any`
195
+
### `useCallback-implicit-any` (React 18)
191
196
192
197
```diff
193
198
-React.useCallback((event) => {})
@@ -216,7 +221,7 @@ By default, the codemods that are definitely required to upgrade to `@types/reac
216
221
The other codemods may or may not be required.
217
222
You should select all and audit the changed files regardless.
218
223
219
-
### `deprecated-prop-types-types`
224
+
### `deprecated-prop-types-types` (React 19)
220
225
221
226
```diff
222
227
+import * as PropTypes from "prop-types";
@@ -231,7 +236,7 @@ You should select all and audit the changed files regardless.
Off by default in `preset-19`. Can be enabled when running `preset-19`.
360
365
@@ -371,7 +376,7 @@ With ref cleanups, this is no longer the case and flagged in types to avoid mist
371
376
This only works for the `ref` prop.
372
377
The codemod will not apply to other props that take refs (e.g. `innerRef`).
373
378
374
-
### `react-element-default-any-props`
379
+
### `react-element-default-any-props` (React 19)
375
380
376
381
> [!CAUTION]
377
382
> This codemod is only meant as a migration helper for old code.
@@ -405,10 +410,7 @@ if (React.isValidElement(node)) {
405
410
406
411
The props would need to be cast to `any` (e.g. `(element.props as any).foo`) to preserve the old runtime behavior.
407
412
408
-
### `refobject-defaults`
409
-
410
-
WARNING: This is an experimental codemod to intended for codebases using unpublished types.
411
-
Only use if you're using https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64896.
413
+
### `refobject-defaults` (React 19)
412
414
413
415
`RefObject` no longer makes `current` nullable by default
414
416
@@ -418,7 +420,7 @@ Only use if you're using https://github.com/DefinitelyTyped/DefinitelyTyped/pull
418
420
+const myRef: React.RefObject<View | null>
419
421
```
420
422
421
-
#### `experimental-refobject-defaults` false-negative pattern A
423
+
#### `refobject-defaults` false-negative pattern A
422
424
423
425
Importing `RefObject` via aliased named import will result in the transform being skipped.
424
426
@@ -429,7 +431,7 @@ import { RefObject as MyRefObject } from "react";
429
431
const myRef:MyRefObject<View>;
430
432
```
431
433
432
-
### `scoped-jsx`
434
+
### `scoped-jsx` (React 19)
433
435
434
436
Ensures access to global JSX namespace is now scoped to React (see [DefinitelyTyped/DefinitelyTyped#64464](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64464)).
435
437
This codemod tries to match the existing import style but isn't perfect.
@@ -447,7 +449,7 @@ If the import style doesn't match your preferences, you should set up auto-fixab
0 commit comments