CodeMod
Created: 2018-08-06 15:57:15 -0700 Modified: 2018-08-13 13:40:53 -0700
Background (reference)
Section titled Background (reference)I had to use Yarn to install this, which meant I had to stop pointing at Sinopia and start pointing at the official NPM repository:
- npm config set registry https://registry.npmjs.org/
- yarn global add jscodeshift
- Make a directory where you want codemod to reside (e.g. C:tools)
- Run their other setup steps like “git clone”
- Set the registry back to normal: npm config set registry http://104.42.195.223:4873/
Sample usage
Section titled Sample usageI wanted to convert “.bind” to arrow functions in React, so I used this CodeMod.
- First, navigate to a directory that has a package.json containing React (or maybe a subfolder of this would work too).
- Despite installing jscodeshift globally, Windows doesn’t let me just use “jscodeshift” because Yarn’s global bin folder isn’t automatically in my PATH. I found the folder by doing “yarn global bin”: C:Usersagd13_000scooppersistyarnbinbin
- C:/Users/agd13_000/scoop/persist/yarn/bin/bin/jscodeshift -t C:/tools/react-codemod/transforms/manual-bind-to-arrow.js D:/Code/BotLand/botland/packages/client/public/javascripts/react_and_redux/containers/blueprintandscripteditor.js