Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uber-web/uber-codemods
Because Code Changes and Evolves
https://github.com/uber-web/uber-codemods
codemod javascript jscodeshift
Last synced: 3 months ago
JSON representation
Because Code Changes and Evolves
- Host: GitHub
- URL: https://github.com/uber-web/uber-codemods
- Owner: uber-web
- License: mit
- Created: 2016-10-06T20:40:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T06:11:16.000Z (about 2 years ago)
- Last Synced: 2024-04-14T15:38:08.000Z (10 months ago)
- Topics: codemod, javascript, jscodeshift
- Language: JavaScript
- Size: 419 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-codemods - uber-codemods - Because Code Changes and Evolves. (Organization specific Codemods / ant-design)
README
# uber-codemods
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]> A collection of code-changing [JSCodeshift's](https://github.com/facebook/jscodeshift) for JavaScript.
## Install
```
npm install -g jscodeshift
npm install uber-codemods
jscodeshift -t node_modules/uber-codemods/
```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](https://github.com/uber/r-dom) with React's `createElement()`. After this conversion, you can optionally use the [create-element-to-jsx codemod](https://github.com/reactjs/react-codemod#create-element-to-jsx) to generate jsx.
##### Usage
```sh
jscodeshift -t node_modules/uber-codemods/src/r-dom-to-react-create-element.js
```##### Code Examples
[Before](src/__testfixtures__/r-dom-to-react-create-element.input.js)
[After](src/__testfixtures__/r-dom-to-react-create-element.output.js)
### `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
```sh
jscodeshift -t node_modules/uber-codemods/src/replace-require.js --toReplace="object.omit" --replaceWith="just-omit"
```##### Code Examples
[Before](src/__testfixtures__/replace-require.input.js)
[After](src/__testfixtures__/replace-require.output.js)
### `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
```sh
jscodeshift -t node_modules/uber-codemods/src/replace-require-absolute-path.js --toReplace="object.omit" --replaceWith=$(pwd)/just-omit
```### `xtend-to-spread`
Replaces all uses of [`xtend`](https://github.com/Raynos/xtend) with the es6 spread operator.
##### Usage
```sh
jscodeshift -t node_modules/uber-codemods/src/xtend-to-spread.js
```##### Code Examples
[Before](src/__testfixtures__/xtend-to-spread.input.js)
[After](src/__testfixtures__/xtend-to-spread.output.js)
## License
MIT © [Uber](https://uber.com)
[npm-image]: https://badge.fury.io/js/uber-codemods.svg
[npm-url]: https://npmjs.org/package/uber-codemods
[travis-image]: https://travis-ci.org/uber-web/uber-codemods.svg?branch=master
[travis-url]: https://travis-ci.org/uber-web/uber-codemods