-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path.lintstagedrc.mjs
62 lines (56 loc) · 1.33 KB
/
.lintstagedrc.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
// @ts-check
import micromatch from "micromatch";
const CSPELL_CMD = "cspell --quiet --no-must-find-files";
/*
* Overview:
* - Fixes lint rules and formatting for code
* - Fixes formatting for md, json, yml, yaml, excluding a few things
*/
/**
* @type {import("lint-staged").Config}
*/
export default {
"packages/monorepo.*/**/*.{js,jsx,ts,tsx,mjs,cjs}": [
"dprint fmt",
CSPELL_CMD,
],
"*.md": [CSPELL_CMD],
"packages/**/*.{js,jsx,ts,tsx,mjs,cjs}": (
files,
) => {
const match = micromatch.not(
files,
[
"**/templates/**/*",
"**/generatedNoCheck/**/*",
"**/generatedNoCheck2/**/*",
"**/examples/**/*",
],
);
if (match.length === 0) return [];
return [
`dprint fmt ${match.join(" ")}`,
`eslint --fix ${match.join(" ")}`,
`${CSPELL_CMD} ${match.join(" ")}`,
];
},
"(.lintstagedrc.mjs|.monorepolint.config.mjs)": [
"dprint fmt",
CSPELL_CMD,
],
"*": (files) => {
const mrlFiles = micromatch(files, [
"package.json",
// "**/package.json",
"tsconfig.json",
"**/tsconfig.json",
], {});
const mrlCommands = mrlFiles.length > 0
? [
"monorepolint check --verbose",
`dprint fmt ${mrlFiles.join(" ")} --allow-no-files`,
]
: [];
return [...mrlCommands];
},
};