Add json sorting pre-commit hook

This commit is contained in:
ViViDboarder 2022-02-28 16:31:56 -08:00
parent d8cf78b4e4
commit d368e0eaf6
2 changed files with 14 additions and 0 deletions

View File

@ -28,3 +28,10 @@ repos:
rev: v0.11.3
hooks:
- id: stylua
- repo: local
hooks:
- id: sort-json
name: sort json files with jq
language: script
entry: ./scripts/sort-json.sh
files: "(\\.json$|^neovim/packer_snapshots/)"

7
scripts/sort-json.sh Executable file
View File

@ -0,0 +1,7 @@
#! /usr/bin/env bash
set -e
for f in "$@"; do
jq --sort-keys --monochrome-output . "$f" > "$f.tmp"
mv "$f.tmp" "$f"
done