From 2b40ec6e643df269b237fa234dd47c8e30b78a68 Mon Sep 17 00:00:00 2001 From: Nick Sheck Date: Mon, 22 May 2023 11:07:43 -0700 Subject: [PATCH] fix: Ignore irrelevant warnings/errors in counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eslint lints by files, but we only care about _specific lines_ in each file. If you made a "clean" change in a "dirty" file, we would report the total number of eslint errors and warnings found — even if we didn't generate any annotations because your diff was good. This change has us adding up errors and warning from the changes we deem relevant to the PR instead of using the original numbers from eslint. --- dist/index.js | 6 +++++- src/main.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index f334c84..d4d990a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5811,7 +5811,9 @@ async function runEslint () { core.debug(`Raw report from eslint: ${JSON.stringify(report, null, 2)}`) - const { results, errorCount, warningCount } = report + const { results } = report + let errorCount = 0 + let warningCount = 0 const levels = ['', 'warning', 'failure'] @@ -5837,6 +5839,8 @@ async function runEslint () { if (!changeRanges.some(r => r.doesInclude(line))) continue + errorCount += msg.errorCount + warningCount += msg.warningCount const annotationLevel = levels[severity] annotations.push({ path, diff --git a/src/main.js b/src/main.js index 6d1e761..ee6e1ab 100644 --- a/src/main.js +++ b/src/main.js @@ -118,7 +118,9 @@ async function runEslint () { core.debug(`Raw report from eslint: ${JSON.stringify(report, null, 2)}`) - const { results, errorCount, warningCount } = report + const { results } = report + let errorCount = 0 + let warningCount = 0 const levels = ['', 'warning', 'failure'] @@ -144,6 +146,8 @@ async function runEslint () { if (!changeRanges.some(r => r.doesInclude(line))) continue + errorCount += msg.errorCount + warningCount += msg.warningCount const annotationLevel = levels[severity] annotations.push({ path,