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

Process all extensions by default #583

Closed
wants to merge 1 commit into from

Conversation

trivikr
Copy link
Contributor

@trivikr trivikr commented Feb 20, 2024

Description

Fixes: #582

Testing

Before

The ts files are not processed by default

$ ../jscodeshift/bin/jscodeshift.js example.ts 2>&1 | head -n 1
No files selected, nothing to do.

The extensions had to be explicitly passed

$ ../jscodeshift/bin/jscodeshift.js --extensions=ts example.ts 2>&1 | head -n 1
Processing 1 files...

By default, the extensions is set to js

$ ../jscodeshift/bin/jscodeshift.js --help | grep -A 1 extensions
      --extensions=EXT          transform files with these file extensions (comma separated list)
                                (default: js)

After

The ts files are processed without requiring to pass extensions

$ ../jscodeshift/bin/jscodeshift.js example.ts 2>&1 | head -n 1                
Processing 1 files...

The ts files are skipped if extensions do not allow it

$ ../jscodeshift/bin/jscodeshift.js --extensions=js example.ts 2>&1 | head -n 1
No files selected, nothing to do.

The ts files are process if extensions request for it

$ ../jscodeshift/bin/jscodeshift.js --extensions=ts example.ts 2>&1 | head -n 1
Processing 1 files...

By default, the extensions is not set

$ ../jscodeshift/bin/jscodeshift.js --help | grep -A 1 extensions
      --extensions=EXT          transform files with these file extensions (comma separated list)
      --(no-)fail-on-error      Return a non-zero code when there are errors

@Daniel15
Copy link
Member

This seems reasonable to me. What did old versions of jscodeshift do? Could this break anyone's workflow if they upgrade from jscodeshift < 0.15.1?

@trivikr
Copy link
Contributor Author

trivikr commented Feb 21, 2024

What did old versions of jscodeshift do?

As per this bug report, the extensions were not respected #561
I don't know how many versions the bug was present though.

Could this break anyone's workflow if they upgrade from jscodeshift < 0.15.1?

The only breaking change I can think of is that jscodeshift will start processing other files by default.
It might surface parser failures - depending on how parser behaves.

Should we limit the default to only supported extensions, i.e. cjs,es,es6,js,jsx,mjs,ts,tsx, like it's done downstream in aws/aws-sdk-js-codemod#770?

@trivikr trivikr marked this pull request as draft February 21, 2024 01:25
@trivikr
Copy link
Contributor Author

trivikr commented Feb 21, 2024

Should we limit the default to only supported extensions, i.e. cjs,es,es6,js,jsx,mjs,ts,tsx, like it's done downstream in aws/aws-sdk-js-codemod#770?

I think #584 is a safer fix, as it's more explicit.

I changed this PR to draft, and it can be closed without merge.

@Daniel15
Copy link
Member

Thanks!

@Daniel15 Daniel15 closed this Feb 21, 2024
@trivikr trivikr deleted the extensions-skip-default branch February 22, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] jscodeshift@0.15.1 ignores the files not starting with .js extension by default
3 participants