Iifabrish

rename-oldthing-to-newthing

Rename OldThing to NewThing

transformationmigrationreactjsx
Public
0 executions

Run locally

npx codemod 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

After

tsx

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

Disable the AI cleanup step:

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.