-
Notifications
You must be signed in to change notification settings - Fork 2k
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 codemods: React.js #13070
Add codemods: React.js #13070
Conversation
db01e2f
to
e2c6648
Compare
e2c6648
to
e9f7b27
Compare
1137323
to
040d869
Compare
fa3640b
to
7e7f003
Compare
How well does this work? Last time I tried it on the Calypso root dir I think it only changed some 4 components or so. (I'm speculating it might be due to our use of |
@ockham: I was under the impression it worked pretty reliably from my initial testing. To verify, I ran the
Here are some issues I discovered from the successfully processed files:
|
7e7f003
to
185d872
Compare
@@ -0,0 +1,41 @@ | |||
#!/usr/bin/env node |
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.
This file seems to be missing the executable bit currently.
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.
Fixed!
package.json
Outdated
@@ -184,6 +184,7 @@ | |||
"nock": "8.0.0", | |||
"nodemon": "1.4.1", | |||
"react-addons-test-utils": "15.4.0", | |||
"react-codemod": "github:reactjs/react-codemod#d6563d9", |
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.
Is there not a published version of this? Otherwise, github links can be shorter:
reactjs/react-codemod#d6563d9
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.
There doesn't seem to be an npm
AFAICS. FWIW, I added the devDep without SHA stamp (thus tracking master
) a while back.
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.
@gwwar Unfortunately, react-codemod isn't published on npm
nor are releases properly tagged on their git repo, so I'll go ahead and shorten this dependency to your suggestion!
89a0a74
to
b2aab6e
Compare
b2aab6e
to
8d0c017
Compare
@jsnmoon This PR needs a rebase |
5555921
to
8cebbca
Compare
@jsnmoon This PR needs a rebase |
8cebbca
to
33c96eb
Compare
Rebased, and re-shrunk. This has been lingering for a while, so I think it'd be good to get it in soonish.
Is this stuff going to be/has been fixed upstream? If so, it'd be obviously nice to continue to use upstream. Anyway, it'd be cool if you could link to upstream PRs from here so we can keep track. One more bit of feedback: Since this PR contains a codemod to use the new standalone |
Oh, same for |
Good point! I have reactjs/react-codemod#122, reactjs/react-codemod#132, reactjs/react-codemod#156, and reactjs/react-codemod#157 open right now. Adding this to the original PR. Unfortunately, I'm not sure if my PRs will ever land given that they've just been... sitting there in the repo. |
33c96eb
to
41b634f
Compare
Done! Rebased and re-wrapped. I'll aim to land this sometime this/next week! |
41b634f
to
8c187b4
Compare
Re-based and re-shrunk one last time. As discussed with @jsnmoon in Slack, I'm going to merge this on his behalf! |
Thanks so much @ockham! :) |
Part of #11688.
This change adds codemods in
bin/codemods
for porting legacy React.js code.react-create-class
: Safely replacesReact.createClass
withReact.Component
orcreateReactClass
from'create-react-class'
. (source)react-prop-types
: ReplacesReact.PropTypes
withprop-types
; applicable for React 15.5+ where React.PropTypes has been extracted to a separate package. (source)Please note that this currently uses by personal fork with couple of bug fixes on top of react-codemod. The following PRs have been filed upstream:
Todo:
client/
client/
Issues:
react-create-class
codemodreact
import for JSX files when falling back tocreateClass
importclient/post-editor/media-modal/gallery/preview-shortcode.jsx
(react import unnecessarily removed)client/post-editor/editor-ground-control/index.jsx
(multiple imports are removed)client/my-sites/themes/thanks-modal.jsx
(malformed import after transform)client/post-editor/media-modal/gallery/remove-button.jsx
client/post-editor/post-editor.jsx