diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..72ac85a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,83 @@ +default_install_hook_types: + - pre-commit + - commit-msg +default_stages: + - pre-commit + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: + - --allow-multiple-documents + - id: check-toml + - id: check-added-large-files + - id: check-merge-conflict + + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v4.2.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [--verbose] + + - repo: https://github.com/crate-ci/typos + rev: v1.36.1 + hooks: + - id: typos + args: ["--force-exclude"] + + - repo: local + hooks: + - id: fmt + name: fmt + description: Format files with cargo fmt. + entry: cargo +nightly fmt + language: system + types: [rust] + args: ["--", "--check"] + # For some reason some formatting is different depending on how you invoke? + pass_filenames: false + + - id: clippy + name: clippy + description: Lint rust sources + entry: cargo clippy + language: system + args: ["--", "-D", "warnings"] + types: [file] + files: (\.rs|Cargo.lock)$ + pass_filenames: false + + - id: audit + name: audit + description: Audit packages + entry: cargo audit + args: ["--deny", "warnings"] + language: system + pass_filenames: false + verbose: true + always_run: true + + - id: udeps + name: unused + description: Check for unused crates + entry: cargo udeps + args: ["--workspace"] + language: system + types: [file] + files: (\.rs|Cargo.lock)$ + pass_filenames: false + + - id: test + name: test + description: Rust test + entry: cargo test + language: system + args: ["--workspace"] + types: [file] + files: (\.rs|Cargo.lock)$ + pass_filenames: false