From 89fbd813312b25b04fdf4afcfbc806654eceff51 Mon Sep 17 00:00:00 2001 From: Tom <25043847+Douile@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:41:20 +0000 Subject: [PATCH] [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/ --- .pre-commit-config.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..40cd9bd --- /dev/null +++ b/.pre-commit-config.yaml @@ -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