-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
99 lines (97 loc) · 3.89 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# ==============================================================================
# Pre-commit hook configuration
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# ==============================================================================
repos:
# ==========================================================================
# Built-in hooks
# ==========================================================================
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
# ==========================================================================
# Golang Pre-Commit Hooks | https://github.com/tekwizely/pre-commit-golang
#
# Visit the project home page to learn more about the available Hooks,
# including useful arguments you might want to pass into them.
#
# Staged Files:
# Unless configured to "always_run" (see below), hooks ONLY run when
# maching file types (usually *.go) are staged.
#
# File-Based Hooks:
# By default, hooks run against matching staged files individually.
# Currently, file-based hooks DO NOT accept user-args.
#
# Directory-Based Hooks:
# Some hooks work on a per-directory basis. The hooks run against the
# directory containing one or more matching staged files.
# Currently, directory-based hooks DO NOT accept user-args.
#
# Directory-Hook Suffixes:
# *-mod-* : Hook runs inside first module root directory going up
# $FILE path.
# *-dir-* : Hook runs using './$(dirname $FILE)' as target.
# *-pkg-* : Hook runs using '$(go list)/$(dirname $FILE)' as target.
#
# ! Multiple Hook Invocations
# ! By design, the directory-based hooks only execute against a given
# ! directory once per hook invocation.
# ! HOWEVER, due to OS command-line length limits, Pre-Commit can invoke
# ! a hook multiple times if a large number of files are staged.
#
# Repo-Based Hooks:
# Hooks named '*-repo-*' only run once (if any matching files are staged).
# They are NOT provided the list of staged files.
# Generally, repo-based hooks DO accept user-args.
#
# Repo-Hook Suffixes:
# *-repo : Hook runs with no target argument
# (good for adding custom arguments / targets)
# *-repo-dir : Hook runs using './...' as target.
# *-repo-pkg : Hook runs using '$(go list)/...' as target.
#
# Fix Suffix:
# Hooks named `*-fix` fix (modify) files directly, when possible.
#
# Aliases:
# Consider adding aliases to longer-named hooks for easier CLI usage.
#
# Useful Hook Parameters:
# - id: hook-id
# alias: hook-alias # Create an alias
# args: [arg1, arg2, ...] # Pass arguments
# always_run: true # Run even if no matching files staged
# ==========================================================================
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.4
hooks:
- id: go-build-mod
alias: build
- id: go-test-mod
alias: test
- id: go-vet-mod
alias: vet
- id: go-fmt-repo
args: ['-w']
alias: fmt
# - id: go-imports-fix # replaces go-fmt-fix
# - id: go-returns-fix # replaces go-imports-fix & go-fmt-fix
- id: go-lint
alias: lint
- id: go-critic
alias: critic
#
# GolangCI-Lint
# - Fast Multi-Linter
# - Can be configured to replace MOST other hooks
# - Supports repo config file for configuration
# - https://github.com/golangci/golangci-lint
#
# - id: golangci-lint
# alias: ci