From 0d1e9e0125103a831ed78a0981ec3555a41bef85 Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Thu, 13 Jan 2022 23:24:57 +0100 Subject: [PATCH] fix: Add property `fatalErrorCount` to ignored file results Fixes #15510 --- lib/cli-engine/cli-engine.js | 3 +++ lib/eslint/eslint.js | 1 + tests/lib/cli-engine/cli-engine.js | 13 +++++++++++-- tests/lib/eslint/eslint.js | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/cli-engine/cli-engine.js b/lib/cli-engine/cli-engine.js index c8e137f4ded..0aff182f0ff 100644 --- a/lib/cli-engine/cli-engine.js +++ b/lib/cli-engine/cli-engine.js @@ -92,6 +92,7 @@ const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]); * @property {string} filePath The path to the file that was linted. * @property {LintMessage[]} messages All of the messages for the result. * @property {number} errorCount Number of errors for the result. + * @property {number} fatalErrorCount Number of fatal errors for the result. * @property {number} warningCount Number of warnings for the result. * @property {number} fixableErrorCount Number of fixable errors for the result. * @property {number} fixableWarningCount Number of fixable warnings for the result. @@ -104,6 +105,7 @@ const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]); * @typedef {Object} LintReport * @property {LintResult[]} results All of the result. * @property {number} errorCount Number of errors for the result. + * @property {number} fatalErrorCount Number of fatal errors for the result. * @property {number} warningCount Number of warnings for the result. * @property {number} fixableErrorCount Number of fixable errors for the result. * @property {number} fixableWarningCount Number of fixable warnings for the result. @@ -308,6 +310,7 @@ function createIgnoreResult(filePath, baseDir) { } ], errorCount: 0, + fatalErrorCount: 0, warningCount: 1, fixableErrorCount: 0, fixableWarningCount: 0 diff --git a/lib/eslint/eslint.js b/lib/eslint/eslint.js index 6274772ad85..ee6b2ef456b 100644 --- a/lib/eslint/eslint.js +++ b/lib/eslint/eslint.js @@ -79,6 +79,7 @@ const { version } = require("../../package.json"); * @property {string} filePath The path to the file that was linted. * @property {LintMessage[]} messages All of the messages for the result. * @property {number} errorCount Number of errors for the result. + * @property {number} fatalErrorCount Number of fatal errors for the result. * @property {number} warningCount Number of warnings for the result. * @property {number} fixableErrorCount Number of fixable errors for the result. * @property {number} fixableWarningCount Number of fixable warnings for the result. diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js index 2ba4839baf6..8871ff86c00 100644 --- a/tests/lib/cli-engine/cli-engine.js +++ b/tests/lib/cli-engine/cli-engine.js @@ -235,6 +235,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results.length, 1); assert.strictEqual(report.errorCount, 0); assert.strictEqual(report.warningCount, 1); + assert.strictEqual(report.fatalErrorCount, 0); assert.strictEqual(report.fixableErrorCount, 0); assert.strictEqual(report.fixableWarningCount, 0); assert.strictEqual(report.results[0].filePath, getFixturePath("passing.js")); @@ -243,6 +244,7 @@ describe("CLIEngine", () => { assert.isUndefined(report.results[0].messages[0].output); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); + assert.strictEqual(report.results[0].fatalErrorCount, 0); assert.strictEqual(report.results[0].fixableErrorCount, 0); assert.strictEqual(report.results[0].fixableWarningCount, 0); }); @@ -982,6 +984,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results.length, 1); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); + assert.strictEqual(report.results[0].fatalErrorCount, 0); assert.strictEqual(report.results[0].fixableErrorCount, 0); assert.strictEqual(report.results[0].fixableWarningCount, 0); assert.strictEqual(report.results[0].messages[0].message, expectedMsg); @@ -1045,6 +1048,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results.length, 1); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); + assert.strictEqual(report.results[0].fatalErrorCount, 0); assert.strictEqual(report.results[0].fixableErrorCount, 0); assert.strictEqual(report.results[0].fixableWarningCount, 0); assert.strictEqual(report.results[0].messages[0].message, expectedMsg); @@ -1066,6 +1070,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results.length, 1); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); + assert.strictEqual(report.results[0].fatalErrorCount, 0); assert.strictEqual(report.results[0].fixableErrorCount, 0); assert.strictEqual(report.results[0].fixableWarningCount, 0); assert.strictEqual(report.results[0].messages[0].message, expectedMsg); @@ -1415,6 +1420,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results.length, 1); assert.strictEqual(report.errorCount, 0); assert.strictEqual(report.warningCount, 1); + assert.strictEqual(report.fatalErrorCount, 0); assert.strictEqual(report.fixableErrorCount, 0); assert.strictEqual(report.fixableWarningCount, 0); assert.strictEqual(report.results[0].filePath, filePath); @@ -1422,6 +1428,7 @@ describe("CLIEngine", () => { assert.strictEqual(report.results[0].messages[0].message, "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); + assert.strictEqual(report.results[0].fatalErrorCount, 0); assert.strictEqual(report.results[0].fixableErrorCount, 0); assert.strictEqual(report.results[0].fixableWarningCount, 0); }); @@ -4824,12 +4831,14 @@ describe("CLIEngine", () => { assert.lengthOf(report.results, 1); assert.strictEqual(report.errorCount, 0); assert.strictEqual(report.warningCount, 1); + assert.strictEqual(report.fatalErrorCount, 0); assert.strictEqual(report.fixableErrorCount, 0); assert.strictEqual(report.fixableWarningCount, 0); assert.strictEqual(report.results[0].errorCount, 0); assert.strictEqual(report.results[0].warningCount, 1); - assert.strictEqual(report.fixableErrorCount, 0); - assert.strictEqual(report.fixableWarningCount, 0); + assert.strictEqual(report.results[0].fatalErrorCount, 0); + assert.strictEqual(report.results[0].fixableErrorCount, 0); + assert.strictEqual(report.results[0].fixableWarningCount, 0); }); it("should return source code of file in the `source` property", () => { diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js index 4e140f7fe0f..d77eac5d44c 100644 --- a/tests/lib/eslint/eslint.js +++ b/tests/lib/eslint/eslint.js @@ -324,6 +324,7 @@ describe("ESLint", () => { assert.strictEqual(results[0].messages[0].output, void 0); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); assert.strictEqual(results[0].fixableErrorCount, 0); assert.strictEqual(results[0].fixableWarningCount, 0); assert.strictEqual(results[0].usedDeprecatedRules.length, 0); @@ -1044,6 +1045,7 @@ describe("ESLint", () => { assert.strictEqual(results.length, 1); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); assert.strictEqual(results[0].fixableErrorCount, 0); assert.strictEqual(results[0].fixableWarningCount, 0); assert.strictEqual(results[0].messages[0].message, expectedMsg); @@ -1105,6 +1107,7 @@ describe("ESLint", () => { assert.strictEqual(results.length, 1); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); assert.strictEqual(results[0].fixableErrorCount, 0); assert.strictEqual(results[0].fixableWarningCount, 0); assert.strictEqual(results[0].messages[0].message, expectedMsg); @@ -1127,6 +1130,7 @@ describe("ESLint", () => { assert.strictEqual(results.length, 1); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); assert.strictEqual(results[0].fixableErrorCount, 0); assert.strictEqual(results[0].fixableWarningCount, 0); assert.strictEqual(results[0].messages[0].message, expectedMsg); @@ -1413,6 +1417,7 @@ describe("ESLint", () => { assert.strictEqual(results[0].messages[0].message, "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); assert.strictEqual(results[0].fixableErrorCount, 0); assert.strictEqual(results[0].fixableWarningCount, 0); }); @@ -4822,6 +4827,9 @@ describe("ESLint", () => { assert.strictEqual(results.length, 1); assert.strictEqual(results[0].errorCount, 0); assert.strictEqual(results[0].warningCount, 1); + assert.strictEqual(results[0].fatalErrorCount, 0); + assert.strictEqual(results[0].fixableErrorCount, 0); + assert.strictEqual(results[0].fixableWarningCount, 0); }); it("should return source code of file in the `source` property", async () => {