Lint all Rust projects in pre-commit
Summary:
Resolves ENG-2314.
- Added a get_cargo_paths.js - it contains a helper function that looks for Cargo project directory for given .rs file path.
- Modified .lintstaged.js to collect a set of modified cargo projects and pass this list to rust_pre_commit.sh script.
- Modified rust_pre_commit.sh script to accept Cargo project paths as command line arguments.
This way, cargo fmt + cargo check is run once per modified cargo project.
Test Plan:
# do some changes in any .rs file e.g. in 2+ services/ projects # lint should run once per cargo project # it's best to do some incorrect formatting git add . # or git commit, command below runs only the hook, without commiting lint-staged # linter should fail on your formatting
Reviewers: varun, jon, ashoat
Reviewed By: varun, jon, ashoat
Subscribers: ashoat, tomek, atul
Differential Revision: https://phab.comm.dev/D6310