From da3d9e32bbd717ccbf15996d4b085d66c905f09b Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Thu, 5 Oct 2023 15:17:35 +0200 Subject: [PATCH] Add options for eclint hook --- modules/hooks.nix | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 1e25addd..c2395c17 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -309,8 +309,38 @@ in type = types.package; description = lib.mdDoc "The `eclint` package to use."; default = "${tools.eclint}"; - defaultText = "\${tools.eclint}"; - example = "\${pkgs.eclint}"; + defaultText = lib.literalExpression "\${tools.eclint}"; + example = lib.literalExpression "\${pkgs.eclint}"; + }; + fix = + mkOption { + type = types.bool; + description = lib.mdDoc "Modify files in place rather than showing the errors."; + default = false; + }; + summary = + mkOption { + type = types.bool; + description = lib.mdDoc "Only show number of errors per file."; + default = false; + }; + color = + mkOption { + type = types.enum [ "auto" "always" "never" ]; + description = lib.mdDoc "When to generate colored output."; + default = "auto"; + }; + exclude = + mkOption { + type = types.listOf types.str; + description = lib.mdDoc "Filter to exclude files."; + default = [ ]; + }; + verbosity = + mkOption { + type = types.enum [ 0 1 2 3 4 ]; + description = lib.mdDoc "Log level verbosity"; + default = 0; }; }; rome = @@ -1500,7 +1530,20 @@ in { name = "eclint"; description = "EditorConfig linter written in Go."; - entry = "${settings.eclint.package}/bin/eclint --fix"; + types = [ "file" ]; + entry = + let + cmdArgs = + mkCmdArgs + (with settings.eclint; [ + [ fix "-fix" ] + [ summary "-summary" ] + [ (color != "auto") "-color ${color}" ] + [ (exclude != [ ]) "-exclude ${lib.escapeShellArgs exclude}" ] + [ (verbosity != 0) "-verbosity ${toString verbosity}" ] + ]); + in + "${settings.eclint.package}/bin/eclint ${cmdArgs}"; }; rome =