fix: lint config

master^2
xingyu4j 2026-05-19 16:08:10 +08:00
parent f77166b3a2
commit c759cb2593
1 changed files with 21 additions and 13 deletions

View File

@ -8,20 +8,20 @@ interface LintCommandOptions {
*/ */
format?: boolean; format?: boolean;
/** /**
* Number of threads for oxlint (default: system CPU count). * Number of threads for oxfmt and oxlint (default: 2).
*/ */
threads?: number; threads?: number;
} }
async function runLint({ format, threads }: LintCommandOptions) { async function runLint({ format, threads }: LintCommandOptions) {
// process.env.FORCE_COLOR = '3'; // process.env.FORCE_COLOR = '3';
const threadsArg = threads ? ` --threads=${threads}` : ''; const threadsArg = threads ? ` --threads=${threads}` : ` --threads=2`;
if (format) { if (format) {
await execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache --fix`, { await execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache --fix`, {
stdio: 'inherit', stdio: 'inherit',
}); });
await execaCommand(`oxfmt`, { await execaCommand(`oxfmt${threadsArg}`, {
stdio: 'inherit', stdio: 'inherit',
}); });
await execaCommand(`oxlint --fix${threadsArg}`, { await execaCommand(`oxlint --fix${threadsArg}`, {
@ -32,20 +32,28 @@ async function runLint({ format, threads }: LintCommandOptions) {
}); });
return; return;
} }
await Promise.all([ const controller = new AbortController();
execaCommand(`oxfmt --check`, { const { signal: cancelSignal } = controller;
stdio: 'inherit',
}), const commands = [
execaCommand(`oxlint${threadsArg}`, { execaCommand(`oxfmt --check${threadsArg}`, {
stdio: 'inherit', cancelSignal,
}),
execaCommand(`eslint . --cache`, {
stdio: 'inherit', stdio: 'inherit',
}), }),
execaCommand(`oxlint${threadsArg}`, { cancelSignal, stdio: 'inherit' }),
execaCommand(`eslint . --cache`, { cancelSignal, stdio: 'inherit' }),
execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache`, { execaCommand(`stylelint "**/*.{vue,css,less,scss}" --cache`, {
cancelSignal,
stdio: 'inherit', stdio: 'inherit',
}), }),
]); ];
try {
await Promise.all(commands);
} catch (error) {
controller.abort();
throw error;
}
} }
function defineLintCommand(cac: CAC) { function defineLintCommand(cac: CAC) {
@ -53,7 +61,7 @@ function defineLintCommand(cac: CAC) {
.command('lint') .command('lint')
.usage('Batch execute project lint check.') .usage('Batch execute project lint check.')
.option('--format', 'Format lint problem.') .option('--format', 'Format lint problem.')
.option('--threads <count>', 'Number of threads for oxlint.') .option('--threads <count>', 'Number of threads for oxfmt and oxlint.')
.action(runLint); .action(runLint);
} }