Files
xk-admin/scripts/vsh/src/lint/index.ts

55 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-05-19 21:20:42 +08:00
import type { CAC } from 'cac';
2024-07-31 21:26:54 +08:00
import { execaCommand } from '@vben/node-utils';
2024-05-19 21:20:42 +08:00
interface LintCommandOptions {
/**
* Format lint problem.
*/
format?: boolean;
}
async function runLint({ format }: LintCommandOptions) {
2024-07-31 21:26:54 +08:00
// process.env.FORCE_COLOR = '3';
2024-05-19 21:20:42 +08:00
if (format) {
await execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache --fix`, {
2024-07-31 21:26:54 +08:00
stdio: 'inherit',
});
await execaCommand(`oxfmt .`, {
2024-08-03 10:12:45 +08:00
stdio: 'inherit',
});
await execaCommand(`oxlint . --fix`, {
stdio: 'inherit',
});
await execaCommand(`eslint . --cache --fix`, {
2024-07-31 21:26:54 +08:00
stdio: 'inherit',
});
2024-05-19 21:20:42 +08:00
return;
}
await Promise.all([
2026-03-13 23:41:17 +08:00
execaCommand(`oxfmt . --check`, {
2024-07-31 21:26:54 +08:00
stdio: 'inherit',
}),
2026-03-13 23:31:19 +08:00
execaCommand(`oxlint .`, {
2026-03-13 22:12:15 +08:00
stdio: 'inherit',
}),
execaCommand(`eslint . --cache`, {
2024-07-31 21:26:54 +08:00
stdio: 'inherit',
}),
execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache`, {
2024-07-31 21:26:54 +08:00
stdio: 'inherit',
}),
2024-05-19 21:20:42 +08:00
]);
}
function defineLintCommand(cac: CAC) {
cac
.command('lint')
.usage('Batch execute project lint check.')
.option('--format', 'Format lint problem.')
.action(runLint);
}
export { defineLintCommand };