Skip to content
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

feat(cli): Support passing class flags on CLI #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tbranyen
Copy link

@tbranyen tbranyen commented Feb 7, 2024

While working on transforming our legacy codebase I'm finding that we have hundreds of files that are not completely converted and need additional processing. I added react-codemod as a starting point to go from createReactClass -> React.createClass -> class extends React.Component, which is in the middle of our codemod stack. I was able to use the class transform in isolation running directly from in node and filling in the options/jscodeshiftapi/etc. Unfortunately this doesn't work for all files. I found many issues with jscodeshift getting into infinite loops that did not appear when invoking react-codemod from the terminal.

The problem with invoking from the terminal in node via something like execSync is that it uses inquirer to be interactive. This PR makes it so that all class options can be specified on the terminal.

Here is an example of what the command I'm running looks like now:

npx react-codemod class /home/tim/netflix/tmp.jsx --force --parser=babel --classFlow=false --classRemoveRuntimePropTypes=false --classPureComponent=false

 OKK /home/tim/netflix/tmp.jsx
All done. 
Results: 
0 errors
0 unmodified
0 skipped
1 ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant