Skip to content

feat(cli): codemod Badge dot mode → StatusDot - #949

Merged
cixzhang merged 1 commit into
mainfrom
navi/codemod-badge-dot-to-statusdot
Mar 28, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/codemod-badge-dot-to-statusdot

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a codemod that migrates XDSBadge dot mode (shape="dot") to XDSStatusDot.

What it does

  • Detects shape="dot" prop on XDSBadge
  • Converts to XDSStatusDot with variant mapping: success→positive, error→negative, others unchanged
  • Passes through label directly (no placeholder needed — Badge already has it)
  • Handles imports: adds StatusDot, removes Badge only when no other usages remain
  • Passes through all other props (xstyle, className, ref, data-testid, spreads)
  • Removes shape prop (StatusDot doesn't have it)

Scope

This codemod only converts shape="dot" Badge usages to StatusDot. It does not:

  • Remove the shape prop from XDSBadge itself (separate breaking change)
  • Rename Badge's own variant enums (success/error stay as-is on pill badges)

The variant mapping (success→positive, error→negative) only applies during the Badge→StatusDot migration, since StatusDot uses different variant names.

Test coverage

12 test cases covering: basic transform, variant mapping, pill badge exclusion, icon badge exclusion, import handling, mixed usage, prop passthrough, default variant, label passthrough.

Dogfooding

Ran on the XDS repo — Badge.stories.tsx dot examples migrated correctly. Badge's own test file was also transformed (expected) but reverted since those tests should keep testing shape="dot" until the prop is removed.

Closes #945


@cixzhang
cixzhang requested a review from josephfarina as a code owner March 28, 2026 20:53
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 28, 2026
@github-actions

github-actions Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 11.3KB 18.0KB 2.8KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Adds migrate-badge-dot-to-statusdot codemod that converts XDSBadge
shape="dot" usages to XDSStatusDot with proper variant mapping
(success→positive, error→negative).

- Detects shape="dot" prop as the dot mode signal
- Maps variants, passes through label and other props
- Handles import addition/removal
- 12 test cases covering all edge cases
- Dogfooded on repo: Badge.stories.tsx dot examples migrated

Closes #945

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang force-pushed the navi/codemod-badge-dot-to-statusdot branch from f711059 to 6c07ef8 Compare March 28, 2026 21:07
@cixzhang

Copy link
Copy Markdown
Contributor Author

Dogfooding notes

The codemod was run against the XDS repo itself. It correctly transformed:

  • apps/storybook/stories/Badge.stories.tsx — 5 dot badges → StatusDot ✅

It also transformed packages/core/src/Badge/XDSBadge.test.tsx (the Badge component's own tests). That change was reverted — Badge's tests should keep testing shape="dot" until the prop is actually removed from the component. The codemod is working correctly; it just can't distinguish "component's own test" from "consumer code."

This will also serve as a smoke test for the codemod CI validation pipeline (#912) — the storybook dogfood change should be reproducible by the codemod.

@cixzhang
cixzhang merged commit 351845b into main Mar 28, 2026
15 checks passed
cixzhang added a commit that referenced this pull request Mar 28, 2026
Badge dot mode is migrated to StatusDot via codemod (#949).
Remove the DotIndicators story, StatusDot import, and shape
argType control from Badge storybook.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Mar 28, 2026
Badge dot mode is migrated to StatusDot via codemod (#949).
Remove the DotIndicators story, StatusDot import, and shape
argType control from Badge storybook.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 4, 2026
- Fix token names: --color-background-{color} / --color-text-{color}
- Remove shape prop and dot mode (codemod shipped in #949)
- Add non-semantic colors to XDSBadgeVariantMap
- Remove dot references from docs, tests, and stories

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 4, 2026
- Fix token names: --color-background-{color} / --color-text-{color}
- Remove shape prop and dot mode (codemod shipped in #949)
- Add non-semantic colors to XDSBadgeVariantMap
- Remove dot references from docs, tests, and stories

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang deleted the navi/codemod-badge-dot-to-statusdot branch April 9, 2026 14:30
cixzhang added a commit that referenced this pull request Apr 26, 2026
Adds migrate-badge-dot-to-statusdot codemod that converts XDSBadge
shape="dot" usages to XDSStatusDot with proper variant mapping
(success→positive, error→negative).

- Detects shape="dot" prop as the dot mode signal
- Maps variants, passes through label and other props
- Handles import addition/removal
- 12 test cases covering all edge cases
- Dogfooded on repo: Badge.stories.tsx dot examples migrated

Closes #945

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 26, 2026
Badge dot mode is migrated to StatusDot via codemod (#949).
Remove the DotIndicators story, StatusDot import, and shape
argType control from Badge storybook.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
Adds migrate-badge-dot-to-statusdot codemod that converts XDSBadge
shape="dot" usages to XDSStatusDot with proper variant mapping
(success→positive, error→negative).

- Detects shape="dot" prop as the dot mode signal
- Maps variants, passes through label and other props
- Handles import addition/removal
- 12 test cases covering all edge cases
- Dogfooded on repo: Badge.stories.tsx dot examples migrated

Closes #945

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
Badge dot mode is migrated to StatusDot via codemod (#949).
Remove the DotIndicators story, StatusDot import, and shape
argType control from Badge storybook.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
Adds migrate-badge-dot-to-statusdot codemod that converts XDSBadge
shape="dot" usages to XDSStatusDot with proper variant mapping
(success→positive, error→negative).

- Detects shape="dot" prop as the dot mode signal
- Maps variants, passes through label and other props
- Handles import addition/removal
- 12 test cases covering all edge cases
- Dogfooded on repo: Badge.stories.tsx dot examples migrated

Closes #945
cixzhang added a commit that referenced this pull request Jun 21, 2026
Badge dot mode is migrated to StatusDot via codemod (#949).
Remove the DotIndicators story, StatusDot import, and shape
argType control from Badge storybook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vibe Test: StatusDot vs Badge dot — LLM component selection

1 participant