forked from everget/pinescript-cheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.mjs
72 lines (66 loc) · 1.26 KB
/
lint-staged.config.mjs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import path from 'node:path';
import { quote } from 'shell-quote';
const IS_WINDOWS = process.platform === 'win32';
function escape(str) {
const escaped = quote(str);
return escaped.replace(/\\@/g, '@');
}
function getRelativePaths(filenames) {
return filenames
.map((f) => path.relative(process.cwd(), f))
.join(' ');
}
function escapeFileNames(filenames) {
return filenames
.map((f) => (IS_WINDOWS ? f : escape([f])))
.join(' ');
}
function gitAdd(filenames) {
return `git add ${escapeFileNames(filenames)}`;
}
function addCommands(stagedFiles, commands) {
return [
...commands,
gitAdd(stagedFiles),
];
}
export default {
'*.{,m,c}{j,t}s{,x}': (stagedFiles) => {
return [
'pnpm types:check',
'pnpm lint:js',
gitAdd(stagedFiles),
];
},
'*.{css,scss,sass,less,styl}': (stagedFiles) => {
return [
'pnpm lint:styles',
gitAdd(stagedFiles),
];
},
'*.vue': (stagedFiles) => {
return [
gitAdd(stagedFiles),
];
},
'*.astro': (stagedFiles) => {
return [
gitAdd(stagedFiles),
];
},
'*.{html,svg}': (stagedFiles) => {
return [
gitAdd(stagedFiles),
];
},
'*.{json,yml,yaml}': (stagedFiles) => {
return [
gitAdd(stagedFiles),
];
},
'*.{md,mdx}': (stagedFiles) => {
return [
gitAdd(stagedFiles),
];
},
};