Rename OldThing JSX usages to NewThing and rename the bar prop to count for the migrated component.
What It Changes
This codemod targets TypeScript React / TSX code and rewrites these patterns:
tsx
<OldThing foo="x" bar={1} />
to:
tsx
<NewThing foo="x" count={1} />
Supported behavior:
Renames <OldThing ...> to <NewThing ...>
Renames </OldThing> to </NewThing>
Renames bar={...} to count={...} only on migrated OldThing elements
Preserves unrelated props, prop ordering, and surrounding formatting
Renames a direct named import like import { OldThing } from "..." to import { NewThing } from "..." when that update is unambiguous
Renames the imported symbol in import { OldThing as Alias } from "..." to NewThing only when there is no conflicting local NewThing binding from imports
Conservative behavior:
If a migrated element already has a count prop, the codemod leaves bar unchanged to avoid creating duplicate props
If import updates look ambiguous or would create a conflicting NewThing import binding, the codemod leaves imports conservative
Namespace-qualified JSX and other ambiguous component indirections are intentionally not guessed
Workflow
The package ships as a two-step workflow:
An AST-based TSX codemod applies the deterministic JSX and import rename.
An optional AI step named AI review and cleanup reviews the diff for ambiguous import updates or duplicate prop cleanup.
Workflow Parameter
runAiCleanup (boolean, default true): enables the AI review and cleanup step
Usage
bash
# Run locally against a target repository
npx codemod workflow run -w . -t /path/to/repo
# Disable the optional AI cleanup step
npx codemod workflow run -w . -t /path/to/repo --param runAiCleanup=false
The workflow scans **/*.{ts,tsx,mts,cts} and excludes node_modules, dist, and build directories.
Test Coverage
Fixtures cover:
Self-closing JSX migration
Paired opening/closing tag migration
Preservation of unrelated props
Direct named import updates when unambiguous
Conservative duplicate-prop handling when both bar and count are present
Conservative import handling when NewThing is already imported