@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 renames —
checked→isSelected,defaultChecked→defaultSelected,disabled→isDisabled,required→isRequired labelprop → children — convertslabel="text"orlabel={expr}to children content, changing self-closing elements to open/close formdata-checked→data-selected— renames data attributes in JSX attribute valuesbui-CheckboxLabel— flags references with a// TODO(backstage-codemod)comment since this CSS class was removed
Handles named imports, aliased imports, and namespace imports.
Installation
bashyarn dlx codemod@latest run @backstage/migrate-checkbox-to-react-aria -t /path/to/target
Usage (from this repo)
bashyarn dlx codemod@latest workflow run \ -w codemods/v1.45.0/migrate-checkbox-to-react-aria/workflow.yaml \ -t /path/to/your/backstage-repo
AI fixup
For complex cases the AST transform cannot handle mechanically:
bashyarn dlx codemod@latest workflow run \ -w codemods/v1.45.0/migrate-checkbox-to-react-aria/workflow.yaml \ -t /path/to/your/backstage-repo \ --param aiFixup=true
Development
From the repo root:
bashyarn install yarn workspace @backstage/migrate-checkbox-to-react-aria test
Known limitations
bui-CheckboxLabelCSS class references are flagged with a TODO but not removed — manual review requireddata-checked→data-selectedreplacement only applies to strings within JSX attributes; CSS files need manual update- Checkboxes without a
labelprop and without existing children are not flagged — the new Checkbox requires a label via children