From a9ba90373fee669dbe4a2978de6a3480604aea65 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. --- src/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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,