Repository navigation
Adopt @jssg/utils import helpers across React JSSG codemods - #15
Merged
Merged
Conversation
Use getImport/getAllImports, addImport, and updateImport from @jssg/utils@^0.0.10 in use-context-hook, react-dom-to-react-dom-factories, unprefix-stable-apis, and fragment-ref-wrappers. Add fixtures that fail under ad-hoc import handling (CJS named useContext, aliased DOM/React, type-only unprefix, single-quote Fragment merge). Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Refactor replace-act-import, replace-use-form-state, replace-reactdom-render, and prop-types-typescript to rely on getImport/getAllImports/addImport/ removeImport instead of ad-hoc import rewriting, and add fixtures that fail under quote-blind or line-regex handling but pass with utils. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Use getImport/getAllImports/addImport/removeImport for memoization cleanup, createFactory removal, PropTypes migration, and React alias resolution in find-dom-node/create-element-to-jsx/pure-render-mixin. Partial utils adoption in update-react-imports preserves its destructure/namespace policy. Add fixtures covering no-semicolon siblings, named import cleanup, double-quote prop-types insertion, and aliased namespace React bindings. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Wire getImport/getAllImports/addImport/removeImport/updateImport into use-browser, remove-legacy-context, pure-component, react-native-view-prop-types, react-to-react-dom (partial), and sort-comp. Bump leftover @jssg/utils ^0.0.2 deps to ^0.0.10 and guard remove-forward-ref/replace-string-ref against getImport namespace fallbacks. Add fixtures for single-quote merge, CJS React, aliased View/findDOMNode, multi-specifier cleanup, and aliased React namespace sort-comp. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Bump changeset packages (0.1.2→0.1.3, react-19-3 0.1.1→0.1.2) and sync codemod.yaml. Add update-react-imports fixtures for single-quote removeImport and no-semicolon destructure, plus a CJS require parity case for prop-types-typescript. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Parallel `pnpm -r test` raced on the shared pnpm dlx cache (ENOENT unlink under ~/.cache/pnpm/dlx). Install codemod@1.18.6 at the workspace root and run tests through scripts/run-codemod.mjs so packages keep their cwd without concurrent dlx installs. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Contributor
Author
|
/codex-review |
`typescript@latest` resolved to 7.0.2, whose package entry only exports version metadata. That made `ts.ScriptTarget` undefined in prop-types-typescript parity tests on CI. Pin ~5.9.3 via package ranges and a pnpm override. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
pnpm dlx was fine conceptually — the CI failure was a parallel-cache race when many packages ran `pnpm dlx` at once. Prefer declaring `codemod` as a devDependency and invoking it on PATH. Also upgrade typescript to ^7.0.2. TS 7 dropped the classic compiler API from the main export, so prop-types-typescript parity tests import createSourceFile via @typescript/typescript6. Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
Contributor
Author
|
/codex-review |
2 tasks
Contributor
|
/codex-review |
2 similar comments
Contributor
Author
|
/codex-review |
Contributor
Author
|
/codex-review |
Contributor
Codex ReviewReviewed all 210 changed files. Existing tests and type checks pass, but comparisons against the base confirm several correctness regressions and gaps in alias, namespace, and import-cleanup coverage. Findings
|
- fragment-ref-wrappers: don't treat a namespace fallback as a named Fragment binding - prop-types-typescript: collect every default binding; keep imports still referenced (incl. type refs) - react-proptypes-to-prop-types: reuse the existing prop-types alias (import, namespace, require) - use-browser: stop hook cleanup before removeImport falls back to a namespace import - use-context-hook: rename every useContext reference when its import is renamed - create-element-to-jsx, find-dom-node, pure-render-mixin, sort-comp: match against all React aliases - remove-legacy-context: generate a CommonJS React binding for CommonJS sources - unprefix-stable-apis: use one collision-safe rename plan per exported name Co-authored-by: Alex Bit <alexbit-codemod@users.noreply.github.com>
mohebifar
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes React JSSG codemods use
@jssg/utilsfor import detection and rewriting instead of ad-hoc scanners, and bumps@jssg/utilsto^0.0.10.Package and
codemod.yamlversions are bumped (patch) for every touched codemod.Test runner / TypeScript
pnpm dlx? Concurrentpnpm -r testraced on the shared dlx cache (ENOENTunlink under~/.cache/pnpm/dlx). Fix: declarecodemod@1.18.6as a realdevDependencyand invokecodemodon PATH — no custom wrapper.^7.0.2fortsc. TS 7’s main export no longer has the classic compiler API, soprop-types-typescriptparity tests use@typescript/typescript6only forcreateSourceFile/ parse checks.New fixtures
CJS, aliases, quote/merge style, multiline import cleanup, and related utils edge cases across the React codemod packages (see diff).
prop-types-typescriptcoverage is inparity-cases.mjs;update-react-importsadds utils-focusedtests/cases.Codex review follow-up
Codemod-side regressions from the review are fixed, each with a fixture: namespace fallback in fragment-ref-wrappers, multi-binding cleanup in prop-types-typescript, alias reuse in react-proptypes-to-prop-types, namespace cleanup crash in use-browser, mixed aliases in use-context-hook, multiple React aliases in create-element-to-jsx / find-dom-node / pure-render-mixin / sort-comp, CommonJS output in remove-legacy-context, and duplicate-export collisions in unprefix-stable-apis.
Known
@jssg/utilsgaps (follow-up in codemod/codemod, not worked around here)getAllImports({ type: "default" })drops namespace imports whenever a default import exists.addImport(named) checks existence by exported name only, ignoring aliases, and treats the namespace fallback as an existing binding.addImportinsertion point includesrequire()declarations nested inside functions.removeImportalways edits the first matching statement; it can't target a specific alias/binding.updateImportonly edits the first matching clause and keys renames by exported name.import typeawareness: type-only bindings are returned as values, and runtime specifiers get merged into type-only imports.Test plan
pnpm run ci(all package tests +check-typeson TypeScript 7)