Skip to content

Commit

Permalink
add cargo fmt to lint staged (vercel#56430)
Browse files Browse the repository at this point in the history
Keep forgetting to run `cargo fmt` before committing

Closes WEB-1707
  • Loading branch information
ForsakenHarmony authored Oct 4, 2023
1 parent 338f80b commit 00aea74
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 00aea74

Please sign in to comment.