index.ts
1.35 KB
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
import type { CAC } from "cac";
import { execaCommand, findMonorepoRoot } from "@venus/node-utils";
interface LintCommandOptions {
/**
* Format lint problem.
*/
format?: boolean;
}
async function runLint({ format }: LintCommandOptions) {
// process.env.FORCE_COLOR = '3';
const root = findMonorepoRoot();
if (format) {
console.log("\n📝 Running Prettier...");
await execaCommand(`prettier . --write --cache`, {
stdio: "inherit",
cwd: root,
});
console.log("\n🎨 Running Stylelint...");
await execaCommand(`stylelint "**/*.{vue,css,less,scss,wxss}" --cache --fix --formatter verbose`, {
stdio: "inherit",
cwd: root,
});
console.log("\n🔍 Running ESLint...");
await execaCommand(`eslint . --cache --fix`, {
stdio: "inherit",
cwd: root,
});
console.log("\n✅ Format completed!");
return;
}
await Promise.all([
execaCommand(`prettier . --ignore-unknown --check --cache`, {
stdio: "inherit",
cwd: root,
}),
execaCommand(`pnpm eslint . --cache`, {
stdio: "inherit",
cwd: root,
}),
execaCommand(`stylelint "**/*.{vue,css,less,scss,wxss}" --cache`, {
stdio: "inherit",
cwd: root,
}),
]);
}
function defineLintCommand(cac: CAC) {
cac.command("lint")
.usage("Batch execute project lint check.")
.option("--format", "Format lint problem.")
.action(runLint);
}
export { defineLintCommand };