rename-oldthing-to-newthing
Rename OldThing to NewThing
# rename-oldthing-to-newthing
Renames the JSX component `OldThing` to `NewThing` in `.tsx` files and renames the `bar` prop to `count` on migrated `OldThing` usages.
## What It Changes
- `<OldThing ... />` becomes `<NewThing ... />`
- `<OldThing ...></OldThing>` becomes `<NewThing ...></NewThing>`
- `bar={...}` becomes `count={...}` on migrated `OldThing` JSX only
- Local imports are updated when the imported binding is the one referenced by the migrated JSX
- `import { OldThing } from "..."` becomes `import { NewThing } from "..."`
- `import OldThing from "..."` becomes `import NewThing from "..."`
## Out Of Scope
- Renaming `bar` props on unrelated components
- Renaming arbitrary strings, comments, or property keys
- Renaming local declarations, exports, or re-exports that are not directly resolved from migrated JSX imports in the AST step
The workflow includes an optional AI cleanup step for edge cases where a project needs follow-up cleanup after the deterministic AST transform.
## Example
### Before
```tsx
import { OldThing } from "./ui";
export function Example() {
return <OldThing foo="x" bar={1} />;
}
```
### After
```tsx
import { NewThing } from "./ui";
export function Example() {
return <NewThing foo="x" count={1} />;
}
```
## Workflow
Workflow name: `default`
Workflow parameter: `runAiCleanup`
- Type: boolean
- Default: `true`
- Purpose: runs the optional `AI review and cleanup` step after the AST transform
Run locally:
```bash
pnpm test
pnpm dlx codemod@latest workflow validate -w workflow.yaml
pnpm dlx codemod@latest workflow run -w . -t /path/to/repo
```
Disable the AI cleanup step:
```bash
pnpm dlx codemod@latest workflow run -w . -t /path/to/repo --param runAiCleanup=false
```
## Development
```bash
pnpm test
pnpm run check-types
pnpm dlx codemod@latest workflow validate -w workflow.yaml
```
## License
MIT