From 00aea747c5ce816a71e3c1f7730786c218de920e Mon Sep 17 00:00:00 2001 From: Leah Date: Wed, 4 Oct 2023 19:46:44 +0200 Subject: [PATCH] add `cargo fmt` to lint staged (#56430) Keep forgetting to run `cargo fmt` before committing Closes WEB-1707 --- lint-staged.config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lint-staged.config.js b/lint-staged.config.js index b44eaea2a0a3f..8c1b2df519b67 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -27,6 +27,12 @@ module.exports = { `git add ${escapedFileNames}`, ] }, + '**/*.rs': (filenames) => { + const escapedFileNames = filenames + .map((filename) => (isWin ? filename : escape([filename]))) + .join(' ') + return [`cargo fmt -- ${escapedFileNames}`, `git add ${escapedFileNames}`] + }, } function escape(str) {