-
Notifications
You must be signed in to change notification settings - Fork 533
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
156 lines (135 loc) · 4.98 KB
/
.pre-commit-config.yaml
File metadata and controls
156 lines (135 loc) · 4.98 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
default_install_hook_types:
- commit-msg
- pre-commit
default_stages:
- pre-commit
- manual
repos:
# ---------------------------------------------------------------------------- #
# 🔄 Pre-Commit Hooks #
# ---------------------------------------------------------------------------- #
### Pre-commit First-Party Tools
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# ------------------------------- 🌳 Git Tools ------------------------------- #
- id: check-merge-conflict
name: "🌳 git · Detect conflict markers"
- id: forbid-new-submodules
name: "🌳 git · Prevent submodule creation"
- id: no-commit-to-branch
name: "🌳 git · Protect main branches"
args: ["--branch", "main", "--branch", "master"]
# ---------------------------- 📁 Filesystem Tools --------------------------- #
- id: check-executables-have-shebangs
name: "📁 filesystem/⚙️ exec · Verify shebang presence"
- id: check-shebang-scripts-are-executable
name: "📁 filesystem/⚙️ exec · Verify script permissions"
- id: check-symlinks
name: "📁 filesystem/🔗 symlink · Check symlink validity"
- id: destroyed-symlinks
name: "📁 filesystem/🔗 symlink · Detect broken symlinks"
- id: requirements-txt-fixer
name: "📁 filesystem/📝 file · Validate requirements.txt"
- id: trailing-whitespace
name: "📁 filesystem/📝 file · Validate empty whitespaces"
exclude: '\.patch$'
# ----------------------------- 🔒 Security Tools ---------------------------- #
- id: check-json
name: "📁 filesystem/🔧 config · Validate JSON file"
- id: check-yaml
name: "📁 filesystem/🔧 config · Validate YAML file"
- id: detect-aws-credentials
name: "🔒 security · Detect aws credentials"
args: ["--allow-missing-credentials"]
- id: detect-private-key
name: "🔒 security · Detect private keys"
- repo: https://github.com/gitleaks/gitleaks
rev: v8.29.0
hooks:
- id: gitleaks
name: "🔒 security · Detect hardcoded secrets"
# --------------------------- 🔍 Code Quality Tools -------------------------- #
### Writing Tools ###
- repo: https://github.com/crate-ci/typos
rev: v1.38.1
hooks:
- id: typos
name: "✏️ typos · Checking typos"
args: ["--force-exclude"]
### Python Tools ###
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.3
hooks:
- id: ruff-format
name: "🐍 python · Format python"
- id: ruff-check
name: "🐍 python · Lint python"
args: ["--fix"]
- id: ruff-check
name: "🐍 python · Sort python imports"
args: ["check", "--select", "I", "--fix"]
### Workflow Validation ###
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.35.0
hooks:
- id: check-github-workflows
name: "🐙 github-actions · Validate gh workflow files"
args: ["--verbose"]
- repo: https://github.com/rhysd/actionlint
rev: v1.7.8
hooks:
- id: actionlint
name: "🐙 github-actions · Lint gh workflow files"
args: ["-shellcheck=enable=all"]
### Markdown ###
- repo: local
hooks:
- id: flowmark
name: "📝 markdown · Format markdown (docs)"
entry: flowmark --inplace --nobackup -w 150
language: python
additional_dependencies: [flowmark]
files: ^docs/
exclude: (\.template\.md$|(README|DEVELOPMENT)\.md$)
types: [markdown]
- repo: https://github.com/hukkin/mdformat
rev: 1.0.0
hooks:
- id: mdformat
name: "📝 markdown · Format markdown"
exclude: ^docs/
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- ruff
### Docker Tools ###
- repo: https://github.com/reteps/dockerfmt
rev: v0.3.9
hooks:
- id: dockerfmt
name: "🐳 docker · Format docker"
args: ["--indent", "2", "--write"]
### Shell ###
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.12.0-2 # Use the latest stable revision
hooks:
- id: shfmt
name: "🐚 shell · Format shell scripts"
args: ["-s"]
# --------------------------- ✍️ Git Commit Quality -------------------------- #
### Commit Message Standards ###
- repo: local
hooks:
- id: signoff-commit
name: Sign-off Commit
entry: bash
args:
- -c
- |
if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)"
fi
language: system
verbose: true
stages: [commit-msg]