Rust hooks for pre-commit.
Add this to your .pre-commit-config.yaml:
- repo: https://github.com/CostcoFanboy/pre-commit-rust
rev: master # Use the latest tag or commit hash
hooks:
- id: fmt
- id: clippyChecks the package for compile errors without producing binaries.
- id: cargo-checkFormats Rust code according to style guidelines. This hook runs in check mode and will fail if code is not formatted.
- id: fmtRuns the Clippy linter with strict settings, treating warnings as errors.
- id: clippyRuns the test suite using cargo test.
- id: testChecks for known security vulnerabilities in dependencies. Requires cargo-audit to be installed.
Install with:
cargo install cargo-auditThen add to your config:
- id: auditHere's a complete example using all available hooks:
- repo: https://github.com/CostcoFanboy/pre-commit-rust
rev: master
hooks:
- id: cargo-check
- id: fmt
- id: clippy
- id: test
- id: audit- Rust toolchain (rustc, cargo, rustfmt, clippy)
cargo-audit(optional, only needed for the audit hook)
See LICENSE file.