All Projects → uber-web → Uber Codemods

uber-web / Uber Codemods

Licence: mit
Because Code Changes and Evolves

Programming Languages

javascript
184084 projects - #8 most used programming language

uber-codemods

NPM version Build Status

A collection of code-changing JSCodeshift's for JavaScript.

Install

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.

Included mods

r-dom-to-react-create-element

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.

Usage
jscodeshift -t node_modules/uber-codemods/src/r-dom-to-react-create-element.js <transform-path>
Code Examples

Before

After

replace-require

Replaces all requires and imports of toReplace with replaceWith. Takes two options via the cli. Also replaces sub-paths in your require/import statements.

Usage
jscodeshift -t node_modules/uber-codemods/src/replace-require.js <transform-path> --toReplace="object.omit" --replaceWith="just-omit"
Code Examples

Before

After

replace-require-absolute-path

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.

Usage
jscodeshift -t node_modules/uber-codemods/src/replace-require-absolute-path.js <transform-path> --toReplace="object.omit" --replaceWith=$(pwd)/just-omit

xtend-to-spread

Replaces all uses of xtend with the es6 spread operator.

Usage
jscodeshift -t node_modules/uber-codemods/src/xtend-to-spread.js <transform-path>
Code Examples

Before

After

License

MIT © Uber

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].