-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-staged.config.js
31 lines (30 loc) · 1021 Bytes
/
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
const path = require('path');
module.exports = {
'*.{json,md,css,scss}': (files) => {
if (files.length > 0 && files[0] !== '[filename]' && files[0] !== '[file]') {
const cwd = process.cwd();
const relativePaths = files.map((f) => path.relative(cwd, f));
/**
* We don't need to run the linter for these files.
*/
return [`nx format:write --files="${relativePaths.join(',')}"`];
} else {
return [];
}
},
'*.{html,js,ts}': (files) => {
if (files.length > 0 && files[0] !== '[filename]' && files[0] !== '[file]') {
const cwd = process.cwd();
const relativePaths = files.map((f) => path.relative(cwd, f));
/**
* This reduces the memory consumption of the script, so it won't fail on particular machines.
*/
return [
`nx format:write --files="${relativePaths.join(',')}"`, //
`nx affected:lint --files="${relativePaths.join(',')}" --fix --parallel`, //
];
} else {
return [];
}
},
};