Skip to content

Commit 51e0431

Browse files
authored
Merge pull request #442 from kimsey0/patch-1
Allow linking directly to each hook
2 parents fd9a0c6 + 96efcc6 commit 51e0431

File tree

1 file changed

+147
-95
lines changed

1 file changed

+147
-95
lines changed

README.md

Lines changed: 147 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -22,99 +22,152 @@ Add this to your `.pre-commit-config.yaml`
2222

2323
### Hooks available
2424

25-
- `check-added-large-files` - Prevent giant files from being committed.
26-
- Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB).
27-
- If `git-lfs` is installed, lfs files will be skipped
28-
(requires `git-lfs>=2.2.1`)
29-
- `check-ast` - Simply check whether files parse as valid python.
30-
- `check-builtin-literals` - Require literal syntax when initializing empty or zero Python builtin types.
31-
- Allows calling constructors with positional arguments (e.g., `list('abc')`).
32-
- Allows calling constructors from the `builtins` (`__builtin__`) namespace (`builtins.list()`).
33-
- Ignore this requirement for specific builtin types with `--ignore=type1,type2,…`.
34-
- Forbid `dict` keyword syntax with `--no-allow-dict-kwargs`.
35-
- `check-byte-order-marker` - Forbid files which have a UTF-8 byte-order marker
36-
- `check-case-conflict` - Check for files with names that would conflict on a
37-
case-insensitive filesystem like MacOS HFS+ or Windows FAT.
38-
- `check-docstring-first` - Checks for a common error of placing code before
39-
the docstring.
40-
- `check-executables-have-shebangs` - Checks that non-binary executables have a
41-
proper shebang.
42-
- `check-json` - Attempts to load all json files to verify syntax.
43-
- `check-merge-conflict` - Check for files that contain merge conflict strings.
44-
- `check-symlinks` - Checks for symlinks which do not point to anything.
45-
- `check-toml` - Attempts to load all TOML files to verify syntax.
46-
- `check-vcs-permalinks` - Ensures that links to vcs websites are permalinks.
47-
- `check-xml` - Attempts to load all xml files to verify syntax.
48-
- `check-yaml` - Attempts to load all yaml files to verify syntax.
49-
- `--allow-multiple-documents` - allow yaml files which use the
50-
[multi-document syntax](http://www.yaml.org/spec/1.2/spec.html#YAML)
51-
- `--unsafe` - Instead of loading the files, simply parse them for syntax.
52-
A syntax-only check enables extensions and unsafe constructs which would
53-
otherwise be forbidden. Using this option removes all guarantees of
54-
portability to other yaml implementations.
55-
Implies `--allow-multiple-documents`.
56-
- `debug-statements` - Check for debugger imports and py37+ `breakpoint()`
57-
calls in python source.
58-
- `detect-aws-credentials` - Checks for the existence of AWS secrets that you
59-
have set up with the AWS CLI.
60-
The following arguments are available:
61-
- `--credentials-file CREDENTIALS_FILE` - additional AWS CLI style
62-
configuration file in a non-standard location to fetch configured
63-
credentials from. Can be repeated multiple times.
64-
- `--allow-missing-credentials` - Allow hook to pass when no credentials are
65-
detected.
66-
- `detect-private-key` - Checks for the existence of private keys.
67-
- `double-quote-string-fixer` - This hook replaces double quoted strings
68-
with single quoted strings.
69-
- `end-of-file-fixer` - Makes sure files end in a newline and only a newline.
70-
- `fix-encoding-pragma` - Add `# -*- coding: utf-8 -*-` to the top of python files.
71-
- To remove the coding pragma pass `--remove` (useful in a python3-only codebase)
72-
- `file-contents-sorter` - Sort the lines in specified files (defaults to alphabetical). You must provide list of target files as input to it. Note that this hook WILL remove blank lines and does NOT respect any comments.
73-
- `flake8` - Run flake8 on your python files.
74-
- `forbid-new-submodules` - Prevent addition of new git submodules.
75-
- `mixed-line-ending` - Replaces or checks mixed line ending.
76-
- `--fix={auto,crlf,lf,no}`
77-
- `auto` - Replaces automatically the most frequent line ending. This is the default argument.
78-
- `crlf`, `lf` - Forces to replace line ending by respectively CRLF and LF.
79-
- This option isn't compatible with git setup check-in LF check-out CRLF as git smudge this later than the hook is invoked.
80-
- `no` - Checks if there is any mixed line ending without modifying any file.
81-
- `name-tests-test` - Assert that files in tests/ end in `_test.py`.
82-
- Use `args: ['--django']` to match `test*.py` instead.
83-
- `no-commit-to-branch` - Protect specific branches from direct checkins.
84-
- Use `args: [--branch, staging, --branch, master]` to set the branch.
85-
`master` is the default if no branch argument is set.
86-
- `-b` / `--branch` may be specified multiple times to protect multiple
87-
branches.
88-
- `-p` / `--pattern` can be used to protect branches that match a supplied regex
89-
(e.g. `--pattern, release/.*`). May be specified multiple times.
90-
- `pretty-format-json` - Checks that all your JSON files are pretty. "Pretty"
91-
here means that keys are sorted and indented. You can configure this with
92-
the following commandline options:
93-
- `--autofix` - automatically format json files
94-
- `--indent ...` - Control the indentation (either a number for a number of spaces or a string of whitespace). Defaults to 4 spaces.
95-
- `--no-ensure-ascii` preserve unicode characters instead of converting to escape sequences
96-
- `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys)
97-
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
98-
- `requirements-txt-fixer` - Sorts entries in requirements.txt and removes incorrect entry for `pkg-resources==0.0.0`
99-
- `sort-simple-yaml` - Sorts simple YAML files which consist only of top-level
100-
keys, preserving comments and blocks.
101-
102-
Note that `sort-simple-yaml` by default matches no `files` as it enforces a
103-
very specific format. You must opt in to this by setting `files`, for
104-
example:
105-
106-
```yaml
107-
- id: sort-simple-yaml
108-
files: ^config/simple/
109-
```
110-
111-
- `trailing-whitespace` - Trims trailing whitespace.
112-
- To preserve Markdown [hard linebreaks](https://github.github.com/gfm/#hard-line-break)
113-
use `args: [--markdown-linebreak-ext=md]` (or other extensions used
114-
by your markdownfiles). If for some reason you want to treat all files
115-
as markdown, use `--markdown-linebreak-ext=*`.
116-
- By default, this hook trims all whitespace from the ends of lines.
117-
To specify a custom set of characters to trim instead, use `args: [--chars,"<chars to trim>"]`.
25+
#### `check-added-large-files`
26+
Prevent giant files from being committed.
27+
- Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB).
28+
- If `git-lfs` is installed, lfs files will be skipped
29+
(requires `git-lfs>=2.2.1`)
30+
31+
#### `check-ast`
32+
Simply check whether files parse as valid python.
33+
34+
#### `check-builtin-literals`
35+
Require literal syntax when initializing empty or zero Python builtin types.
36+
- Allows calling constructors with positional arguments (e.g., `list('abc')`).
37+
- Allows calling constructors from the `builtins` (`__builtin__`) namespace (`builtins.list()`).
38+
- Ignore this requirement for specific builtin types with `--ignore=type1,type2,…`.
39+
- Forbid `dict` keyword syntax with `--no-allow-dict-kwargs`.
40+
41+
#### `check-byte-order-marker`
42+
Forbid files which have a UTF-8 byte-order marker
43+
44+
#### `check-case-conflict`
45+
Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
46+
47+
#### `check-docstring-first`
48+
Checks for a common error of placing code before the docstring.
49+
50+
#### `check-executables-have-shebangs`
51+
Checks that non-binary executables have a proper shebang.
52+
53+
#### `check-json`
54+
Attempts to load all json files to verify syntax.
55+
56+
#### `check-merge-conflict`
57+
Check for files that contain merge conflict strings.
58+
59+
#### `check-symlinks`
60+
Checks for symlinks which do not point to anything.
61+
62+
#### `check-toml`
63+
Attempts to load all TOML files to verify syntax.
64+
65+
#### `check-vcs-permalinks`
66+
Ensures that links to vcs websites are permalinks.
67+
68+
#### `check-xml`
69+
Attempts to load all xml files to verify syntax.
70+
71+
#### `check-yaml`
72+
Attempts to load all yaml files to verify syntax.
73+
- `--allow-multiple-documents` - allow yaml files which use the
74+
[multi-document syntax](http://www.yaml.org/spec/1.2/spec.html#YAML)
75+
- `--unsafe` - Instead of loading the files, simply parse them for syntax.
76+
A syntax-only check enables extensions and unsafe constructs which would
77+
otherwise be forbidden. Using this option removes all guarantees of
78+
portability to other yaml implementations.
79+
Implies `--allow-multiple-documents`.
80+
81+
#### `debug-statements`
82+
Check for debugger imports and py37+ `breakpoint()` calls in python source.
83+
84+
#### `detect-aws-credentials`
85+
Checks for the existence of AWS secrets that you have set up with the AWS CLI.
86+
The following arguments are available:
87+
- `--credentials-file CREDENTIALS_FILE` - additional AWS CLI style
88+
configuration file in a non-standard location to fetch configured
89+
credentials from. Can be repeated multiple times.
90+
- `--allow-missing-credentials` - Allow hook to pass when no credentials are detected.
91+
92+
#### `detect-private-key`
93+
Checks for the existence of private keys.
94+
95+
#### `double-quote-string-fixer`
96+
This hook replaces double quoted strings with single quoted strings.
97+
98+
#### `end-of-file-fixer`
99+
Makes sure files end in a newline and only a newline.
100+
101+
#### `fix-encoding-pragma`
102+
Add `# -*- coding: utf-8 -*-` to the top of python files.
103+
- To remove the coding pragma pass `--remove` (useful in a python3-only codebase)
104+
105+
#### `file-contents-sorter`
106+
Sort the lines in specified files (defaults to alphabetical).
107+
You must provide list of target files as input to it.
108+
Note that this hook WILL remove blank lines and does NOT respect any comments.
109+
110+
#### `flake8`
111+
Run flake8 on your python files.
112+
113+
#### `forbid-new-submodules`
114+
Prevent addition of new git submodules.
115+
116+
#### `mixed-line-ending`
117+
Replaces or checks mixed line ending.
118+
- `--fix={auto,crlf,lf,no}`
119+
- `auto` - Replaces automatically the most frequent line ending. This is the default argument.
120+
- `crlf`, `lf` - Forces to replace line ending by respectively CRLF and LF.
121+
- This option isn't compatible with git setup check-in LF check-out CRLF as git smudge this later than the hook is invoked.
122+
- `no` - Checks if there is any mixed line ending without modifying any file.
123+
124+
#### `name-tests-test`
125+
Assert that files in tests/ end in `_test.py`.
126+
- Use `args: ['--django']` to match `test*.py` instead.
127+
128+
#### `no-commit-to-branch`
129+
Protect specific branches from direct checkins.
130+
- Use `args: [--branch, staging, --branch, master]` to set the branch.
131+
`master` is the default if no branch argument is set.
132+
- `-b` / `--branch` may be specified multiple times to protect multiple
133+
branches.
134+
- `-p` / `--pattern` can be used to protect branches that match a supplied regex
135+
(e.g. `--pattern, release/.*`). May be specified multiple times.
136+
137+
#### `pretty-format-json`
138+
Checks that all your JSON files are pretty. "Pretty"
139+
here means that keys are sorted and indented. You can configure this with
140+
the following commandline options:
141+
- `--autofix` - automatically format json files
142+
- `--indent ...` - Control the indentation (either a number for a number of spaces or a string of whitespace). Defaults to 4 spaces.
143+
- `--no-ensure-ascii` preserve unicode characters instead of converting to escape sequences
144+
- `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys)
145+
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
146+
147+
#### `requirements-txt-fixer`
148+
Sorts entries in requirements.txt and removes incorrect entry for `pkg-resources==0.0.0`
149+
150+
#### `sort-simple-yaml`
151+
Sorts simple YAML files which consist only of top-level
152+
keys, preserving comments and blocks.
153+
154+
Note that `sort-simple-yaml` by default matches no `files` as it enforces a
155+
very specific format. You must opt in to this by setting `files`, for example:
156+
157+
```yaml
158+
- id: sort-simple-yaml
159+
files: ^config/simple/
160+
```
161+
162+
163+
#### `trailing-whitespace`
164+
Trims trailing whitespace.
165+
- To preserve Markdown [hard linebreaks](https://github.github.com/gfm/#hard-line-break)
166+
use `args: [--markdown-linebreak-ext=md]` (or other extensions used
167+
by your markdownfiles). If for some reason you want to treat all files
168+
as markdown, use `--markdown-linebreak-ext=*`.
169+
- By default, this hook trims all whitespace from the ends of lines.
170+
To specify a custom set of characters to trim instead, use `args: [--chars,"<chars to trim>"]`.
118171

119172
### Deprecated / replaced hooks
120173

@@ -124,7 +177,6 @@ Add this to your `.pre-commit-config.yaml`
124177

125178
### As a standalone package
126179

127-
If you'd like to use these hooks, they're also available as a standalone
128-
package.
180+
If you'd like to use these hooks, they're also available as a standalone package.
129181

130182
Simply `pip install pre-commit-hooks`

0 commit comments

Comments
 (0)