-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.pre-commit-config.yaml
240 lines (207 loc) · 7.46 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
---
minimum_pre_commit_version: "2.17"
default_stages: [pre-commit]
default_language_version:
python: python3.12
ci:
skip: [mypy, pylint]
repos:
# ----------------------------------------------
# Meta hooks
# ----------------------------------------------
- repo: meta
hooks:
- id: identity
stages: [pre-commit, manual]
- id: check-hooks-apply
stages: [manual]
- id: check-useless-excludes
stages: [manual]
# ----------------------------------------------
# File hooks
# ----------------------------------------------
# file checking out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
exclude: '^.*\.rs$'
stages: [pre-commit]
- id: check-symlinks
- id: destroyed-symlinks
- id: forbid-new-submodules
# ####################################################################################
#
# FORMATTING
#
# ####################################################################################
# ----------------------------------------------
# Python
# ----------------------------------------------
# ruff - python linter with fixing ability
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 89c421dff2e1026ba12cdb9ebd731f4a83aa8021 # frozen: v0.8.6
hooks:
- id: ruff
name: ruff (fix)
args: ["--fix-only", "--exit-non-zero-on-fix", "--config=pyproject.toml"]
- id: ruff-format
name: ruff (format)
# blacken-docs - black for python code in docs (rst/md/tex)
- repo: https://github.com/asottile/blacken-docs
rev: 78a9dcbecf4f755f65d1f3dec556bc249d723600 # frozen: 1.19.1
hooks:
- id: blacken-docs
args: ["--line-length=100", "--target-version=py312"]
exclude: testing|tests
# ----------------------------------------------
# JS / TS / HTML / CSS / MD / JSON / YAML
# ----------------------------------------------
# prettier - multi formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
- "prettier@^3.2.4"
# ----------------------------------------------
# Spelling dict
# ----------------------------------------------
# Custom hook as python command
- repo: local
hooks:
- id: sort-spelling-dicts
name: Sort spelling_dict.txt files
description: Sort spelling_dict.txt files
language: python
entry: python
args:
- "-c"
- |
import pathlib;
import sys;
p = pathlib.Path(sys.argv[1]);
p.write_text("\n".join(sorted(set(p.read_text("utf-8").splitlines()))) + "\n", "utf-8")
files: "spelling_dict.txt"
# ----------------------------------------------
# General (code unspecific)
# ----------------------------------------------
# code unspecific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: end-of-file-fixer
stages: [pre-commit]
- id: trailing-whitespace
stages: [pre-commit]
# ####################################################################################
#
# LINTING
#
# ####################################################################################
# ----------------------------------------------
# General (code unspecific)
# ----------------------------------------------
- repo: local
hooks:
# Find TODO:|FIXME: comments in all files
# Inline skip: `#i#` directly after the colon after the tag-word
- id: find-todos
name: "Find TODO:|FIXME: comments"
description: "Check for TODO:|FIXME: comments in all files"
language: pygrep
entry: '(^|//!?|#|<!--|;|/\*(\*|!)?|\.\.)\s*(TODO:|FIXME:)(?!\s#i#)'
exclude: TODO
# code unspecific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-merge-conflict
- id: detect-private-key
# ----------------------------------------------
# Python
# ----------------------------------------------
# ruff - python linter with fixing ability
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 89c421dff2e1026ba12cdb9ebd731f4a83aa8021 # frozen: v0.8.6
hooks:
- id: ruff
name: ruff (lint)
args: ["--config=pyproject.toml"]
- id: ruff-format
name: ruff (format-check)
args: ["--diff"]
# python specific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: name-tests-test
# Lint hooks managed via tox envs b/c they need the pkg installed
- repo: local
hooks:
# mypy - python type checker
- id: mypy
name: mypy
description: run mypy over the installed package via tox
entry: tox
args: ["-e", "mypy"]
language: python
additional_dependencies: [tox]
types: [python]
pass_filenames: false
require_serial: true
# pylint - python linter
- repo: https://github.com/PyCQA/pylint/
rev: c28580be76fe1ec55a6cac41833c0bd68070d2f7 # frozen: v3.3.3
hooks:
- id: pylint
name: spell-check (pylint+pyenchant)
description: >
spell-check in docstrings/comments in py-source via pyenchant and pylint
additional_dependencies: [pyenchant]
args: ["--disable=all", "--enable=spelling", "--rcfile=.pylintrc.spelling.toml"]
# ----------------------------------------------
# Shell script
# ----------------------------------------------
# shellscript (via PyPI package)
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: a23f6b85d0fdd5bb9d564e2579e678033debbdff # frozen: v0.10.0.1
hooks:
- id: shellcheck
# ----------------------------------------------
# reStructuredText
# ----------------------------------------------
# rstcheck - rst file checker
- repo: https://github.com/rstcheck/rstcheck
rev: f30c4d170a36ea3812bceb5f33004afc213bd797 # frozen: v6.2.4
hooks:
- id: rstcheck
additional_dependencies: [sphinx]
exclude: testing
args: ["--config", ".rstcheck.project.cfg"]
# ----------------------------------------------
# Markdown
# ----------------------------------------------
# markdownlint - md file checker
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: af14a2e768b741b941255b4c6b875339b4acbb73 # frozen: v0.17.1
hooks:
- id: markdownlint-cli2
# ----------------------------------------------
# TOML / YAML
# ----------------------------------------------
# JSON specific out-of-the-box hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
# yamllint - yaml linter
- repo: https://github.com/adrienverge/yamllint
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # frozen: v1.35.1
hooks:
- id: yamllint