Bbackstage

backstage/migrate-checkbox-to-react-aria

Backstage 1.45.0: Migrate Checkbox component from Base UI to React Aria — prop renames and label to children conversion

backstagemigrationuicheckboxreact-aria1.45.0
Public
0 executions

Run locally

npx codemod @backstage/migrate-checkbox-to-react-aria

@backstage/migrate-checkbox-to-react-aria

Migrates Checkbox component usage from the Base UI implementation to the React Aria implementation introduced in @backstage/ui@0.9.0 (Backstage v1.45.0).

What it transforms

  • Prop renamescheckedisSelected, defaultCheckeddefaultSelected, disabledisDisabled, requiredisRequired
  • label prop → children — converts label="text" or label={expr} to children content, changing self-closing elements to open/close form
  • data-checkeddata-selected — renames data attributes in JSX attribute values
  • bui-CheckboxLabel — flags references with a // TODO(backstage-codemod) comment since this CSS class was removed

Handles named imports, aliased imports, and namespace imports.

Installation

bash

Usage (from this repo)

bash

AI fixup

For complex cases the AST transform cannot handle mechanically:

bash

Development

From the repo root:

bash

Known limitations

  • bui-CheckboxLabel CSS class references are flagged with a TODO but not removed — manual review required
  • data-checkeddata-selected replacement only applies to strings within JSX attributes; CSS files need manual update
  • Checkboxes without a label prop and without existing children are not flagged — the new Checkbox requires a label via children

Ready to contribute?

Build your own codemod and share it with the community.