Files
yudao-ui-admin-vben/scripts/vsh/src/lint/index.ts
xingyu4j 7c943cc06b chore: disable oxc typeAware and add --threads option for oxlint
Type-aware linting was consuming excessive memory with nearly all
type-aware rules turned off. Add --threads CLI option to control
oxlint parallelism.
2026-05-18 18:46:13 +08:00

61 lines
1.4 KiB
TypeScript

import type { CAC } from 'cac';
import { execaCommand } from '@vben/node-utils';
interface LintCommandOptions {
/**
* Format lint problem.
*/
format?: boolean;
/**
* Number of threads for oxlint (default: system CPU count).
*/
threads?: number;
}
async function runLint({ format, threads }: LintCommandOptions) {
// process.env.FORCE_COLOR = '3';
const threadsArg = threads ? ` --threads=${threads}` : '';
if (format) {
await execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache --fix`, {
stdio: 'inherit',
});
await execaCommand(`oxfmt`, {
stdio: 'inherit',
});
await execaCommand(`oxlint --fix${threadsArg}`, {
stdio: 'inherit',
});
await execaCommand(`eslint . --cache --fix`, {
stdio: 'inherit',
});
return;
}
await Promise.all([
execaCommand(`oxfmt --check`, {
stdio: 'inherit',
}),
execaCommand(`oxlint${threadsArg}`, {
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.')
.option('--threads <count>', 'Number of threads for oxlint.')
.action(runLint);
}
export { defineLintCommand };