From 295c36176866e9827f47d2ecc80f128ca333e0e6 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Tue, 16 Jul 2019 01:20:01 +0100 Subject: [PATCH] Stop skipping linting when --report-needless-disables is used. Fix #4076 --- lib/cli.js | 8 +++----- system-tests/cli/cli.test.js | 22 ++++++++++++++++++++++ system-tests/cli/stylesheet.css | 3 +++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 4b859b5d3b..c88e80f928 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -274,7 +274,7 @@ const meowOptions /*: meowOptionsType*/ = { --report-needless-disables, --rd - Report stylelint-disable comments that are not blocking a lint warning. + Also report errors for stylelint-disable comments that are not blocking a lint warning. The process will exit with code ${EXIT_CODE_ERROR} if needless disables are found. --max-warnings, --mw @@ -282,9 +282,9 @@ const meowOptions /*: meowOptionsType*/ = { Number of warnings above which the process will exit with code ${EXIT_CODE_ERROR}. Useful when setting "defaultSeverity" to "warning" and expecting the process to fail on warnings (e.g. CI build). - + --output-file, -o - + Path of file to write report. --version, -v @@ -552,8 +552,6 @@ module.exports = (argv /*: string[]*/) /*: Promise|void*/ => { if (report) { process.exitCode = EXIT_CODE_ERROR; } - - return; } if (!linted.output) { diff --git a/system-tests/cli/cli.test.js b/system-tests/cli/cli.test.js index fcecc562b5..4afee3b6ed 100644 --- a/system-tests/cli/cli.test.js +++ b/system-tests/cli/cli.test.js @@ -92,4 +92,26 @@ describe("CLI", () => { ); }); }); + + it("--report-needless-disables", () => { + return Promise.resolve( + cli([ + "--report-needless-disables", + "--config", + path.join(__dirname, "config.json"), + path.join(__dirname, "stylesheet.css") + ]) + ).then(() => { + expect(process.exitCode).toBe(2); + expect(process.stdout.write).toHaveBeenCalledTimes(2); + expect(process.stdout.write).toHaveBeenNthCalledWith( + 1, + expect.stringContaining("unused rule: color-named") + ); + expect(process.stdout.write).toHaveBeenNthCalledWith( + 2, + expect.stringContaining("Unexpected empty block") + ); + }); + }); }); diff --git a/system-tests/cli/stylesheet.css b/system-tests/cli/stylesheet.css index e69de29bb2..16f367b3ec 100644 --- a/system-tests/cli/stylesheet.css +++ b/system-tests/cli/stylesheet.css @@ -0,0 +1,3 @@ +/* stylelint-disable-next-line color-named */ +body { +}