-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
410 lines (372 loc) · 11.4 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
---
# See https://pre-commit.com for more information
# NOTE: Given fail_fast, you should the more problematic hooks first.
# See https://github.com/pishoyg/coptic/issues/94.
# NOTE: Fail fast won't be optimal if your pipelines get better at writing
# consistent output that doesn't get modified by the pre-commits. Revisit.
fail_fast: true
exclude: ^archive/
repos:
# Language-agnostic
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: .*\.(tsv|csv|xml|html|xhtml)$
# HTML
- repo: local
hooks:
- id: tidy-html
name: tidy-html
entry: tidy -config "tidy_config.txt"
language: system
files: .*\.html
exclude: ^site/crum.html$
# See https://github.com/pishoyg/coptic/issues/317 for why
# `site/crum.html` needs the --warn-proprietary-attributes flag.
- id: crum-tidy-html
name: crum-tidy-html
entry: tidy -config "tidy_config.txt" --warn-proprietary-attributes
"no"
language: system
files: ^site/crum.html$
# Language-agnostic
- repo: meta
hooks:
- id: check-useless-excludes
- id: identity
- repo: local
hooks:
- id: commit-file-sizes
name: commit-file-sizes
entry: pre-commit/commit-file-size.sh
language: system
verbose: true
require_serial: true
# TypeScript and JavaScript
- repo: local
hooks:
- id: prettier
name: prettier
args: [--write]
files: \.(js|jsx|mjs|cjs|ts|tsx|mts|cts|json|css)$
types: [file]
entry: npx prettier
language: system
- id: typescript-unittest-exists
name: typescript-unittest-exists
types: [ts]
entry: pre-commit/typescript-unittest-exists.sh
language: system
- id: typescript-unittest
name: typescript-unittest
types: [ts]
entry: bun test
language: system
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.12.0
hooks:
- id: eslint
additional_dependencies:
- typescript
- globals
- typescript-eslint
- "@stylistic/eslint-plugin"
- "eslint-config-standard@latest"
args: [--fix]
files: \.(js|jsx|mjs|cjs|ts|tsx|mts|cts)$
types: [file]
entry: npx eslint
# CSS
- repo: local
hooks:
- id: stylelint
name: stylelint
entry: npx stylelint
language: system
types: [css]
args: [--fix, --color, --report-invalid-scope-disables, --report-needless-disables]
- repo: local
hooks:
# Python Unit Tests Exist
- id: python-unittest-exists
name: python-unittest-exists
entry: pre-commit/python-unittest-exists.sh
language: system
types: [python]
exclude: setup.py
# XML
- id: tidy-xml
name: tidy-xml
entry: tidy -config "tidy_config.txt" -xml
language: system
files: .*\.(xml|xhtml|opf)$
# Python
# NOTE: Running `add-trailing-comma` before `black` is intentional.
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
- repo: local
hooks:
- id: mypy
name: mypy
entry: pre-commit/mypy.sh
language: system
types: [python]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
args: [--line-length, '79']
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/asottile/dead
rev: v1.5.2
hooks:
- id: dead
# We wrap `dead` in a Bash script that suppresses its errors.
# It has some false positives[1]. One of them is global variables,
# which the creator doesn't intend to fix.[2]
# [1] https://github.com/asottile/dead?tab=readme-ov-file#false-positives
# [2] https://github.com/asottile/dead/issues/184
# It also can't be disabled on a class level, we would have to disable
# it for each method individually.
# Although we can (and should) get rid of our global variables, we
# might end up continuously having unused (albeit not dead per se)
# classes in our repo. Disabling dead on a per-method basis is going to
# be annoying, so we just change it to a warning for now.
entry: bash -c 'dead "${@}" || true' --
verbose: true
# `dead` doesn't respect the pre-commit `exclude` directive[1], so we
# have to exclude the archive using a flag.
# [1] https://github.com/asottile/dead/issues/185
args: [--exclude, archive/.*]
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.7.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
- repo: https://github.com/PyCQA/doc8
rev: v1.1.2
hooks:
- id: doc8
- repo: https://github.com/PyCQA/eradicate
rev: 2.3.0
hooks:
- id: eradicate
# Language-agnostic
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
exclude: .*\.css$
- id: check-added-large-files
exclude: .*\.(html|xhtml|mobi|pdf|tsv|jpg|png|json)$|.*/img/.*
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-vcs-permalinks
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: fix-byte-order-marker
- id: name-tests-test
- id: requirements-txt-fixer
- id: sort-simple-yaml
- id: forbid-submodules
- id: mixed-line-ending
- id: check-xml
- repo: https://github.com/mxr/sync-pre-commit-deps
rev: v0.0.1
hooks:
- id: sync-pre-commit-deps
# Spell Checking
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# The KELLIA driver contains non-English text.
# Other types of files are data files, not code files. We don't take
# data updates lightly.
exclude: ".*\\.(xml|html|xhtml|txt|tsv|csv|json|tab|msql|xsd)$|dictionary/kellia.uni-goettingen.de/main.py"
# NOTE: This hook was problematic in the past. It was found to change code
# variable names, assuming that they are typos!
# We pass `--diff` to make it report typos before fixing them.
# Keep an eye for it.
- repo: https://github.com/crate-ci/typos
rev: v1.26.0
hooks:
- id: typos
exclude: ".*\\.(xml|html|xhtml|txt|tsv|csv|json|tab|msql|xsd)$|dictionary/kellia.uni-goettingen.de/main.py"
args: [--diff]
# Git Commit Messages
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
# Security
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.0
hooks:
- id: gitleaks
- repo: https://github.com/trufflesecurity/truffleHog
rev: v3.82.9
hooks:
- id: trufflehog
# Shell
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: [-x]
- repo: https://github.com/openstack/bashate
rev: 2.1.1
hooks:
- id: bashate
args: [-i, E003]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
hooks:
- id: shfmt
args: [-indent, '2']
# Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
hooks:
- id: markdownlint-fix
args: [--disable, MD033, MD036]
- repo: https://github.com/thlorenz/doctoc
rev: v2.2.0
hooks:
- id: doctoc
exclude: ^site/README.md$
# YAML
- repo: https://github.com/google/yamlfmt
rev: v0.13.0
hooks:
- id: yamlfmt
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: [--strict]
# Protobuf
- repo: https://github.com/bufbuild/buf
rev: v1.45.0
hooks:
- id: buf-dep-prune
- id: buf-dep-update
- id: buf-format
- id: buf-lint
- id: buf-breaking
- id: buf-generate
# Lua
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v0.20.0
hooks:
- id: stylua
# Makefile
- repo: https://github.com/mrtazz/checkmake
rev: 0.2.2
hooks:
- id: checkmake
- repo: local
hooks:
# Crum Images
- id: crum-img-validate
name: crum-img-validate
entry: dictionary/marcion.sourceforge.net/img_helper.py --validate
language: system
# NOTE: This hook should also run when files are deleted. But
# pre-commits don't work that way! If a file is deleted, even if it
# matches the pattern below, the hook won't be triggered.
# We still use the pattern to run the hook selectively because it's
# too slow. For deletions, we rely on the developer's memory, as well
# as sporadic runs of the scripts triggered by other operations such as
# image modifications and additions, to ensure that the files that need
# to be deleted are deleted.
files: ^dictionary/marcion.sourceforge.net/data/img.*
pass_filenames: false
- id: crum-appendices-validate
name: crum-appendices-validate
entry: dictionary/marcion.sourceforge.net/appendices_helper.py --validate
language: system
files: ^dictionary/marcion.sourceforge.net/data/input/.*_appendices.tsv$
pass_filenames: false
# Python Unit Tests
- id: python-unittest
name: python-unittest
entry: pre-commit/python-unittest.sh
language: system
types: [python]
verbose: true
# DO-NOT-SUBMIT
- id: check-do-not-submit
name: check-do-not-submit
entry: pre-commit/check-do-not-submit.sh
language: system
types: [text]
# One README
- id: check-one-readme
name: check-one-readme
entry: pre-commit/check-one-readme.sh
language: system
exclude: ^(site/)?README.md$
types: [markdown]
# Daily Statistics
- id: stats
name: stats
entry: pre-commit/stats.sh
language: system
pass_filenames: false
verbose: true
# TODO's
- id: check-todo
name: check-todo
entry: pre-commit/check-todo.sh
language: system
verbose: true
types: [text]
require_serial: true