Aalexbit-codemod

migrate-button-priority-to-variant

Migrate selected React button APIs from priority to variant, including ReplayPlayPauseButton fallback updates

transformationmigrationreactbuttonvariantpriority
Public
0 executions

Run locally

npx codemod migrate-button-priority-to-variant

migrate-button-priority-to-variant

Migrates selected React button APIs from priority to variant in TypeScript and TSX codebases.

What It Changes

  • Renames JSX prop priority to variant on OverlayTrigger.Button.
  • Renames JSX prop priority to variant on OverlayTrigger.IconButton.
  • Renames JSX prop priority to variant on ReplayPlayPauseButton.
  • Renames ReplayPlayPauseButton-local *Priority bindings to *Variant when they are directly used by the migrated prop expression.
  • Renames matching type/object property signatures such as playPausePriority to playPauseVariant when they use ComponentProps<typeof ReplayPlayPauseButton>['priority'].
  • Renames ComponentProps<typeof ReplayPlayPauseButton>['priority'] to ['variant'].
  • Rewrites ReplayPlayPauseButton fallback literals from 'default' to 'secondary' inside migrated nullish-coalescing expressions.

Safety

  • Targets only **/*.{ts,tsx,mts,cts}.
  • Does not rewrite arbitrary priority props on unrelated components.
  • Does not rename unrelated identifiers that merely end with Priority.
  • Keeps the transform intentionally narrow to the button APIs named in the spec.

Workflow Parameter

  • runAiCleanup: boolean, default true.
  • When enabled, the workflow runs an optional AI review and cleanup step after the AST transform.
  • The AI step is for judgment-based cleanup of remaining local *Priority to *Variant cases tied to this migration, while avoiding unrelated rewrites.

Installation

bash

To run the local package:

bash

To disable the optional AI cleanup step:

bash

Example

tsx

becomes:

tsx

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.