rename-oldthing-to-newthing-brisk-spark-1shi
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
to:
tsx
Supported behavior:
- Renames
<OldThing ...>to<NewThing ...> - Renames
</OldThing>to</NewThing> - Renames
bar={...}tocount={...}only on migratedOldThingelements - Preserves unrelated props, prop ordering, and surrounding formatting
- Renames a direct named import like
import { OldThing } from "..."toimport { NewThing } from "..."when that update is unambiguous - Renames the imported symbol in
import { OldThing as Alias } from "..."toNewThingonly when there is no conflicting localNewThingbinding from imports
Conservative behavior:
- If a migrated element already has a
countprop, the codemod leavesbarunchanged to avoid creating duplicate props - If import updates look ambiguous or would create a conflicting
NewThingimport 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 cleanupreviews the diff for ambiguous import updates or duplicate prop cleanup.
Workflow Parameter
runAiCleanup(boolean, defaulttrue): enables theAI review and cleanupstep
Usage
bash
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
barandcountare present - Conservative import handling when
NewThingis already imported
Development
bash
License
MIT