https://github.com/rip21/ramda-codemod
Simple codemod that adds import to ramda to all js/jsx files with R global variable.
https://github.com/rip21/ramda-codemod
codemod global jscodeshift ramda ramdajs
Last synced: 6 months ago
JSON representation
Simple codemod that adds import to ramda to all js/jsx files with R global variable.
- Host: GitHub
- URL: https://github.com/rip21/ramda-codemod
- Owner: RIP21
- License: mit
- Created: 2017-12-12T11:38:23.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T13:13:32.000Z (almost 8 years ago)
- Last Synced: 2025-03-01T10:06:53.643Z (7 months ago)
- Topics: codemod, global, jscodeshift, ramda, ramdajs
- Language: JavaScript
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ramda-codemod ðŸ›
It's a simple codemod to add explicit import for `ramda` for files which are using
it as `R` global variable.## Why?
`ProvidePlugin` for `Webpack` for globals such as `R` for global `ramda` import doesn't work properly with `babel-plugin-ramda`
so to fix it you need a lot of manual work. This codemod here to do it automate it for you.## Input/Output
```javascript
R.map();
``````javascript
import R from 'ramda';
R.map();
```## Usage
1. Install jscodeshift`npm i -g jscodeshift`
2. Download `R-globals-add-explicit-import.js` from this repo or download it like
`npm i ramda-codemod` and take it from `node_modules/ramda-codemod/R-globals-add-explicit-import.js`
3. In root of the project with sources under `/src` for example call
`jscodemode -t /R-globals-add-explicit-import.js ./src --noSemi=true`
4. PROFIT!## Run Options
* `noSemi` - removes `;` from the import statement :)
* `useDouble` - wraps with `"` instead of `'` so `import R from "ramda";`
* `useRequire` - instead of ES6 imports uses require() function.## IT DOESN'T WORK!!!
If you use some other global variable which is differentiate from `R` then, I'm sorry, it will not work :)