From f13fbbd922fcd5b60f8544096a9415753f81e782 Mon Sep 17 00:00:00 2001 From: Matthew Hughes Date: Sat, 30 Mar 2024 17:38:22 +0000 Subject: [PATCH] Add `pre-commit` hook to run `config verify` Add this as a way to easily ensure configs stay valid. Filenames are not passed to the hook, this means For the default case (config in one of the default searched files), the config is picked up automatically and there's nothing extra to configure. For the case of a non-standard config setup the hook can be configured like repos: - repo: https://github.com/golangci/golangci-lint rev: v1.57.2 hooks: - id: golangci-lint-config-verify # config is kept at '.golangci-config.yaml' files: \.golangci-config\.yaml args: ['--config', '.golangci-config.yaml'] --- .pre-commit-hooks.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 2e622bc5df3c..dea4b598a090 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -14,3 +14,10 @@ language: golang require_serial: true pass_filenames: false +- id: golangci-lint-config-verify + name: golangci-lint-config-verify + description: Verifies the configuration file + entry: golangci-lint config verify + files: '\.golangci\.(?:yml|yaml|toml|json)' + language: golang + pass_filenames: false