-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.lintstagedrc.js
40 lines (34 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
32
33
34
35
36
37
38
39
40
const path = require('path');
module.exports = {
'*': filenames => {
const commands = [];
const cwd = process.cwd();
const files = filenames
.filter(file => !file.match(/\.(ts)$/i))
.map(file => path.relative(cwd, file))
.map(file => `'${file}'`);
if (files.length === 0) {
return [];
}
commands.push(`prettier --write ${files.join(' ')}`);
return commands;
},
'*.ts': filenames => {
const commands = [];
const cwd = process.cwd();
const files = filenames.map(file => path.relative(cwd, file)).map(file => `'${file}'`);
if (files.length === 0) {
return [];
}
const filesForLint = filenames
.map(file => path.relative(cwd, file))
.filter(file => !file.match(/^e2e\//i))
.filter(file => !file.match(/^test\//i))
.map(file => `'${file}'`);
if (filesForLint.length) {
commands.push(`npm run lint -- --fix --force`);
}
commands.push(`prettier --write ${files.join(' ')}`);
return commands;
},
};