Browse Source

Add json sorting pre-commit hook

master
ViViDboarder 4 months ago
parent
commit
d368e0eaf6
  1. 7
      .pre-commit-config.yaml
  2. 7
      scripts/sort-json.sh

7
.pre-commit-config.yaml

@ -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

@ -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
Loading…
Cancel
Save