Skip to content

Commit df0ef3b

Browse files
authored
Add common pre-commit hooks (#8059)
Pre-commits are usually used to minimize busy work by the contributors, e.g., by fixing extra spacing, formatting, etc. This PR adds various basic text file checks to the repo. I also made yaml spacing a bit cleaner. I was a bit surprised it is used for `cargo clippy` because you wouldn't want clippy's auto-fixes to be auto-applied by CI, so usually GitHub workflow simply checks runs it regularly. This is outside of the scope for this PR, but perhaps it should be removed here?
2 parents 60c55d7 + f46e096 commit df0ef3b

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
13
repos:
2-
- repo: local
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
36
hooks:
4-
- id: rust-linting
7+
- id: check-added-large-files
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
- id: check-shebang-scripts-are-executable
11+
exclude: '.+\.rs' # would be triggered by #![some_attribute]
12+
- id: check-symlinks
13+
- id: check-toml
14+
- id: check-yaml
15+
args: [ --allow-multiple-documents ]
16+
- id: destroyed-symlinks
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
args: [ --fix=lf ]
20+
- id: trailing-whitespace
21+
22+
- repo: local
23+
hooks:
24+
- id: rust-linting
525
name: Rust linting
626
description: Run cargo fmt on files included in the commit.
727
entry: cargo +stable fmt --
828
pass_filenames: true
929
types: [file, rust]
1030
language: system
11-
- id: rust-clippy
31+
- id: rust-clippy
1232
name: Rust clippy
1333
description: Run cargo clippy on files included in the commit.
1434
entry: cargo +stable clippy --workspace --all-targets --all-features -- -D warnings
1535
pass_filenames: false
1636
types: [file, rust]
1737
language: system
18-
- id: cspell
38+
- id: cspell
1939
name: Code spell checker (cspell)
2040
description: Run cspell to check for spelling errors.
2141
entry: cspell --no-must-find-files --

0 commit comments

Comments
 (0)