Skip to content

jsonvet 3.0.0

Latest

Choose a tag to compare

@simonvanlierde simonvanlierde released this 19 Oct 00:44
· 19 commits to main since this release
683c712

3.0 checks files against a JSON Schema and puts each error at its line and column, in every dialect, comments and JSON5 included. It also writes SARIF for GitHub code scanning, and it ships as a GitHub Action.

Upgrade

Set rev: v3.0.0 in .pre-commit-config.yaml, or uses: simonvanlierde/jsonvet@v3. Most hook users need nothing else. Check the breaking changes below if you run jsonvet from a directory other than its config file's, pass it unknown options from a script, match its paths in a script, or use the Rust library.

What's new

  • --schema FILE: checks each file against one JSON Schema, offline. Errors come under the rule schema, at the line and column of the value, with its JSONPath: server.json5:3:9: error[schema] "80" is not of type "integer" (at $.port). It is in every build, the hook and the Action included.
  • --format sarif: one SARIF 2.1.0 document for GitHub code scanning, with the same exit codes as text.
  • A GitHub Action: uses: simonvanlierde/jsonvet@v3 checks the repository's tracked JSON files, or the files you give it, on Linux, macOS and Windows runners. With sarif: it also writes a SARIF file for code scanning.
  • Safer output: file names and messages escape control, bidi and invisible characters, so a file name cannot forge a GitHub annotation or reorder a terminal line.
  • A DOI: each release from this one on gets a Zenodo DOI, and CITATION.cff says how to cite jsonvet.

Breaking changes

  • dialects patterns in jsonvet.toml or [tool.jsonvet] match paths relative to that file, not to the working directory.
  • An unknown option such as --x or -x exits 2 instead of 1, unless a file of that name exists.
  • Non-ASCII keys in paths print as written, $["日本"] and not $["\u65e5\u672c"].
  • Rust library: Rule::ALL and Dialect::ALL are slices, Severity and Location are #[non_exhaustive], and UnknownRule and UnknownDialect hide their text behind id() and name().

The full list, with the fixes, is in the changelog.

Install

uvx jsonvet, pip install jsonvet or cargo install jsonvet-cli. The Rust library is the jsonvet crate.