Skip to content

Commit 53d1425

Browse files
authored
Merge pull request #2 from codemod/preview-codemods
chore: port jssg codemods
2 parents ea4973e + bd5e2ab commit 53d1425

1,056 files changed

Lines changed: 10216 additions & 15754 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ on:
55
pull_request:
66

77
jobs:
8-
docs-and-lint:
8+
checks:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
steps:
1113
- uses: actions/checkout@v4
1214
- uses: pnpm/action-setup@v4
@@ -17,32 +19,5 @@ jobs:
1719
node-version: 20
1820
cache: pnpm
1921
- run: pnpm install --frozen-lockfile
20-
- run: pnpm run lint
21-
22-
active:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
- uses: pnpm/action-setup@v4
27-
with:
28-
version: 9.14.2
29-
- uses: actions/setup-node@v4
30-
with:
31-
node-version: 20
32-
cache: pnpm
33-
- run: pnpm install --frozen-lockfile
34-
- run: pnpm run test:active
35-
- run: pnpm run check-types:active
36-
37-
legacy:
38-
runs-on: ubuntu-latest
39-
steps:
40-
- uses: actions/checkout@v4
41-
- uses: pnpm/action-setup@v4
42-
with:
43-
version: 9.14.2
44-
- uses: actions/setup-node@v4
45-
with:
46-
node-version: 20
47-
cache: pnpm
48-
- run: pnpm run test:legacy
22+
- run: pnpm run test
23+
- run: pnpm run check-types

CONTRIBUTING.md

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,44 @@
11
# Contributing
22

3-
Thanks for your interest in contributing to react-codemod!
3+
This repository is a pnpm workspace of JSSG codemods under `codemods/*`.
44

5-
## Development setup
5+
## Setup
66

77
```bash
8-
# Install dependencies
98
pnpm install
10-
11-
# Run all tests
12-
pnpm test
13-
14-
# Type-check all codemods
15-
pnpm check-types
169
```
1710

18-
## Making changes
19-
20-
1. Create a branch from `main`.
21-
2. Make your changes and add or update tests.
22-
3. Run `pnpm test` and `pnpm check-types` to verify everything passes.
23-
4. Add a changeset (see below).
24-
5. Open a pull request.
11+
Required local checks before opening a pull request:
2512

26-
## Adding a changeset
13+
```bash
14+
pnpm run test
15+
pnpm run check-types
16+
```
2717

28-
This repo uses [Changesets](https://github.com/changesets/changesets) for versioning and releases. Every PR that changes a codemod must include a changeset.
18+
Or run the combined check:
2919

3020
```bash
31-
pnpm changeset
21+
pnpm run ci
3222
```
3323

34-
Follow the prompts to:
35-
1. Select the affected codemod(s).
36-
2. Choose the semver bump type — **patch** for bug fixes, **minor** for new features, **major** for breaking changes.
37-
3. Write a short summary of the change.
24+
## Adding or updating codemods
3825

39-
This creates a markdown file in `.changeset/` that should be committed with your PR.
26+
- Keep each codemod self-contained under `codemods/<slug>/`.
27+
- Update the codemod package README when behavior or usage changes.
28+
- Add or extend snapshot fixtures under the codemod’s `tests/` directory for every behavioral change.
4029

41-
## Release workflow
30+
## Versioning and publishing
4231

43-
1. Merge a PR with one or more changesets into `main`.
44-
2. CI automatically opens a **Version Packages** PR that bumps versions in `package.json` and `codemod.yaml`.
45-
3. Merge the version PR — git tags are created and the updated codemods are published to the Codemod registry.
32+
This repo uses Changesets to version codemod packages.
4633

47-
## Adding a new codemod
34+
To prepare a release entry for your change:
4835

49-
Each codemod lives in its own directory under `codemods/jssg/`:
50-
51-
```
52-
codemods/jssg/<name>/
53-
scripts/codemod.ts # Codemod logic (jssg / ast-grep)
54-
tests/ # Input/expected test fixtures
55-
codemod.yaml # Codemod manifest
56-
workflow.yaml # Execution workflow
57-
package.json
36+
```bash
37+
pnpm changeset
5838
```
5939

60-
Use an existing codemod as a reference when creating a new one.
40+
When release changesets land on `main`, GitHub Actions:
41+
42+
1. opens or updates the release PR via Changesets
43+
2. tags released codemod package versions as `<package-name>@v<version>`
44+
3. publishes each tagged codemod through `codemod/publish-action@v1`

LEGACY.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

PARITY_STATUS.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Parity Status
22

3-
Last updated: 2026-04-15
3+
Last updated: 2026-04-21
44

55
Status meanings:
66

77
- `Certified`: replacement-grade confidence. Tests are green, public test posture is portable, and there are no known logic gaps versus the original jscodeshift codemod. May include safe extensions on edge cases the original did not handle, as long as original behavior remains unbroken.
8-
- `Legacy`: available as a jscodeshift codemod under `codemods/legacy/`. Not yet ported to JSSG.
8+
- `Fixture-Verified`: JSSG port exists in this branch, package fixture suites are green, and type checks pass. May include differential/error/warning tests, but replacement-grade real-repo parity has not yet been established to the same standard as `Certified`.
9+
- `Deferred`: intentionally out of scope for now. Not ported to JSSG yet.
910

1011
## JSSG Codemods
1112

@@ -17,23 +18,23 @@ Status meanings:
1718
| `replace-reactdom-render` | `replace-reactdom-render.ts` | `Certified` | Full fixture coverage plus multi-alias regression tests are green. |
1819
| `react-proptypes-to-prop-types` | `React-PropTypes-to-prop-types.js` | `Certified` | Full original fixture surface is green. No JSSG-specific rollout blocker found. |
1920
| `use-context-hook` | `use-context-hook.ts` | `Certified` | Full fixture coverage plus multi-import regression tests are green. |
20-
21-
## Legacy Codemods
22-
23-
These codemods are available as jscodeshift transforms under [`codemods/legacy/transforms/`](./codemods/legacy/transforms/):
21+
| `create-element-to-jsx` | `create-element-to-jsx.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. 34 fixture cases plus error/differential checks are green. |
22+
| `error-boundaries` | `error-boundaries.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
23+
| `find-dom-node` | `findDOMNode.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
24+
| `manual-bind-to-arrow` | `manual-bind-to-arrow.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
25+
| `pure-component` | `pure-component.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. 11 fixtures plus warning/differential checks are green. |
26+
| `pure-render-mixin` | `pure-render-mixin.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
27+
| `react-dom-to-react-dom-factories` | `React-DOM-to-react-dom-factories.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
28+
| `react-native-view-prop-types` | `ReactNative-View-propTypes.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
29+
| `react-to-react-dom` | `react-to-react-dom.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. 14 fixtures plus error tests are green. |
30+
| `remove-context-provider` | `remove-context-provider.ts` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
31+
| `remove-forward-ref` | `remove-forward-ref.ts` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
32+
| `rename-unsafe-lifecycles` | `rename-unsafe-lifecycles.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
33+
| `sort-comp` | `sort-comp.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. Package fixtures and type checks are green. |
34+
| `update-react-imports` | `update-react-imports.js` | `Fixture-Verified` | Imported from `align-with-legacy-codemods` on 2026-04-20. 33 fixtures are green. |
35+
36+
## Deferred Codemods
37+
38+
These codemods are still deferred and do not have a JSSG port in this repo:
2439

2540
- `class`
26-
- `create-element-to-jsx`
27-
- `error-boundaries`
28-
- `findDOMNode`
29-
- `manual-bind-to-arrow`
30-
- `pure-component`
31-
- `pure-render-mixin`
32-
- `React-DOM-to-react-dom-factories`
33-
- `ReactNative-View-propTypes`
34-
- `react-to-react-dom`
35-
- `remove-context-provider`
36-
- `remove-forward-ref`
37-
- `rename-unsafe-lifecycles`
38-
- `sort-comp`
39-
- `update-react-imports`

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# React Codemods
22

3-
This repository contains a collection of codemods to help update React apps.
3+
This repository contains the public JSSG codemods for React migrations and cleanup work.
44

55
All codemods are free and open source, with the source code available in this repository.
66

77
## Usage
88

9-
We recommend using the [`codemod`](https://go.codemod.com/github) command for running codemods.
10-
119
```bash
1210
npx codemod <codemod-name> --target <path>
1311
```
1412

1513
- `<codemod-name>` — name of the codemod (see available codemods below)
1614
- `<path>` — files or directory to transform
1715

18-
Check [codemod docs](https://go.codemod.com/cli-docs) for the full list of available commands.
16+
Check [Codemod docs](https://go.codemod.com/cli-docs) for the full list of available commands.
1917

2018
## Available Codemods
2119

22-
All React codemods are also available in the [Codemod Registry](https://go.codemod.com/react-codemods).
20+
All React codemods are also available in the [Codemod Registry](https://app.codemod.com/registry?q=scope:@react-new).
2321

2422
#### `react-19-migration-recipe`
2523

@@ -29,7 +27,7 @@ Runs all React 19 migration codemods in sequence.
2927
npx codemod @react-new/react-19-migration-recipe --target <path>
3028
```
3129

32-
See [`react-19-migration-recipe`](./codemods/jssg/react-19-migration-recipe/) for details.
30+
See [@react-new/react-19-migration-recipe](https://app.codemod.com/registry/@react-new/react-19-migration-recipe).
3331

3432
#### `use-context-hook`
3533

@@ -39,7 +37,7 @@ Replaces usages of `React.useContext(...)` with `React.use(...)`.
3937
npx codemod @react-new/use-context-hook --target <path>
4038
```
4139

42-
See [`use-context-hook`](./codemods/jssg/use-context-hook/) for details.
40+
See [@react-new/use-context-hook](https://app.codemod.com/registry/@react-new/use-context-hook).
4341

4442
#### `replace-act-import`
4543

@@ -49,7 +47,7 @@ Updates `act` import path from `react-dom/test-utils` to `react`.
4947
npx codemod @react-new/replace-act-import --target <path>
5048
```
5149

52-
See [`replace-act-import`](./codemods/jssg/replace-act-import/) for details.
50+
See [@react-new/replace-act-import](https://app.codemod.com/registry/@react-new/replace-act-import).
5351

5452
#### `replace-string-ref`
5553

@@ -59,7 +57,7 @@ Replaces deprecated string refs with callback refs.
5957
npx codemod @react-new/replace-string-ref --target <path>
6058
```
6159

62-
See [`replace-string-ref`](./codemods/jssg/replace-string-ref/) for details.
60+
See [@react-new/replace-string-ref](https://app.codemod.com/registry/@react-new/replace-string-ref).
6361

6462
#### `replace-use-form-state`
6563

@@ -69,7 +67,7 @@ Replaces usages of `useFormState()` with `useActionState()`.
6967
npx codemod @react-new/replace-use-form-state --target <path>
7068
```
7169

72-
See [`replace-use-form-state`](./codemods/jssg/replace-use-form-state/) for details.
70+
See [@react-new/replace-use-form-state](https://app.codemod.com/registry/@react-new/replace-use-form-state).
7371

7472
#### `replace-reactdom-render`
7573

@@ -79,7 +77,7 @@ Replaces usages of `ReactDOM.render()` with `createRoot(node).render()`.
7977
npx codemod @react-new/replace-reactdom-render --target <path>
8078
```
8179

82-
See [`replace-reactdom-render`](./codemods/jssg/replace-reactdom-render/) for details.
80+
See [@react-new/replace-reactdom-render](https://app.codemod.com/registry/@react-new/replace-reactdom-render).
8381

8482
#### `react-proptypes-to-prop-types`
8583

@@ -89,11 +87,24 @@ Replaces `React.PropTypes` references with the `prop-types` package and adds the
8987
npx codemod @react-new/react-proptypes-to-prop-types --target <path>
9088
```
9189

92-
See [`react-proptypes-to-prop-types`](./codemods/jssg/react-proptypes-to-prop-types/) for details.
93-
94-
#### Legacy Codemods
95-
96-
Additional jscodeshift-based codemods from the original `react-codemod` project are available under [`codemods/legacy/`](./codemods/legacy/). See [LEGACY.md](./LEGACY.md) for the full catalog.
90+
See [@react-new/react-proptypes-to-prop-types](https://app.codemod.com/registry/@react-new/react-proptypes-to-prop-types).
91+
92+
#### Additional useful React codemods
93+
94+
- [`create-element-to-jsx`](https://app.codemod.com/registry/@react-new/create-element-to-jsx)
95+
- [`error-boundaries`](https://app.codemod.com/registry/@react-new/error-boundaries)
96+
- [`find-dom-node`](https://app.codemod.com/registry/@react-new/find-dom-node)
97+
- [`manual-bind-to-arrow`](https://app.codemod.com/registry/@react-new/manual-bind-to-arrow)
98+
- [`pure-component`](https://app.codemod.com/registry/@react-new/pure-component)
99+
- [`pure-render-mixin`](https://app.codemod.com/registry/@react-new/pure-render-mixin)
100+
- [`react-dom-to-react-dom-factories`](https://app.codemod.com/registry/@react-new/react-dom-to-react-dom-factories)
101+
- [`react-native-view-prop-types`](https://app.codemod.com/registry/@react-new/react-native-view-prop-types)
102+
- [`react-to-react-dom`](https://app.codemod.com/registry/@react-new/react-to-react-dom)
103+
- [`remove-context-provider`](https://app.codemod.com/registry/@react-new/remove-context-provider)
104+
- [`remove-forward-ref`](https://app.codemod.com/registry/@react-new/remove-forward-ref)
105+
- [`rename-unsafe-lifecycles`](https://app.codemod.com/registry/@react-new/rename-unsafe-lifecycles)
106+
- [`sort-comp`](https://app.codemod.com/registry/@react-new/sort-comp)
107+
- [`update-react-imports`](https://app.codemod.com/registry/@react-new/update-react-imports)
97108

98109
## Development
99110

@@ -114,16 +125,6 @@ Run type checking:
114125
pnpm run check-types
115126
```
116127

117-
Run legacy codemod tests:
118-
119-
```bash
120-
pnpm run test:legacy
121-
```
122-
123128
## Support and Contributing
124129

125-
If you want to contribute, you're welcome to submit a pull request.
126-
127-
## License
128-
129-
react-codemod is [MIT licensed](./LICENSE).
130+
If you want to contribute, see [CONTRIBUTING.md](./CONTRIBUTING.md).

0 commit comments

Comments
 (0)