Bbackstage

backstage/migrate-collapsible-to-accordion

Backstage 1.45.0: Migrate Collapsible compound component to Accordion — Collapsible.Root/Trigger/Panel to Accordion/AccordionTrigger/AccordionPanel

backstagemigrationuicollapsibleaccordion1.45.0
Public
0 executions

Run locally

npx codemod @backstage/migrate-collapsible-to-accordion

@backstage/migrate-collapsible-to-accordion

Migrates Collapsible compound component usage to Accordion as introduced in @backstage/ui@0.9.0 (Backstage v1.45.0).

What it transforms

  • Import replacementimport { Collapsible } from '@backstage/ui'import { Accordion, AccordionTrigger, AccordionPanel } from '@backstage/ui'
  • Component renamesCollapsible.RootAccordion, Collapsible.TriggerAccordionTrigger, Collapsible.PanelAccordionPanel
  • Simple render prop conversion<Collapsible.Trigger render={(props) => <button {...props}>Label</button>} /><AccordionTrigger>Label</AccordionTrigger>
  • Complex render prop — adds a {/* TODO(backstage-codemod) */} comment for render props that cannot be mechanically converted
  • Handles aliased imports (import { Collapsible as Collapse })

Installation

bash

Usage (from this repo)

bash

AI fixup

For complex render prop patterns the AST transform cannot handle:

bash

Development

From the repo root:

bash

Known limitations

  • Namespace imports (import * as UI from '@backstage/ui' with <UI.Collapsible.Root>) are not supported — these must be migrated manually
  • Self-closing render elements with props (e.g., render={(props) => <Icon {...props} />}) are treated as complex cases requiring manual review
  • Props on Collapsible.Trigger other than render (e.g., id, className) are preserved in the complex-render path but may be lost in the simple-render extraction

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.