facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.26k stars 477 forks source link

Respect extensions cli option when filtering individual files #562

Closed robcmills closed 1 year ago

robcmills commented 1 year ago

Resolves https://github.com/facebook/jscodeshift/issues/561

facebook-github-bot commented 1 year ago

Hi @robcmills!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Daniel15 commented 1 year ago

This could go either way - it's not defined whether passing in an exact filename should bypass the extension filter or not. Changing it so everything observes the extension filter seems reasonable to me though.

lg-kialo commented 11 months ago

This could go either way - it's not defined whether passing in an exact filename should bypass the extension filter or not. Changing it so everything observes the extension filter seems reasonable to me though.

@Daniel15 I disagree, for a single filename supplying the extension twice (once in the filename and once as --extension flag) seems redundant.

Daniel15 commented 11 months ago

@lg-kialo The --extension flag is optional. You don't have to provide it.

lg-kialo commented 11 months ago

@Daniel15 you do have to provide it if you want to transform files with extension different than .js. Before version 0.15.1 jscodeshift -t transform.ts fileToTransform.tsx used to work, now one is forced to use jscodeshift -t transform.ts --extensions=tsx fileToTransform.tsx

lg-kialo commented 11 months ago

My suggestion would be that if no --extensions flag is passed, we don't filter by extension at all. Instead of filtering only files with the default extension (.js) as it is now.