This universal codemod provides possibility to replace any prop with a new one in any component
- <Component old="info" />
+ <Component new="info" />
It's likely that props might be assigned in a different manners, therefore this codemod accounts for several prop patterns.
<Component old="old" />
<Component old={"old"} />
<Component old={old} />
<Component {...props} />
<Component {...{ old: "old" }} />
<Component {...{ old }} />
<Component {...{ old: oldType }} />
If there is a pattern that you use that is not transformed, please file a feature request.
npx carbon-codemod rename-prop <target> <component-import-path> <old-prop> <new-prop>
npx carbon-codemod rename-prop src carbon-react/lib/components/button oldProp newProp
npx carbon-codemod rename-prop <target> <component-import-path> <old-prop> <new-prop> -i <component-import-name>
npx carbon-codemod rename-prop src carbon-react/lib/components/accordion oldProp newProp -i Accordion
npx carbon-codemod rename-prop src carbon-react/lib/components/button buttonType variant
import Button from "carbon-react/lib/components/button";
- <Button buttonType="primary>Button</Button>
+ <Button variant="primary">Button</Button>