-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.js
31 lines (28 loc) · 1.01 KB
/
.lintstagedrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { quote } from "shell-quote";
const isWin = process.platform === "win32";
export default {
"**/*.{js,jsx,mjs,ts,tsx,mts}": (filenames) => {
const fileArgs = escape(filenames);
return [
`prettier --write ${fileArgs}`,
`eslint --max-warnings=0 --no-warn-ignored --fix ${fileArgs}`,
];
},
"**/*.{json,json5,md,mdx,html,css,scss,yml,yaml}": (filenames) => {
const fileArgs = escape(filenames);
return [`prettier --write ${fileArgs}`];
},
// Note that cargo-clippy is not run because it will need to compile the project and
// cannot be limited only to staged files, making it not a good idea for a pre-commit
// hook; we shall rely on CI to discover cargo-clippy issues and recommend users to
// manually fix or use `pnpm lint:rs`
"**/*.rs": (filenames) => {
const fileArgs = escape(filenames);
return [`rustfmt -- ${fileArgs}`];
},
};
function escape(filenames) {
return filenames
.map((filename) => (isWin ? `"${filename}"` : quote([filename])))
.join(" ");
}