Skip to content

berquist/pre-commit-rust

 
 

Repository files navigation

Rust hooks for pre-commit

pre-commit hooks for Rust tools.

Usage

First, install the pre-commit Python package.

Second, create a .pre-commit-config.yaml file in the top level of your Git-based project with the following content:

- repo: https://github.com/berquist/pre-commit-rust
  rev: main
  hooks:
    - id: cargo-fmt
    - id: cargo-check
    - id: cargo-clippy
    - id: cargo-test

Finally, install the pre-commit hook locally and run it for the first time:

pre-commit install
pre-commit run -a

Passing arguments to rustfmt

- repo: https://github.com/berquist/pre-commit-rust
  rev: main
  hooks:
    - id: cargo-fmt
      args: ['--verbose', '--', '--edition', '2018' ]

Note: cargo fmt picks up "edition" automatically from Cargo.toml, so specifying this isn't necessary in most cases.

About

Rust hooks for pre-commit

Resources

Stars

Watchers

Forks

Packages

No packages published