[Crate] Add clippy and rustfmt pre-commit hooks (#50)

These hooks can be installed using [pre-commit], with:
"pre-commit install". Once installed they will prevent you from
committing if the staged code has clippy warnings or hasn't been
formatted. You can skip the pre-commit checks by adding the "-n" flag to
your git commit command.

The hooks also require rustup as the nightly versions of rustfmt and
clippy are used.

[pre-commit]: https://pre-commit.com/
This commit is contained in:
Tom 2023-06-25 11:41:20 +00:00 committed by GitHub
parent 31162b6d6e
commit 89fbd81331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

17
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,17 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: clippy
name: Check clippy
language: system
files: '[.]rs$'
pass_filenames: false
entry: rustup run --install nightly cargo-clippy -- -- -D warnings
- id: format
name: Check rustfmt
language: system
files: '[.]rs$'
pass_filenames: false
entry: rustup run --install nightly cargo-fmt --check