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

Possibility to exclude globs when checking files #575

Open
Zegnat opened this issue Mar 2, 2025 · 2 comments
Open

Possibility to exclude globs when checking files #575

Zegnat opened this issue Mar 2, 2025 · 2 comments

Comments

@Zegnat
Copy link

Zegnat commented Mar 2, 2025

I would like to use v8r in a lint step of my project. But then I end up having to specify a bunch of files separately to be checked because some auto-generated files should not be checked (and/or do not have schemas).

Example: when verifying an entire repository with npx v8r "./**/*.json" it will dig deep into node_modules. Then by limiting it to npx v8r "./*.json" "./src/**/*.json" we still run into problems where package-lock.json has no schema (and really does not need to be checked).

It would be great if it could follow in the footsteps of some other linting projects and take .gitignore into account. Though that will often not cover everything. Something like an --exclude flag for the cli might be easier, for opting out specific files rather than having to opt-in everything manually.

@chris48s
Copy link
Owner

chris48s commented Mar 3, 2025

I like the idea of respecting .gitignore. Either by default or via an option. I'll take that one on board next time I have some time free to work on this project 👍

To solve your immediate issue, the glob library v8r uses supports extglob syntax, so you can run

v8r "./!(node_modules)/**/*.json" "./*.json"

to validate all json files but ignore node_modules

or

v8r "./!(node_modules|something_else)/**/*.json" "./*.json"

to ignore multiple dirs.

Maybe it would be more ergonomic to implement the ability to explicitly pass patterns to ignore as well though.

@Zegnat
Copy link
Author

Zegnat commented Mar 5, 2025

I did not know about that syntax. I will play around with it a little bit, and if it solves my direct concern I might even file a PR against the v8r docs so others will not down the same path as me 👍

I will close this issue after I have tried it out.

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