git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

Added hooks.golangci-lint.settings.flags option

Open tobias-kuendig opened this issue 3 months ago • 2 comments

It is currently not possible to define any of the many golangci-lint flags: https://golangci-lint.run/docs/configuration/cli/#run

This PR adds the option to do so.

tobias-kuendig avatar Sep 30 '25 14:09 tobias-kuendig

Does hooks.golangci-lint.args = [ ... ]; work for this hook?

sandydoo avatar Oct 16 '25 20:10 sandydoo

I don't see where the args would be added to the command:

https://github.com/cachix/git-hooks.nix/blob/ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37/modules/hooks.nix#L2973

Using this config:

    golangci-lint = {
      enable = true;
      args = [ "--fix" ];
    };

The following output is generated:

 {
          "always_run": false,
          "args": [
            "--fix"
          ],
          "entry": "/nix/store/y1xfcgx6821rwynpfjpp4a8s6if3mwma-precommit-golangci-lint",
          "exclude": "^$",
          "exclude_types": [],
          "fail_fast": false,
          "files": "\\.go$",
          "id": "golangci-lint",
          "language": "system",
          "name": "golangci-lint",
          "pass_filenames": true,
          "require_serial": true,
          "stages": [
            "pre-commit"
          ],
          "types": [
            "file"
          ],
          "types_or": [],
          "verbose": false
        },

But the --fix argument is not used by the golangci-lint command.

tobias-kuendig avatar Oct 27 '25 07:10 tobias-kuendig