From 8b3529385e32874cfff2e8015d1bfeee9d0d4f95 Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Fri, 27 Feb 2026 17:10:30 -0300 Subject: [PATCH] fix: do not store errors, errors from files not included should not be reported --- src/linter.js | 29 +---------------------------- test/watch.test.js | 6 ++---- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/linter.js b/src/linter.js index 6b78eef..3a8f4ad 100644 --- a/src/linter.js +++ b/src/linter.js @@ -2,7 +2,6 @@ const { dirname, isAbsolute, join } = require("node:path"); const ESLintError = require("./ESLintError"); const { getESLint } = require("./getESLint"); -const { arrify } = require("./utils"); /** @typedef {import("eslint").ESLint} ESLint */ /** @typedef {import("eslint").ESLint.Formatter} Formatter */ @@ -17,21 +16,6 @@ const { arrify } = require("./utils"); /** @typedef {(files: string | string[]) => void} Linter */ /** @typedef {{ [files: string]: LintResult }} LintResultMap */ -/** @type {WeakMap} */ -const resultStorage = new WeakMap(); - -/** - * @param {Compilation} compilation compilation - * @returns {LintResultMap} lint result map - */ -function getResultStorage({ compiler }) { - let storage = resultStorage.get(compiler); - if (!storage) { - resultStorage.set(compiler, (storage = {})); - } - return storage; -} - /** * @param {Promise[]} results results * @returns {Promise} flatted results @@ -196,8 +180,6 @@ async function linter(key, options, compilation) { /** @type {Promise[]} */ const rawResults = []; - const crossRunResultStorage = getResultStorage(compilation); - try { ({ eslint, lintFiles, cleanup, threads } = await getESLint(key, options)); } catch (err) { @@ -208,9 +190,6 @@ async function linter(key, options, compilation) { * @param {string | string[]} files files */ function lint(files) { - for (const file of arrify(files)) { - delete crossRunResultStorage[file]; - } rawResults.push( lintFiles(files).catch((err) => { compilation.errors.push(new ESLintError(err.message)); @@ -224,7 +203,7 @@ async function linter(key, options, compilation) { */ async function report() { // Filter out ignored files. - let results = await removeIgnoredWarnings( + const results = await removeIgnoredWarnings( eslint, // Get the current results, resetting the rawResults to empty await flatten(rawResults.splice(0)), @@ -232,12 +211,6 @@ async function linter(key, options, compilation) { await cleanup(); - for (const result of results) { - crossRunResultStorage[result.filePath] = result; - } - - results = Object.values(crossRunResultStorage); - // do not analyze if there are no results or eslint config if (!results || results.length < 1) { return {}; diff --git a/test/watch.test.js b/test/watch.test.js index 76ac2dd..5dbd468 100644 --- a/test/watch.test.js +++ b/test/watch.test.js @@ -44,10 +44,7 @@ describe("watch", () => { function finish(err, stats) { expect(err).toBeNull(); expect(stats.hasWarnings()).toBe(false); - const { errors } = stats.compilation; - const [{ message }] = errors; - expect(stats.hasErrors()).toBe(true); - expect(message).toEqual(expect.stringMatching("prefer-const")); + expect(stats.hasErrors()).toBe(false); done(); } @@ -62,6 +59,7 @@ describe("watch", () => { expect(message).toEqual(expect.stringMatching("no-unused-vars")); // `prefer-const` fails here expect(message).toEqual(expect.stringMatching("prefer-const")); + expect(message).toEqual(expect.stringMatching("\\(4 errors,")); next = finish;