From c7b22db9a2b2e37247fdf4b994b64b70301922dd Mon Sep 17 00:00:00 2001 From: Daniel Baker Date: Sat, 14 Dec 2024 23:32:31 -0800 Subject: [PATCH] bugfix: remove before/after options from config json file A recent commit to add ordering priority to the hooks introduced new keys into the pre-commit JSON config file. These keys should not be there are they are not keys pre-commit is aware of and produce warning messages. e.g.: [WARNING] Unexpected key(s) present on local => treefmt: after, before This commit fixes it by filter out all keys with names `before` or `after` before writing the configuration to file. --- modules/pre-commit.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/pre-commit.nix b/modules/pre-commit.nix index 8ad81104..b3be2bf6 100644 --- a/modules/pre-commit.nix +++ b/modules/pre-commit.nix @@ -62,7 +62,9 @@ let { echo '# DO NOT MODIFY'; echo '# This file was generated by git-hooks.nix'; - jq . <"$rawJSONPath" + # recursively descends through the json and removes all keys with + # names `before` or `after` + jq 'del(.. | .after?) | del(.. | .before?)' <"$rawJSONPath" } >$out '' );