This repository contains a codemod script for converting React codebases from Radium to glamor automatically. Eventually this will become a place for all sorts of JS migrations, but there's just one for now.
npm install -g jscodeshiftgit clone https://github.com/EDITD/codemods.gitor download a zip file fromhttps://github.com/EDITD/codemods/archive/master.zip- Run
npm installoryarnin the codemods directory jscodeshift -t <codemod-script> <path>- Use the
-doption for a dry-run and use-pto print the output for comparison
This does a few things in order to move a codebase from Radium to glamor completely.
- Removes all
Radiumimports and calls - Converts
style={someStyles}to{...css(someStyles)}in JSX when the components are DOM components from React. Props to any other components are left as they are. If it's not possible to statically analyse whether the expression should be spread and passed intocssthen we add comments leading withTODO_RADIUM_TO_GLAMOR. - Adds
import { css } from "glamor"to all files that need it
Options to recast's printer can be provided
through the printOptions command line argument
jscodeshift -t transform.js <path> --printOptions='{"quote":"double"}'Please feel free to make a Pull Request with any improvements!