Browse Source

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.
xingyu4j 3 weeks ago
parent
commit
7c943cc06b
2 changed files with 10 additions and 4 deletions
  1. 1 1
      .vscode/settings.json
  2. 9 3
      scripts/vsh/src/lint/index.ts

+ 1 - 1
.vscode/settings.json

@@ -38,7 +38,7 @@
 
   // lint && format
   "oxc.enable": true,
-  "oxc.typeAware": true,
+  "oxc.typeAware": false,
   "oxc.configPath": "oxlint.config.ts",
   "oxc.fmt.configPath": "oxfmt.config.ts",
   "eslint.useFlatConfig": true,

+ 9 - 3
scripts/vsh/src/lint/index.ts

@@ -7,10 +7,15 @@ interface LintCommandOptions {
    * Format lint problem.
    */
   format?: boolean;
+  /**
+   * Number of threads for oxlint (default: system CPU count).
+   */
+  threads?: number;
 }
 
-async function runLint({ format }: LintCommandOptions) {
+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`, {
@@ -19,7 +24,7 @@ async function runLint({ format }: LintCommandOptions) {
     await execaCommand(`oxfmt`, {
       stdio: 'inherit',
     });
-    await execaCommand(`oxlint --fix`, {
+    await execaCommand(`oxlint --fix${threadsArg}`, {
       stdio: 'inherit',
     });
     await execaCommand(`eslint . --cache --fix`, {
@@ -31,7 +36,7 @@ async function runLint({ format }: LintCommandOptions) {
     execaCommand(`oxfmt --check`, {
       stdio: 'inherit',
     }),
-    execaCommand(`oxlint`, {
+    execaCommand(`oxlint${threadsArg}`, {
       stdio: 'inherit',
     }),
     execaCommand(`eslint . --cache`, {
@@ -48,6 +53,7 @@ function defineLintCommand(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);
 }