migrate-button-priority-to-variant
Migrate selected React button APIs from priority to variant, including ReplayPlayPauseButton fallback updates
# 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
codemod run migrate-button-priority-to-variant
```
To run the local package:
```bash
codemod workflow run -w .
```
To disable the optional AI cleanup step:
```bash
codemod workflow run -w . --param runAiCleanup=false
```
## Example
```tsx
type Props = {
playPausePriority?: ComponentProps<typeof ReplayPlayPauseButton>['priority'];
};
function Example({ playPausePriority }: Props) {
return (
<ReplayPlayPauseButton
priority={playPausePriority ?? (isFinished || isPlaying ? 'primary' : 'default')}
/>
);
}
```
becomes:
```tsx
type Props = {
playPauseVariant?: ComponentProps<typeof ReplayPlayPauseButton>['variant'];
};
function Example({ playPauseVariant }: Props) {
return (
<ReplayPlayPauseButton
variant={playPauseVariant ?? (isFinished || isPlaying ? 'primary' : 'secondary')}
/>
);
}
```
## Development
```bash
pnpm test
codemod workflow validate -w .
codemod publish
```
## License
MIT