prantlf / jsonlint

JSON/CJSON/JSON5 parser, syntax & schema validator and pretty-printer with a command-line client, written in pure JavaScript.
http://prantlf.github.io/jsonlint/
MIT License
38 stars 9 forks source link

How can I lint all json files in my project ignoring node_modules directory? #6

Closed Shayan-To closed 2 years ago

Shayan-To commented 4 years ago

How can I lint all json files in my project? When I run it like jsonlint --sort-keys --in-place ., it tries to run against the json files in node_modules directory. How can I ignore the node_modules directory?

prantlf commented 2 years ago

A good point! Instead of running jsonlint ., you have to list every file directory by jsonlint dir1 dir2 dir3 file1.json. Being able to exclude some paths would be a nice feature. Maybe using glob patterns to have the ultimate flexibility.

prantlf commented 2 years ago

I added support for BASH patterns in 11.2.0. Instead of specifying a directory, specify a (positive) pattern to identify all JSON files in your project and another (negative) pattern to exclude files from, the node_modules directory (from node_modules in any subdirectory):

jsonlint --sort-keys --in-place --log-files '**/*.json' '!**/node_modules'