Skip to content

v2.0.0: check-json5 is now jsonvet, rewritten in Rust

Choose a tag to compare

@simonvanlierde simonvanlierde released this 13 Oct 22:34
· 33 commits to main since this release
118b80e

check-json5 is now jsonvet, rewritten in Rust. It gives the same pass or fail as 1.4.1 on every file: I ran both on 20,114 files in JSON5 and strict mode, 40,228 runs, and they agree on all of them.

Upgrade

Set rev: v2.0.0 in .pre-commit-config.yaml. The check-json5 hook id, the check-json5 command and --strict keep working until 3.0, and the old repository URL redirects. To use the new options, switch to the jsonvet hook id.

What's new

  • Six dialects on one parser: JSON, I-JSON, JSONC, JWCC (HuJSON), JSON5 and JSON Lines, picked by file extension or with --dialect.
  • Rules with severities: duplicate-key, invalid-number, byte-order-mark and more, changed with --error, --warn, --ignore and --max-warnings.
  • A config file: jsonvet.toml, or [tool.jsonvet] in pyproject.toml.
  • Faster, with no Python start-up: the hook installs a prebuilt binary. It is 3x faster on 1,100 small config files and 1,398x faster on a 1.8 MB JSON5 file.

Breaking changes

  • Each output line gains its severity and rule, as in file:4:5: error[duplicate-key] duplicate key $.a (first at 2:5), and syntax errors use new wording.
  • Lines end at every JSON5 line terminator, so positions after a lone CR, U+2028 or U+2029 differ from 1.x.
  • The importable Python module is gone. The wheel brings the jsonvet and check-json5 commands.

The full list is in the changelog.

Install

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