Skip to content

Commit e785182

Browse files
committed
refactor repo
1 parent 422d89f commit e785182

1,011 files changed

Lines changed: 15747 additions & 9588 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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
docs-and-lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: pnpm/action-setup@v4
13+
with:
14+
version: 9.14.2
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: pnpm
19+
- 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

LEGACY.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Legacy Codemods
2+
3+
This branch keeps the non-high-priority `react-codemod` transforms as a legacy jscodeshift snapshot under [`codemods/legacy/transforms/`](./codemods/legacy/transforms/).
4+
5+
The legacy snapshot is preserved for source reference, upstream-style tests, and branch preview parity with the structure of `reactjs/react-codemod`.
6+
7+
## Legacy Catalog
8+
9+
- [`create-element-to-jsx`](./codemods/legacy/transforms/create-element-to-jsx.js)
10+
- [`error-boundaries`](./codemods/legacy/transforms/error-boundaries.js)
11+
- [`findDOMNode`](./codemods/legacy/transforms/findDOMNode.js)
12+
- [`manual-bind-to-arrow`](./codemods/legacy/transforms/manual-bind-to-arrow.js)
13+
- [`pure-component`](./codemods/legacy/transforms/pure-component.js)
14+
- [`pure-render-mixin`](./codemods/legacy/transforms/pure-render-mixin.js)
15+
- [`React-DOM-to-react-dom-factories`](./codemods/legacy/transforms/React-DOM-to-react-dom-factories.js)
16+
- [`ReactNative-View-propTypes`](./codemods/legacy/transforms/ReactNative-View-propTypes.js)
17+
- [`react-to-react-dom`](./codemods/legacy/transforms/react-to-react-dom.js)
18+
- [`remove-context-provider`](./codemods/legacy/transforms/remove-context-provider.ts)
19+
- [`remove-forward-ref`](./codemods/legacy/transforms/remove-forward-ref.ts)
20+
- [`rename-unsafe-lifecycles`](./codemods/legacy/transforms/rename-unsafe-lifecycles.js)
21+
- [`sort-comp`](./codemods/legacy/transforms/sort-comp.js)
22+
- [`update-react-imports`](./codemods/legacy/transforms/update-react-imports.js)
23+
- [`class`](./codemods/legacy/transforms/class.js)
24+
25+
## Notes
26+
27+
- The 6 promoted JSSG transforms are not duplicated in `codemods/legacy/`.
28+
- This preview branch does not claim that legacy transforms can be run through Codemod Registry.
29+
- The legacy snapshot keeps the full upstream-style test corpus in `codemods/legacy/transforms/__tests__`.
30+
- The preview branch CI runs the compatible legacy subset under the current preview runtime:
31+
32+
```bash
33+
pnpm run test:legacy
34+
```
35+
36+
- To run the full legacy snapshot test corpus manually from `codemods/legacy/`:
37+
38+
```bash
39+
pnpm test
40+
```

PARITY_STATUS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Legacy Parity Status
2+
3+
Last updated: 2026-04-15
4+
5+
Status meanings:
6+
7+
- `Certified`: replacement-grade rollout confidence. Strict/default package tests are green, public test posture is portable, and there are no known rollout-blocking logic gaps versus the legacy jscodeshift codemod. `Certified` may include intentional safe extensions on legacy-unsupported edge cases, as long as intentional legacy behavior remains unbroken.
8+
- `Legacy Snapshot`: preserved as upstream jscodeshift source and tests on this branch, but not promoted as part of the active JSSG replacement surface.
9+
10+
## Active JSSG Surface
11+
12+
These are the only codemods promoted as active replacements on this branch.
13+
14+
| Codemod | Legacy Source | Status | Notes |
15+
| --- | --- | --- | --- |
16+
| `replace-use-form-state` | `replace-use-form-state.ts` | `Certified` | Legacy fixture surface plus added multi-import regression coverage are green. Collection-wide replacement on matching `react-dom` imports fixes a real parity gap, and the broader multi-import handling is treated as an acceptable safe extension where legacy only partially migrated files. |
17+
| `replace-act-import` | `replace-act-import.ts` | `Certified` | Legacy fixture surface plus added multi-import regression coverage. This closes a real parity gap, and the mixed test-utils partial-removal path is an acceptable safe extension that does not break intentional legacy behavior. |
18+
| `replace-string-ref` | `replace-string-ref.ts` | `Certified` | Legacy fixture surface plus added namespace/default-export/multi-ref coverage are green, and the direct-superclass guard restores the intended direct-superclass behavior by avoiding the prior mixin false positive. |
19+
| `replace-reactdom-render` | `replace-reactdom-render.ts` | `Certified` | Legacy fixtures plus added multi-alias regression coverage are green. The extra multi-alias handling is an acceptable safe extension over legacy implementation limits; it preserves intentional legacy behavior while covering additional valid cases. |
20+
| `react-proptypes-to-prop-types` | `React-PropTypes-to-prop-types.js` | `Certified` | Full legacy fixture surface is green, targeted mixed-import validation is aligned, and no JSSG-specific rollout blocker was found in the audit. No additional extension beyond the legacy behavior is currently relied on for certification. |
21+
| `use-context-hook` | `use-context-hook.ts` | `Certified` | Legacy fixture surface plus added multi-import regression coverage are green. The multi-import handling goes beyond the legacy implementation, but it is treated as an acceptable safe extension because it preserves intentional legacy behavior while covering additional valid cases. |
22+
23+
## Legacy Snapshot Surface
24+
25+
These codemods remain available only as an upstream jscodeshift snapshot under [`codemods/legacy/transforms/`](./codemods/legacy/transforms/):
26+
27+
- `class`
28+
- `create-element-to-jsx`
29+
- `error-boundaries`
30+
- `findDOMNode`
31+
- `manual-bind-to-arrow`
32+
- `pure-component`
33+
- `pure-render-mixin`
34+
- `React-DOM-to-react-dom-factories`
35+
- `ReactNative-View-propTypes`
36+
- `react-to-react-dom`
37+
- `remove-context-provider`
38+
- `remove-forward-ref`
39+
- `rename-unsafe-lifecycles`
40+
- `sort-comp`
41+
- `update-react-imports`

README.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
1-
# jssg-react-codemods
2-
3-
React codemods built with JSSG and JavaScript ast-grep.
4-
5-
## Packages
6-
7-
- `@react/error-boundaries`
8-
- `@react/find-dom-node`
9-
- `@react/manual-bind-to-arrow`
10-
- `@react/pure-render-mixin`
11-
- `@react/react-proptypes-to-prop-types`
12-
- `@react/rename-unsafe-lifecycles`
13-
- `@react/replace-act-import`
14-
- `@react/replace-reactdom-render`
15-
- `@react/replace-string-ref`
16-
- `@react/replace-use-form-state`
17-
- `@react/sort-comp`
18-
- `@react/update-react-imports`
19-
- `@react/use-context-hook`
1+
# React Codemods Preview
2+
3+
This branch is a React-facing preview of how this repo should look as a replacement-style home for `react-codemod`.
4+
5+
It promotes 6 audited JSSG codemods as the active surface and preserves the remaining upstream jscodeshift codemods as a legacy snapshot.
6+
7+
## Active JSSG Transforms
8+
9+
These transforms are the active replacement surface on this branch. They are source-first JSSG codemods and are not described here as Codemod Registry entries unless they are actually published.
10+
11+
- [`use-context-hook`](./codemods/jssg/use-context-hook/) — replace `useContext` usage with `use`
12+
- [`replace-act-import`](./codemods/jssg/replace-act-import/) — move `act` from `react-dom/test-utils` to `react`
13+
- [`replace-string-ref`](./codemods/jssg/replace-string-ref/) — replace deprecated string refs with callback refs
14+
- [`replace-use-form-state`](./codemods/jssg/replace-use-form-state/) — rename `useFormState` to `useActionState`
15+
- [`replace-reactdom-render`](./codemods/jssg/replace-reactdom-render/) — replace `ReactDOM.render` with `createRoot(...).render(...)`
16+
- [`react-proptypes-to-prop-types`](./codemods/jssg/react-proptypes-to-prop-types/) — replace `React.PropTypes` with `prop-types`
17+
18+
## Legacy Codemods
19+
20+
All non-priority transforms are preserved as an upstream-style legacy jscodeshift snapshot under [`codemods/legacy/`](./codemods/legacy/).
21+
22+
See [LEGACY.md](./LEGACY.md) for the legacy catalog and testing notes.
2023

2124
## Development
2225

2326
```bash
24-
pnpm test
25-
pnpm -r check-types
27+
pnpm install
28+
pnpm run ci
29+
```
30+
31+
Run active JSSG checks only:
32+
33+
```bash
34+
pnpm run test:active
35+
pnpm run check-types:active
2636
```
2737

28-
Run a single package:
38+
Run the legacy snapshot test harness:
2939

3040
```bash
31-
pnpm --filter @react-codemods/replace-reactdom-render test
41+
pnpm run test:legacy
3242
```

codemods/create-element-to-jsx/README.md

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

codemods/create-element-to-jsx/codemod.yaml

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

codemods/create-element-to-jsx/package.json

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

0 commit comments

Comments
 (0)