codeant-ai-for-open-source[bot] commented on code in PR #44201:
URL: https://github.com/apache/superset/pull/44201#discussion_r4015086832


##########
superset-frontend/scripts/oxlint-metrics-uploader.js:
##########
@@ -130,102 +163,52 @@ async function runOxlintAndProcess() {
     );
 
     const results = JSON.parse(oxlintOutput);
-
-    // Process OXC JSON output
-    const metricsByRule = {};
-    let occurrencesData = [];
-
-    // OXC JSON format has diagnostics array
-    if (results.diagnostics && Array.isArray(results.diagnostics)) {
-      results.diagnostics.forEach(diagnostic => {
-        const ruleId = parseRuleId(diagnostic.code);
-
-        const file = diagnostic.filename || 'unknown';
-        const line = diagnostic.labels?.[0]?.span?.line || 0;
-        const column = diagnostic.labels?.[0]?.span?.column || 0;
-        const message = diagnostic.message || '';
-
-        const ruleData = metricsByRule[ruleId] || { count: 0 };
-        ruleData.count += 1;
-        metricsByRule[ruleId] = ruleData;
-
-        occurrencesData.push({
-          rule: ruleId,
-          message,
-          file,
-          line,
-          column,
-          ts: DATETIME,
-        });
-      });
-    }
-
     console.log(
       `OXC found ${results.diagnostics?.length || 0} issues across 
${results.number_of_files} files`,
     );
+    const { metricsByRule, occurrencesData } = parseOxlintResult(results);
+
+    // Also run Oxlint for custom rules and merge results
+    console.log('Running Oxlint for custom rules...');
+    // Run ESLint and capture output directly.
+    // Flat config (oxlint.custom-lint-rules.mts) is explicitly selected via 
--config
+    const oxlintCustomRuleOutput = execSync(
+      'npx oxlint --config oxlint.custom-lint-rules.mts --format json src',
+      {
+        encoding: 'utf8',
+        maxBuffer: 50 * 1024 * 1024, // 50MB buffer for large outputs
+        stdio: ['pipe', 'pipe', 'ignore'], // Ignore stderr
+      },

Review Comment:
   Yes. The custom Oxlint invocation should catch its nonzero exit status and 
continue parsing `error.stdout`, just as the removed ESLint path did. 
Unexpected failures without JSON output should still be rethrown.
   
   ```js
   let oxlintCustomRuleOutput = '{}';
   
   try {
     oxlintCustomRuleOutput = execSync(
       'npx oxlint --config oxlint.custom-lint-rules.mts --format json src',
       {
         encoding: 'utf8',
         maxBuffer: 50 * 1024 * 1024,
         stdio: ['pipe', 'pipe', 'ignore'],
       },
     );
   } catch (error) {
     if (error.stdout) {
       oxlintCustomRuleOutput = error.stdout.toString();
     } else {
       throw error;
     }
   }
   
   const oxlintCustomRuleResults = JSON.parse(oxlintCustomRuleOutput);
   ```
   
   This preserves diagnostics when custom rules report violations while still 
surfacing configuration, startup, or parsing failures that produce no JSON 
output.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to