Files
ruoyi-plus-vben5-h/scripts/vsh/src/lint/index.ts
2026-03-14 19:48:40 +08:00

55 lines
1.2 KiB
TypeScript

import type { CAC } from 'cac';
import { execaCommand } from '@vben/node-utils';
interface LintCommandOptions {
/**
* Format lint problem.
*/
format?: boolean;
}
async function runLint({ format }: LintCommandOptions) {
// process.env.FORCE_COLOR = '3';
if (format) {
await execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache --fix`, {
stdio: 'inherit',
});
await execaCommand(`oxfmt`, {
stdio: 'inherit',
});
await execaCommand(`oxlint --fix`, {
stdio: 'inherit',
});
await execaCommand(`eslint . --cache --fix`, {
stdio: 'inherit',
});
return;
}
await Promise.all([
execaCommand(`oxfmt --check`, {
stdio: 'inherit',
}),
execaCommand(`oxlint`, {
stdio: 'inherit',
}),
execaCommand(`eslint . --cache`, {
stdio: 'inherit',
}),
execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache`, {
stdio: 'inherit',
}),
]);
}
function defineLintCommand(cac: CAC) {
cac
.command('lint')
.usage('Batch execute project lint check.')
.option('--format', 'Format lint problem.')
.action(runLint);
}
export { defineLintCommand };