-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy path.lintstagedrc.mjs
More file actions
36 lines (29 loc) · 909 Bytes
/
.lintstagedrc.mjs
File metadata and controls
36 lines (29 loc) · 909 Bytes
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
import micromatch from 'micromatch';
export default {
// Use custom function to avoid overlaps that could cause race conditions
[`*`]: (allChanges) => {
const commands = [];
if (micromatch.some(allChanges, '**/package.json')) {
commands.push(`yarn syncpack format`);
}
if (micromatch.some(allChanges, 'yarn.lock')) {
commands.push(`yarn dedupe`);
}
const eslintExtensions = `{mdx,ts,tsx,js,jsx,json}`;
const eslintFiles = micromatch(
allChanges,
[`**/*.${eslintExtensions}`, `?(.)**.${eslintExtensions}`],
{ dot: true }
);
if (eslintFiles.length) {
commands.push(
`node_modules/@codecademy/eslint-config/bin/eslint-fix.js ${eslintFiles.join(
' '
)}`
);
}
// Run nx format, which will run prettier
commands.push(`nx format:write --files ${allChanges}`);
return commands;
},
};