-
Notifications
You must be signed in to change notification settings - Fork 1
/
.pre-commit-hooks.yaml
112 lines (107 loc) · 4.18 KB
/
.pre-commit-hooks.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
105
106
107
108
109
110
111
112
- id: check-build-file-without-extensions
name: check for BUILD files without extensions
description: Check that `BUILD` files have a `.bazel` ending. `BUILD.bazel` file is the recommended way to name these files.
entry: BUILD files must have a .bazel ending
language: fail
files: "BUILD$"
- id: check-snake-case
name: check snake case
description: Check that all source code files are `snake_case`. We don't want to use `camelCase` or `kebab-case` file names.
entry: file names and paths must be snake_case
language: fail
files: "-|[A-Z]"
types_or:
- c++
- cuda
- python
- shell
- id: check-cpp-and-cu-unit-test-naming-pattern
name: Check c++ and cu unit test naming pattern
description: Check that all C++ and Cuda unit test files end with `_test.cpp` or `_test.cu`.
entry: cpp and cu unit test files must end with _test.cpp
language: fail
files: '.*(?<=test)(?<!_test)\.(cpp|cu)$'
types_or:
- c++
- cuda
- id: check-no-dashes
name: check no dashes
description: Check that markdown filenames do not use dashes
entry: Markdown filenames must not use dashes
language: fail
files: "-"
types_or:
- markdown
- id: check-sys-path-append
name: Check sys path append usage
description: Check that no `sys.path.append` is used in Python code
entry: "sys.path.append"
language: pygrep
types: ["python"]
- id: go-fmt
name: Go Format
description: Format go files
entry: gofmt
args: [-s, -w, -d=false]
language: golang
types: [go]
- id: go-imports
name: Go Imports
description: Order go imports
entry: goimports
args: [-w, -d=false]
additional_dependencies: [golang.org/x/tools/cmd/goimports@v0.27.0]
language: golang
types: [go]
- id: go-revive
name: Go Revive
description: Run Go Revive linter
entry: revive
args: [-set_exit_status, -formatter, friendly]
additional_dependencies: [github.com/mgechev/revive@v1.5.1]
language: golang
types: [go]
- id: check-number-of-lines-count
name: Check Number of Lines
description: Check that number of lines in scripts do not exceed max-lines. Use `--max-lines=<number>` to set the maximum number of lines. Default is 30 for shell scripts.
entry: check-number-of-lines-count
language: python
types_or:
- shell
args: [--max-lines=30]
- id: check-shellscript-set-options
name: Check 'set' options
description: Check if options are set with `set -euxo pipefail`. Use `# nolint(set_options)` to ignore this check.
entry: check-shellscript-set-options
language: python
types_or:
- shell
- id: check-jira-reference-in-todo
name: Check Jira reference in TODO
description: "Check that all TODO comments follow the same pattern and link a Jira ticket: `TODO(ABC-1234):`."
entry: check-jira-reference-in-todo
language: python
exclude_types:
- svg
- id: check-non-existing-and-duplicate-excludes
name: Check non-existing and duplicate excludes in pre-commit-config
description: "Check for non existing and duplicate paths in `.pre-commit-config.yaml`. Background: In a big codebase, the exclude lists can be quite long and it's easy to make a typo or forget to remove an entry when it's no longer needed."
entry: check-useless-exclude-paths-hooks
language: python
additional_dependencies: ["pre-commit >= 3.5.0"]
- id: check-ownership
name: Check `.github/CODEOWNERS` consistency (can take a while)
description: |
Check if all folders in the `CODEOWNERS` file exist, there are no duplicates, and it has acceptable codeowners.
What is an acceptable codeowner? We want to make sure that every folder has a codeowner other than the team that should exclusively own the CODEOWNERS file.
For this, we define a `CODEOWNERS_OWNER` using the `--codeowners-owner` argument. Your `CODEOWNERS` file should look as follows:
```shell
* CODEOWNERS_OWNER
# Here goes all your CODEOWNERS file content overriding the wildcard owner
# leave this at the bottom to have highest ownership priority
/.github/CODEOWNERS CODEOWNERS_OWNER
```
If the hook detects `CODEOWNERS_OWNER` owns anything else than `.github/CODEOWNERS` it will fail to make sure every file added has an acceptable codeowner.
entry: check-ownership
language: python
always_run: true