Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop skipping linting when --report-needless-disables CLI flag is used. Fix #4076 #4151

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/cli.js
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
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
@@ -0,0 +1,3 @@
/* stylelint-disable-next-line color-named */
body {
}