This is a pre-commit hook which verifies that .json
files in a repository are valid JSON5. The JSON5 format is similar to JSON, but it permits comments, trailing commas, and more. It is similar to the so-called "JSONC" (JSON with Comments) format, but JSON5 has an actual specification.
This hook is a drop-in replacement for the check-json
hook from the official pre-commit-hooks repository. A file succeeds when it can be loaded by the json5 library. (In contrast, check-json
uses the built-in json library.)
In .pre-commit-config.yaml
under the repos:
section, add the following:
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
(The original check-json
hook should probably be removed in case it is already included.)
The actual code this hook was written by @asottile and various contributors to the official pre-commit-hooks repository. The current author (Ben Mares) replaced the json
library with json5
and published it as a separate hook.
This hook is published under the MIT license. The original pre-commit-hooks collection (from which this hook is derived) is also published under the MIT license, included here.