Skip to content

Commit beb40f0

Browse files
authored
Make the hook list more readable (folding descriptions)
The hook list is: - `check-added-large-files` - `check-ast` - `check-builtin-literals` - `check-case-conflict` - `check-docstring-first` - `check-executables-have-shebangs` - `check-illegal-windows-names` - `check-json` - `check-merge-conflict` - `check-shebang-scripts-are-executable` - `check-symlinks` - `check-toml` - `check-vcs-permalinks` - `check-xml` - `check-yaml` - `debug-statements` - `destroyed-symlinks` - `detect-aws-credentials` - `detect-private-key` - `double-quote-string-fixer` - `end-of-file-fixer` - `file-contents-sorter` - `fix-byte-order-marker` - `fix-encoding-pragma` - `forbid-new-submodules` - `forbid-submodules` - `mixed-line-ending` - `name-tests-test` - `no-commit-to-branch` - `pretty-format-json` - `requirements-txt-fixer` - `sort-simple-yaml` - `trailing-whitespace`
1 parent 6db05e2 commit beb40f0

File tree

1 file changed

+204
-6
lines changed

1 file changed

+204
-6
lines changed

README.md

Lines changed: 204 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,64 +23,147 @@ Add this to your `.pre-commit-config.yaml`
2323

2424
### Hooks available
2525

26+
<details>
27+
<summary>
28+
2629
#### `check-added-large-files`
30+
</summary>
31+
2732
Prevent giant files from being committed.
2833
- Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB).
2934
- Limits checked files to those indicated as staged for addition by git.
3035
- If `git-lfs` is installed, lfs files will be skipped
3136
(requires `git-lfs>=2.2.1`)
3237
- `--enforce-all` - Check all listed files not just those staged for
3338
addition.
39+
</details>
40+
41+
<details>
42+
<summary>
3443

3544
#### `check-ast`
45+
</summary>
46+
3647
Simply check whether files parse as valid python.
48+
</details>
49+
50+
<details>
51+
<summary>
3752

3853
#### `check-builtin-literals`
39-
Require literal syntax when initializing empty or zero Python builtin types.
40-
- Allows calling constructors with positional arguments (e.g., `list('abc')`).
41-
- Allows calling constructors from the `builtins` (`__builtin__`) namespace (`builtins.list()`).
42-
- Ignore this requirement for specific builtin types with `--ignore=type1,type2,…`.
43-
- Forbid `dict` keyword syntax with `--no-allow-dict-kwargs`.
54+
</summary>
55+
</details>
56+
57+
<details>
58+
<summary>
4459

4560
#### `check-case-conflict`
61+
</summary>
62+
4663
Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
64+
</details>
65+
66+
<details>
67+
<summary>
4768

4869
#### `check-docstring-first`
70+
</summary>
71+
4972
Checks for a common error of placing code before the docstring.
73+
</details>
74+
75+
<details>
76+
<summary>
5077

5178
#### `check-executables-have-shebangs`
79+
</summary>
80+
5281
Checks that non-binary executables have a proper shebang.
82+
</details>
83+
84+
<details>
85+
<summary>
5386

5487
#### `check-illegal-windows-names`
88+
</summary>
89+
5590
Check for files that cannot be created on Windows.
91+
</details>
92+
93+
<details>
94+
<summary>
5695

5796
#### `check-json`
97+
</summary>
98+
5899
Attempts to load all json files to verify syntax.
100+
</details>
101+
102+
<details>
103+
<summary>
59104

60105
#### `check-merge-conflict`
106+
</summary>
107+
61108
Check for files that contain merge conflict strings.
62109
- `--assume-in-merge` - Allows running the hook when there is no ongoing merge operation
110+
</details>
111+
112+
<details>
113+
<summary>
63114

64115
#### `check-shebang-scripts-are-executable`
116+
</summary>
117+
65118
Checks that scripts with shebangs are executable.
119+
</details>
120+
121+
<details>
122+
<summary>
66123

67124
#### `check-symlinks`
125+
</summary>
126+
68127
Checks for symlinks which do not point to anything.
128+
</details>
129+
130+
<details>
131+
<summary>
69132

70133
#### `check-toml`
134+
</summary>
135+
71136
Attempts to load all TOML files to verify syntax.
137+
</details>
138+
139+
<details>
140+
<summary>
72141

73142
#### `check-vcs-permalinks`
143+
</summary>
144+
74145
Ensures that links to vcs websites are permalinks.
75146
- `--additional-github-domain DOMAIN` - Add check for specified domain.
76147
Can be repeated multiple times. for example, if your company uses
77148
GitHub Enterprise you may use something like
78149
`--additional-github-domain github.example.com`
150+
</details>
151+
152+
<details>
153+
<summary>
79154

80155
#### `check-xml`
156+
</summary>
157+
81158
Attempts to load all xml files to verify syntax.
159+
</details>
160+
161+
<details>
162+
<summary>
82163

83164
#### `check-yaml`
165+
</summary>
166+
84167
Attempts to load all yaml files to verify syntax.
85168
- `--allow-multiple-documents` - allow yaml files which use the
86169
[multi-document syntax](http://www.yaml.org/spec/1.2/spec.html#YAML)
@@ -89,34 +172,76 @@ Attempts to load all yaml files to verify syntax.
89172
otherwise be forbidden. Using this option removes all guarantees of
90173
portability to other yaml implementations.
91174
Implies `--allow-multiple-documents`.
175+
</details>
176+
177+
<details>
178+
<summary>
92179

93180
#### `debug-statements`
181+
</summary>
182+
94183
Check for debugger imports and py37+ `breakpoint()` calls in python source.
184+
</details>
185+
186+
<details>
187+
<summary>
95188

96189
#### `destroyed-symlinks`
190+
</summary>
191+
97192
Detects symlinks which are changed to regular files with a content of a path
98193
which that symlink was pointing to.
99194
This usually happens on Windows when a user clones a repository that has
100195
symlinks but they do not have the permission to create symlinks.
196+
</details>
197+
198+
<details>
199+
<summary>
101200

102201
#### `detect-aws-credentials`
202+
</summary>
203+
103204
Checks for the existence of AWS secrets that you have set up with the AWS CLI.
104205
The following arguments are available:
105206
- `--credentials-file CREDENTIALS_FILE` - additional AWS CLI style
106207
configuration file in a non-standard location to fetch configured
107208
credentials from. Can be repeated multiple times.
108209
- `--allow-missing-credentials` - Allow hook to pass when no credentials are detected.
210+
</details>
211+
212+
<details>
213+
<summary>
109214

110215
#### `detect-private-key`
216+
</summary>
217+
111218
Checks for the existence of private keys.
219+
</details>
220+
221+
<details>
222+
<summary>
112223

113224
#### `double-quote-string-fixer`
225+
</summary>
226+
114227
This hook replaces double quoted strings with single quoted strings.
228+
</details>
229+
230+
<details>
231+
<summary>
115232

116233
#### `end-of-file-fixer`
234+
</summary>
235+
117236
Makes sure files end in a newline and only a newline.
237+
</details>
238+
239+
<details>
240+
<summary>
118241

119242
#### `file-contents-sorter`
243+
</summary>
244+
120245
Sort the lines in specified files (defaults to alphabetical).
121246
You must provide the target [`files`](https://pre-commit.com/#config-files) as input.
122247
Note that this hook WILL remove blank lines and does NOT respect any comments.
@@ -125,41 +250,83 @@ All newlines will be converted to line feeds (`\n`).
125250
The following arguments are available:
126251
- `--ignore-case` - fold lower case to upper case characters.
127252
- `--unique` - ensure each line is unique.
253+
</details>
254+
255+
<details>
256+
<summary>
128257

129258
#### `fix-byte-order-marker`
259+
</summary>
260+
130261
removes UTF-8 byte order marker
262+
</details>
263+
264+
<details>
265+
<summary>
131266

132267
#### `fix-encoding-pragma`
268+
</summary>
269+
133270

134271
_Deprecated since py2 is EOL - use [pyupgrade](https://github.com/asottile/pyupgrade) instead._
135272

136273
Add `# -*- coding: utf-8 -*-` to the top of python files.
137274
- To remove the coding pragma pass `--remove` (useful in a python3-only codebase)
275+
</details>
276+
277+
<details>
278+
<summary>
138279

139280
#### `forbid-new-submodules`
281+
</summary>
282+
140283
Prevent addition of new git submodules.
141284

142285
This is intended as a helper to migrate away from submodules. If you want to
143286
ban them entirely use `forbid-submodules`
287+
</details>
288+
289+
<details>
290+
<summary>
144291

145292
#### `forbid-submodules`
293+
</summary>
294+
146295
forbids any submodules in the repository.
296+
</details>
297+
298+
<details>
299+
<summary>
147300

148301
#### `mixed-line-ending`
302+
</summary>
303+
149304
Replaces or checks mixed line ending.
150305
- `--fix={auto,crlf,lf,no}`
151306
- `auto` - Replaces automatically the most frequent line ending. This is the default argument.
152307
- `crlf`, `lf` - Forces to replace line ending by respectively CRLF and LF.
153308
- This option isn't compatible with git setup check-in LF check-out CRLF as git smudge this later than the hook is invoked.
154309
- `no` - Checks if there is any mixed line ending without modifying any file.
310+
</details>
311+
312+
<details>
313+
<summary>
155314

156315
#### `name-tests-test`
316+
</summary>
317+
157318
verifies that test files are named correctly.
158319
- `--pytest` (the default): ensure tests match `.*_test\.py`
159320
- `--pytest-test-first`: ensure tests match `test_.*\.py`
160321
- `--django` / `--unittest`: ensure tests match `test.*\.py`
322+
</details>
323+
324+
<details>
325+
<summary>
161326

162327
#### `no-commit-to-branch`
328+
</summary>
329+
163330
Protect specific branches from direct checkins.
164331
- Use `args: [--branch, staging, --branch, main]` to set the branch.
165332
Both `main` and `master` are protected by default if no branch argument is set.
@@ -174,8 +341,14 @@ As a result, it will ignore any setting of [`files`](https://pre-commit.com/#con
174341
or [`exclude_types`](https://pre-commit.com/#config-exclude_types).
175342
Set [`always_run: false`](https://pre-commit.com/#config-always_run) to allow this hook to be skipped according to these
176343
file filters. Caveat: In this configuration, empty commits (`git commit --allow-empty`) would always be allowed by this hook.
344+
</details>
345+
346+
<details>
347+
<summary>
177348

178349
#### `pretty-format-json`
350+
</summary>
351+
179352
Checks that all your JSON files are pretty. "Pretty"
180353
here means that keys are sorted and indented. You can configure this with
181354
the following commandline options:
@@ -184,11 +357,23 @@ the following commandline options:
184357
- `--no-ensure-ascii` preserve unicode characters instead of converting to escape sequences
185358
- `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys)
186359
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
360+
</details>
361+
362+
<details>
363+
<summary>
187364

188365
#### `requirements-txt-fixer`
366+
</summary>
367+
189368
Sorts entries in requirements.txt and constraints.txt and removes incorrect entry for `pkg-resources==0.0.0`
369+
</details>
370+
371+
<details>
372+
<summary>
190373

191374
#### `sort-simple-yaml`
375+
</summary>
376+
192377
Sorts simple YAML files which consist only of top-level
193378
keys, preserving comments and blocks.
194379

@@ -199,20 +384,33 @@ very specific format. You must opt in to this by setting [`files`](https://pre-
199384
- id: sort-simple-yaml
200385
files: ^config/simple/
201386
```
387+
</details>
202388
389+
<details>
390+
<summary>
203391
204392
#### `trailing-whitespace`
393+
</summary>
394+
205395
Trims trailing whitespace.
206396
- To preserve Markdown [hard linebreaks](https://github.github.com/gfm/#hard-line-break)
207397
use `args: [--markdown-linebreak-ext=md]` (or other extensions used
208398
by your markdownfiles). If for some reason you want to treat all files
209399
as markdown, use `--markdown-linebreak-ext=*`.
210400
- By default, this hook trims all whitespace from the ends of lines.
211401
To specify a custom set of characters to trim instead, use `args: [--chars,"<chars to trim>"]`.
402+
</details>
212403

213404
### Deprecated / replaced hooks
214405

215-
- `check-byte-order-marker`: instead use fix-byte-order-marker
406+
<details>
407+
<summary>
408+
409+
#### `check-byte-order-marker`
410+
</summary>
411+
412+
instead use fix-byte-order-marker
413+
</details>
216414

217415
### As a standalone package
218416

0 commit comments

Comments
 (0)