Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fixed: `throwError` no longer throws when the logged messages are neither
warnings nor errors, as before 7.1.0 (#77).
- Changed: dropped support for Node.js below 18.
- Fixed: the summary now uses the singular form for a single error or warning
(`1 error`, not `1 errors`).
Expand Down
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = function (opts = {}) {
}

function shouldThrowError() {
return opts.throwError || errorCount > 0;
return errorCount > 0 || (opts.throwError && warningCount > 0);
}
},
};
Expand Down
11 changes: 11 additions & 0 deletions lib/reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ test("reporter with throwError", () => {
run({ throwError: true }, clone(simpleResult), { expectError: true });
});

test("reporter with throwError does not throw on messages that are neither warnings nor errors", () => {
const { calls } = run(
{ throwError: true, filter: () => true },
{
messages: [{ type: "dependency", plugin: "foo", text: "foo dependency" }],
root: {},
},
);
assert.equal(calls.length, 1);
});

test("reporter with a file as source", () => {
const { calls } = run(
{},
Expand Down
Loading