forked from drivendataorg/cookiecutter-data-science
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
235 lines (210 loc) · 7.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
exclude: |
(?x)^(
.*\{\{.*\}\}.*| # Exclude any files with cookiecutter variables
docs/site/.*| # Exclude mkdocs compiled files
\.history/.*| # Exclude history files
.*cache.*/.*| # Exclude cache directories
.*venv.*/.*| # Exclude virtual environment directories
)$
fail_fast: true
default_language_version:
python: python3.12
default_install_hook_types:
- pre-commit
- commit-msg
repos:
#
# Documentation Here:
# https://gatlenculp.github.io/gatlens-opinionated-template/precommit/
#
# ---------------------------------------------------------------------------- #
# 🔄 Pre-Commit Hooks #
# ---------------------------------------------------------------------------- #
# ----------------------------- 🔒 Security Tools ---------------------------- #
- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.1
hooks:
- id: gitleaks
name: "🔒 security · Detect hardcoded secrets"
# --------------------------- 🔍 Code Quality Tools -------------------------- #
### Python Tools ###
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff-format
name: "🐍 python · Format with Ruff"
# STRICT
# - id: ruff
# name: "🐍 python · Lint and perform safe auto-fixes with Ruff"
# args: [--fix]
# STRICT
# - repo: https://github.com/RobertCraigie/pyright-python
# rev: v1.1.391
# hooks:
# - id: pyright
# name: "🐍 python · Check types"
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject
name: "🐍 python · Validate pyproject.toml"
additional_dependencies: ["validate-pyproject-schema-store[all]"]
### Javascript & Web Tools ###
- repo: https://github.com/biomejs/pre-commit
rev: "v0.6.1"
hooks:
- id: biome-check
name: "🟨 javascript · Lint, format, and safe fixes with Biome"
additional_dependencies: ["@biomejs/[email protected]"]
### Data & Config Validation ###
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.31.0
hooks:
- id: check-github-workflows
name: "🐙 github-actions · Validate gh workflow files"
args: ["--verbose"]
- id: check-taskfile
name: "✅ taskfile · Validate Task configuration"
### Markdown ###
- repo: https://github.com/hukkin/mdformat
rev: 0.7.21
hooks:
- id: mdformat
name: "📝 markdown · Format markdown"
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- mdformat-frontmatter
- ruff
# STRICT
# - repo: https://github.com/markdownlint/markdownlint
# rev: v0.12.0
# hooks:
# - id: markdownlint
# name: "📝 markdown · Lint markdown"
### Shell ###
# STRICT
# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: v0.10.0.1
# hooks:
# - id: shellcheck
# name: "🐚 shell · Lint shell scripts"
# STRICT
# - repo: https://github.com/openstack/bashate
# rev: 2.1.1
# hooks:
# - id: bashate
# name: "🐚 shell · Check shell script code style"
### Makefile ###
- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake
name: "🐮 Makefile · Lint Makefile"
### SQL ###
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.3.0
hooks:
- id: sqlfluff-fix
name: "📊 SQL · Attempts to fix rule violations."
# STRICT
# - id: sqlfluff-lint
# name: "📊 SQL · Lint SQL code files"
### Notebooks ###
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa
entry: nbqa mdformat
name: "📓 notebook · Format markdown cells"
args: ["--nbqa-md"]
types: [jupyter]
additional_dependencies:
- mdformat
- mdformat-gfm
- mdformat-ruff
- mdformat-frontmatter
- ruff
# STRICT
# TODO: Convert to pyright
- id: nbqa-mypy
name: "📓 notebook · Type-check cells"
### PNG Images ###
- repo: https://github.com/shssoichiro/oxipng
rev: v9.1.3
hooks:
- id: oxipng
name: "🖼️ images · Optimize PNG files"
args: ["-o", "4", "--strip", "safe", "--alpha"]
### Additional File Types ###
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: "✨ misc-files · Format misc web files"
types_or: [yaml, html, scss]
additional_dependencies:
# ---------------------------- 📁 Filesystem Tools --------------------------- #
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# Filesystem Checks
- 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-case-conflict
name: "📁 filesystem/📝 names · Check case sensitivity"
- id: check-illegal-windows-names
name: "📁 filesystem/📝 names · Validate Windows filenames"
- id: check-symlinks
name: "📁 filesystem/🔗 symlink · Check symlink validity"
- id: destroyed-symlinks
name: "📁 filesystem/🔗 symlink · Detect broken symlinks"
# ------------------------------- 🌳 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"]
- id: check-added-large-files
name: "🌳 git · Block large file commits"
args: ["--maxkb=5000"]
# ---------------------------------------------------------------------------- #
# 📝 Commit Message Hooks #
# ---------------------------------------------------------------------------- #
#
# --------------------------- ✍️ Git Commit Quality -------------------------- #
### Commit Message Standards ###
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
name: "🌳 git · Validate commit message"
stages: [commit-msg]
additional_dependencies: [cz-conventional-gitmoji]
# ---------------------------------------------------------------------------- #
# 🧪 Fast Tests (Local) #
# ---------------------------------------------------------------------------- #
- repo: local
hooks:
- id: pytest-collect
name: 🧪 test · Validate test formatting
entry: ./.venv/bin/pytest tests
language: system
types: [python]
args: ["--collect-only"]
pass_filenames: false
always_run: true
# STRICT
- id: pytest-fast
name: 🧪 test · Run fast tests
entry: ./.venv/bin/pytest tests
language: system
types: [python]
args: ["--max-timeout=3"]
pass_filenames: false
always_run: true