forked from MastersAcademy/fe-react-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lintstagedrc.js
39 lines (33 loc) · 1.1 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
const path = require('path');
const getLintFlags = (absolutePaths) => {
const cwd = process.cwd();
const relativePaths = absolutePaths.map((file) => path.relative(cwd, file));
/**
*
* Some file paths are too long and cannot be added as parameter to eslint
* https://serverfault.com/questions/9546/filename-length-limits-on-linux/9548#9548
*
* */
const filePathLengthLimit = relativePaths.find((path) => path.length > 250);
/**
*
* There is a case, when the command is too long and eslint cannot execute it.
*
* */
const isTooManyFilesToLint = relativePaths.length > 20;
return {
relativePaths,
filePathLengthLimit,
isTooManyFilesToLint,
};
};
module.exports = {
'**/*.{js,jsx,ts,tsx}': (absolutePaths) => {
const { relativePaths } = getLintFlags(absolutePaths);
return `eslint ${relativePaths.join(' ')}`;
},
'**/*.css': (absolutePaths) => {
const { relativePaths } = getLintFlags(absolutePaths);
return `stylelint --config .stylelintrc ${relativePaths.join(' ')}`;
},
};