-
Notifications
You must be signed in to change notification settings - Fork 2
/
.pre-commit-config.yaml
104 lines (98 loc) · 2.42 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
100
101
102
103
104
---
# Configuration of git pre-commit hooks:
# https://pre-commit.com/
#
# In a newly cloned git repo, run the following commands to install the
# pre-commit hooks into .git/hooks/pre-commit:
# pip3 install pre-commit
# pre-commit install
#
# After that, `git commit` will automatically run the pre-commit hooks.
#
# Run all checks:
# pre-commit run --all
#
# Run trailing-whitespace check for common/workspace/*.go:
# pre-commit run trailing-whitespace --files common/workspace/*.go
#
# Run all checks for common/workspace/*.go::
# pre-commit run --files common/workspace/*.go
# Skip pre-commit hooks:
#
# In some situations, for example, when fixing legacy codes, it is desirable to
# skip pre-commit hooks. You can do so via the -n option of git-commit, as the
# follows:
# git commit -n
# However, please DO NOT use this unless you absolutely have to.
exclude: >
(?x)^(
.*\.pb\.go| # Protobuf files
.*\.pb\.gw\.go| # Protobuf gateway files
.*\.pb\.validate\.go| # Protobuf validate files
.*\.swagger\.json| # Swagger json files
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
stages:
- commit
- id: check-added-large-files
stages:
- commit
- id: check-case-conflict
stages:
- commit
- id: check-docstring-first
stages:
- commit
- id: check-executables-have-shebangs
stages:
- commit
- id: check-json
stages:
- commit
- id: check-symlinks
stages:
- commit
- id: check-yaml
stages:
- commit
- id: double-quote-string-fixer
stages:
- commit
- id: end-of-file-fixer
stages:
- commit
- id: mixed-line-ending
stages:
- commit
- id: pretty-format-json
stages:
- commit
args:
- --autofix
- --indent=4
- id: sort-simple-yaml
stages:
- commit
- repo: local
# golangci-lint does not support {entry} file1 file2 ... which
# the file1 and file2 in different directory
hooks:
- id: golint
entry: go run cmd/lint/main.go go
language: system
name: lint .go source files
files: ^.*\.go$
stages:
- commit
# buf lint does not support {entry} file1 file2 ...
- id: buflint
entry: go run cmd/lint/main.go proto
language: system
name: lint .proto source files
files: ^.*\.proto$
stages:
- commit