-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the clippy check precommit hook (#71)
It turns out that `clippy-driver` can only accept single files as input, while `lint-staged` calls by default with batches of files. This uses the JS configuration option to instead create a separate task for each Rust file that needs to be linted.
- Loading branch information
1 parent
a7ce0fd
commit 6571743
Showing
3 changed files
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Rust | ||
/target | ||
main | ||
|
||
# Tooling | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default { | ||
// These are simple, as they can just run prettier directly on any number of files. | ||
"(*.md|*.toml|*.json|*.yaml|*.yml|*.css|*.js|*.mjs|*.ts)": ["prettier --write"], | ||
|
||
// Unfortunately `clippy-driver` can only accept one file at a time, so we have to create an | ||
// individual clippy task for each changed file. | ||
"*.rs": async (stagedFiles) => | ||
[ | ||
`rustfmt --unstable-features --edition 2021 ${stagedFiles.join(" ")}`, | ||
stagedFiles.map((filename) => `clippy-driver ${filename}`), | ||
].flat(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters