Dockerized jsonlint with various versions, easy to use and easy to integrate with CI.
docker run --rm -v $PATH_TO_JSON:/json peterdavehello/jsonlint jsonlint -q JSON_FILE.json
# Please replace "$PATH_TO_JSON" with your custom path,
# and replace "JSON_FILE.json" with your real json file filename.
Just like above, but you can specify version of jsonlint, for example:
docker run --rm -v $PATH_TO_JSON:/json peterdavehello/jsonlint:1.6.3 jsonlint -q JSON_FILE.json
# Please replace "1.6.3" with the version number you want.
# Don't forget to replace "$PATH_TO_JSON" & "JSON_FILE.json".
Enable Docker service in your .travis.yml
:
services:
- docker
And use the same command in the scripts
part as the command line mentions, for example:
services:
- docker
scripts:
- docker run --rm -v $TRAVIS_BUILD_DIR:/json peterdavehello/jsonlint:1.6.3 jsonlint -q example.json
This will lint a example json file called example.json
Add this block to your .gitlab-ci.yml
:
jsonlint:
stage: lint
variables:
jsonlint_version: "1.6.3"
image: peterdavehello/jsonlint:$jsonlint_version
only:
changes:
- "**/*.json"
script:
- find . -name "*.json" | xargs -n 1 jsonlint -q
Replace "1.6.3" with the version you want to use, you can also use "latest" for the very new version.
Just pass -h
/--help
to jsonlint to get its help message, for example:
$ docker run --rm peterdavehello/jsonlint jsonlint --help
Usage: jsonlint [file] [options]
file file to parse; otherwise uses stdin
Options:
-v, --version print version and exit
-s, --sort-keys sort object keys
-i, --in-place overwrite the file
-t CHAR, --indent CHAR character(s) to use for indentation [ ]
-c, --compact compact error display
-V, --validate a JSON schema to use for validation
-e, --environment which specification of JSON Schema the validation file uses [json-schema-draft-03]
-q, --quiet do not print the parsed json to STDOUT [false]
For more details, check out the jsonlint project page.
Build command, you need to specify a valid jsonlint version argument to jsonLINT_VERSION
:
docker build --build-arg JSONLINT_VERSION="1.6.3" -t docker-jsonlint .
# Replace "docker-jsonlint" with the preferred image name
You can find a valid version on jsonlint npm registry page, or just poke the registry to retrieve more details.