-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.lint-staged.config.js
40 lines (37 loc) · 999 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
32
33
34
35
36
37
38
39
40
// lint-staged.config.js
const fs = require("fs");
const configPath = "tsconfig.lint.json";
const generateTSConfig = (stagedFilenames) => {
try {
if (fs.existsSync(configPath)) {
fs.unlinkSync(configPath);
}
const files = stagedFilenames.reduce((acc, filename) => {
if (fs.existsSync(filename)) {
return [...acc, filename];
}
return acc;
}, []);
const tsConfig = {
extends: "./tsconfig.json",
files: files,
};
fs.writeFileSync(configPath, JSON.stringify(tsConfig));
} catch (err) {
console.log("Error: generateTSConfig", err);
}
return "tsc --noEmit --project tsconfig.lint.json";
};
module.exports = {
"*.css": ["prettier --write", "stylelint"],
"*.{json,md,yml}": "prettier --write",
"*/*.js": [
"prettier --write",
"eslint --cache --cache-strategy content --fix",
],
"**/*.ts?(x)": [
"prettier --write",
"eslint --cache --cache-strategy content --fix",
generateTSConfig,
],
};