-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add npm-react-codemod #3506
Add npm-react-codemod #3506
Conversation
Options to [recast](https://github.com/benjamn/recast)'s printer can be provided | ||
through the `printOptions` command line argument | ||
|
||
* `react-codemod use-strict <file> --printOptions='{"quote":"double"}'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use-strict doesn't exist, perhaps use a real example
Lots of lint to fix :) You might need a custom |
var reactTools = require('react-tools'); | ||
|
||
function process(source) { | ||
return reactTools.transform(source, {harmony: true, stripTypes: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 space indent? you monster.
TRANSFORM=$1 | ||
shift | ||
|
||
$DIR/node_modules/.bin/jscodeshift -t $DIR/build/$TRANSFORM.js $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this isn't going to work on Windows. I thought we were going to make this a js script that used node to shell out to jscodeshift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh, that's no fun. Let me see what I can do.
fun fact, I can't actually use |
I'm on v0.10.37 and it works fine for me? Should I move back to var's? |
Changed to use babel. |
ok, should be good to go |
jest now fails because it picks up your transform tests but jscodeshift isn't in the root package.json. |
oh damn, why didn't travis not catch that? :( |
oh hmm, I thought i actually checked that locally…
Because we're having issues with travis and jest. |
This adds
react-codemod
with the following codemods:getDOMNode
toReact.findDOMNode
PureRenderMixin
toshouldComponentUpdate
usingshallowCompare
React.createClass
to ES6 classes.See the README for a detailed explanation of how the codemods work.
The codemods are based on jscodeshift and the project structure is based on js-codemod.
The tests can be run using
npm test
. Publishing this to npm should work as I have fiddled around withjs-codemod
enough.@zpao can we pull in #3355 for React 0.13.2? I thought it was going into 0.13.1 but I guess it didn't :)