-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.js
45 lines (39 loc) · 1 KB
/
lint-staged.config.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { quote } = require('shell-quote');
const isWin = process.platform === 'win32';
function escape(str) {
const escaped = quote(str);
return escaped.replace(/\\@/g, '@');
}
function escapeFileNames(filenames) {
return filenames
.map((filename) => (isWin ? filename : escape([filename])))
.join(' ');
}
module.exports = {
'*.{ts,tsx,js,jsx,mts,mtsx,mjs,mjsx,cts,ctsx,cjs,cjsx}': (filenames) => {
return [
'pnpm format-staged',
'pnpm types-check',
'pnpm lint-js-fix',
'vitest related --run --bail 1 --coverage=false',
`git add ${escapeFileNames(filenames)}`,
];
},
'*.{css,scss,sass,less,styl}': (filenames) => {
return [
'pnpm format-staged',
'stylelint --cache --fix',
`git add ${escapeFileNames(filenames)}`,
];
},
'*.{json,yml,yaml}': (filenames) => {
return ['pnpm format-staged', `git add ${escapeFileNames(filenames)}`];
},
'*.{md}': (filenames) => {
return [
'pnpm format-staged',
'pnpm lint-md-fix',
`git add ${escapeFileNames(filenames)}`,
];
},
};