-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix(codemod): Pass codemod options to jscodeshift script #2137
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
.options({ | ||
'ignore-config': { | ||
type: 'string', | ||
describe: 'Ignore files if they match patterns sourced from a configuration file (e.g. a .gitignore)', | ||
default: '', | ||
}, | ||
'ignore-pattern': { | ||
type: 'string', | ||
describe: 'Ignore files that match a provided glob expression (e.g. **/dist/**)', | ||
default: '**/node_modules/**', | ||
}, | ||
verbose: { | ||
type: 'number', | ||
describe: 'Show more information about the transform process', | ||
default: 0, | ||
choices: [0, 1, 2] | ||
}, | ||
}) |
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.
Putting these options here allows them to be available for all our codemod scripts.
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.
Options are pulls from the jscodeshift docs: https://github.com/facebook/jscodeshift#usage-cli
Passing run #5521 ↗︎
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
``` | ||
|
||
> Note: These codemods only work on .js, .jsx, .ts, and .tsx extensions. You may need to make some manual changes in other file types (.json, .mdx, .md, etc.). | ||
> Note: These codemods only work on .js, .jsx, .ts, and .tsx extensions. You may need to make some | ||
> manual changes in other file types (.json, .mdx, .md, etc.). |
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.
why is in
highlighted differently here?
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.
That's GitHub trying to syntax highlight correctly and making a mistake. It thinks it's a keyword.
should this go into support as well? |
It could go to support, but I'm mostly wanting these improvement for folks who still need to move to v8 (and eventually v9). Most consumers are on v7 already. |
Summary
Fixes: #2136
The codemod was ignoring valid JSCodeshift options that are helpful to optimize the script. This patch allows
--ignore-pattern
,--ignore-config
, and--verbose
to be passed through. I also set the codemod to ignorenode_modules
directories by default and updated the docs.Release Category
Codemods
Checklist
ready for review
has been added to PRFor the Reviewer
Where Should the Reviewer Start?
Areas for Feedback? (optional)
Testing Manually
There's not a great way to test this manually, but if the codemod tests pass, it works. I added the output of running this updated script in another consumer repo to show that it works as expected.
Screenshots or GIFs (if applicable)
Thank You Gif (optional)