ruoyi-plus-vben5/scripts/vsh/src/lint/index.ts

49 lines
1.1 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) {
2024-07-31 21:26:54 +08:00
await execaCommand(`stylelint "**/*.{vue,css,less.scss}" --cache --fix`, {
stdio: 'inherit',
});
2024-08-03 10:12:45 +08:00
await execaCommand(`eslint . --cache --fix`, {
stdio: 'inherit',
});
2024-07-31 21:26:54 +08:00
await execaCommand(`prettier . --write --cache --log-level warn`, {
stdio: 'inherit',
});
2024-05-19 21:20:42 +08:00
return;
}
await Promise.all([
2024-07-31 21:26:54 +08:00
execaCommand(`eslint . --cache`, {
stdio: 'inherit',
}),
execaCommand(`prettier . --ignore-unknown --check --cache`, {
stdio: 'inherit',
}),
execaCommand(`stylelint "**/*.{vue,css,less.scss}" --cache`, {
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 };