A collection of code-changing JSCodeshift's for JavaScript.
npm install -g jscodeshift
npm install uber-codemods
jscodeshift -t node_modules/uber-codemods/<codemod-name> <transform-path>
Use the -d option for a dry-run and use -p to print the output for comparison.
Replaces all uses of r-dom with React's createElement()
. After this conversion, you can optionally use the create-element-to-jsx codemod to generate jsx.
jscodeshift -t node_modules/uber-codemods/src/r-dom-to-react-create-element.js <transform-path>
Replaces all requires and imports of toReplace
with replaceWith
. Takes two options via the cli. Also replaces sub-paths in your require/import statements.
jscodeshift -t node_modules/uber-codemods/src/replace-require.js <transform-path> --toReplace="object.omit" --replaceWith="just-omit"
Replaces all requires and imports of toReplace
with the relative path to replaceWith
. Takes two options via the cli. The reason this is needed as a separate mod from replace-require
is because the relative path to replaceWith
changes relative to the current file being evaluated by jscodeshift.
jscodeshift -t node_modules/uber-codemods/src/replace-require-absolute-path.js <transform-path> --toReplace="object.omit" --replaceWith=$(pwd)/just-omit
Replaces all uses of xtend
with the es6 spread operator.
jscodeshift -t node_modules/uber-codemods/src/xtend-to-spread.js <transform-path>
MIT © Uber