Skip to content

Commit b9650f1

Browse files
authored
Merge pull request #553 from gigamonster256/yamlfmt-linting
yamlfmt: allow formatting during hook run
2 parents 4e78441 + 129cb47 commit b9650f1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

modules/hooks.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,12 @@ in
18751875
default = "";
18761876
example = ".yamlfmt";
18771877
};
1878+
lint-only =
1879+
mkOption {
1880+
type = types.bool;
1881+
description = "Only lint the files, do not format them in place.";
1882+
default = true;
1883+
};
18781884
};
18791885
};
18801886
};
@@ -3906,10 +3912,10 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
39063912
cmdArgs =
39073913
mkCmdArgs
39083914
(with hooks.yamlfmt.settings; [
3909-
# Exit non-zero on changes
3910-
[ true "-lint" ]
3911-
# But do not print the diff
3912-
[ true "-quiet" ]
3915+
# Exit with non-zero status if the file is not formatted
3916+
[ lint-only "-lint" ]
3917+
# Do not print the diff
3918+
[ lint-only "-quiet" ]
39133919
# See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery
39143920
[ (configPath != "") "-conf ${configPath}" ]
39153921
]);

0 commit comments

Comments
 (0)