Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gunar/js-transforms
Codemod to replace lodash for lodash/fp
https://github.com/gunar/js-transforms
Last synced: about 2 months ago
JSON representation
Codemod to replace lodash for lodash/fp
- Host: GitHub
- URL: https://github.com/gunar/js-transforms
- Owner: gunar
- Created: 2016-05-20T19:22:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-24T13:33:35.000Z (over 8 years ago)
- Last Synced: 2024-08-02T07:23:05.370Z (5 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-codemods - js-transforms - Codemod to replace lodash for lodash/fp. (Libraries / Lodash)
README
# My jscodeshift transforms
A collection of js transforms using [js-codeshift](https://github.com/facebook/jscodeshift).
## Usage
```
npm install -g jscodeshift
jscodeshift -t
```## Transforms
### [lodash-to-fp.js](lodash-to-fp.js)
It helps you refactor a codebase from lodash to lodash/fp. It assumes that you're using `_ = require('lodash')` and returns `fp = require('lodash/fp')`.
There's lots of room for improvement. That's why I'm assigning to the variable `fp`, so it's easier to fix conflicts. Then afterwards you can easily "find and replace" `fp -> _`.
This scripts takes a "better safe than sorry" approach, as to try to minimize false positives.
e.g. `_.mapValues(myValues, myFunctions)` doesn't get converted because I'd need to confirm [myFunction's arity](https://github.com/lodash/lodash/wiki/FP-Guide#fixed-arity)### [fp-to-_.js](fp-to-_.js)
It's intended to be used as a final step when converting a codebase from `lodash` to `lodash/fp`.
The transform above (`lodash-to-fp`) uses `fp` as an identifier, to allow you to manually fix conflicts.
This transform simply replaces the identifier `fp` for `_` everywhere.## License
MIT [http://gunar.mit-license.org]()