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

feature request(cli): option to pass file containing filenames to lint #1166

Open
vegerot opened this issue Jan 5, 2024 · 8 comments
Open

Comments

@vegerot
Copy link
Sponsor Contributor

vegerot commented Jan 5, 2024

Problem:
I want to run quick-lint on a large project (120k files, 6m SLoC).

Approaches tried:

  • fd --extension=... | xargs -J{} quick-lint-js "{}" doesn't work with filenames with spaces in them
  • quick-lint-js $(fd ...) zsh can't handle that many arguments
  • manually calling exec("/usr/local/bin/quick-lint-js", ...) fails because it exceeds NCARGS
  • writing my own script that batches calls to quick-lint in batch sizes of NCARGS works but is inconvenient to users

Recommendation:
quick-lint CLI option that accepts the path to a file containing the paths of many files to check. This file can contain many more files than NCARGS.

$ fd --extension=.js --extension=.mjs --extension=.jsx --extension=.ts --extension=.tsx > allfiles.txt
$ quick-lint-js --file-with-filenames=allfiles.txt

Out of scope:

  • If we're going to be linting hundreds of thousands of files anyways, we might as well do some of them in parallel. Surely once we're >100k files the overhead of parallelism is worth it.
  • read filenames from stdin: $ fd --extension=.js --extension=.mjs --extension=.jsx --extension=.ts --extension=.tsx | quick-lint-js --file-with-filenames=-
@vegerot
Copy link
Sponsor Contributor Author

vegerot commented Jan 5, 2024

note: #1167 would be an alternative solution if quick-lint respected .gitignore. However, since that proposal does not, this proposal is better.

@vegerot
Copy link
Sponsor Contributor Author

vegerot commented Jan 5, 2024

I accept this task.

@strager
Copy link
Collaborator

strager commented Jan 5, 2024

Why not use xargs?

@vegerot
Copy link
Sponsor Contributor Author

vegerot commented Jan 5, 2024

So something like

$ fd --extension=.js --extension=.jsx --extension=.ts --extension=.tsx | xargs -n999999999 quick-lint-js

? Because that makes too much sense.

@vegerot
Copy link
Sponsor Contributor Author

vegerot commented Jan 5, 2024

think of the microseconds saved from quick-lint being able to do it all itself!

@vegerot
Copy link
Sponsor Contributor Author

vegerot commented Jan 5, 2024

xargs was the first thing I looked into when I played with this idea this week (after fd's builtin exec). The problem I ran into was not being able to tell xargs to wrap quotes around every argument

echo "apps/us/e2e/full-regression/src/glass-orders/tc196-tiered -fast-refund -order.test.ts" | xargs -J{} quick-lint-js {}
error: unrecognized option: -fast-refund

That's when I tried the other solutions I mentioned in the OP and forgot I had tried this! My bad

@strager
Copy link
Collaborator

strager commented Jan 6, 2024

@vegerot You should look at the -0 option of both fd and xargs. -0 on both will cause file names to be transferred without space splitting.

@strager
Copy link
Collaborator

strager commented Jan 6, 2024

Typical command: find . -name '*.ts' -print0 | xargs -0 quick-lint-js --

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

No branches or pull requests

2 participants