Skip to content

Commit

Permalink
Stop skipping linting when --report-needless-disables is used. Fix st…
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Jul 16, 2019
1 parent 1e6cde6 commit 295c361
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,17 @@ 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
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
Expand Down Expand Up @@ -552,8 +552,6 @@ module.exports = (argv /*: string[]*/) /*: Promise<void>|void*/ => {
if (report) {
process.exitCode = EXIT_CODE_ERROR;
}

return;
}

if (!linted.output) {
Expand Down
22 changes: 22 additions & 0 deletions system-tests/cli/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
});
});
});
3 changes: 3 additions & 0 deletions system-tests/cli/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* stylelint-disable-next-line color-named */
body {
}

0 comments on commit 295c361

Please sign in to comment.