Skip to content

Commit

Permalink
feat: add the option to ignore suppressed messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Nov 6, 2023
1 parent a0855be commit fa09dc7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/eslint-formatter-sarif/sarif.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports = function (results, data) {
let nextRuleIndex = 0;
const sarifResults = [];
const embedFileContents = process.env.SARIF_ESLINT_EMBED === 'true';
const ignoreSuppressed = process.env.SARIF_ESLINT_IGNORE_SUPPRESSED === 'true';

// Emit a tool configuration notification with this id if ESLint emits a message with
// no ruleId (which indicates an internal error in ESLint).
Expand Down Expand Up @@ -131,7 +132,7 @@ module.exports = function (results, data) {

const containsSuppressedMessages =
result.suppressedMessages && result.suppressedMessages.length > 0;
const messages = containsSuppressedMessages
const messages = containsSuppressedMessages && !ignoreSuppressed

Check failure on line 135 in packages/eslint-formatter-sarif/sarif.js

View workflow job for this annotation

GitHub Actions / Lint - ubuntu

Insert `⏎·······`

Check failure

Code scanning / ESLint

Insert ⏎······· Error

Insert ⏎·······
? [...result.messages, ...result.suppressedMessages]

Check failure on line 136 in packages/eslint-formatter-sarif/sarif.js

View workflow job for this annotation

GitHub Actions / Lint - ubuntu

Insert `··`
: result.messages;

Check failure on line 137 in packages/eslint-formatter-sarif/sarif.js

View workflow job for this annotation

GitHub Actions / Lint - ubuntu

Insert `··`

Expand Down Expand Up @@ -195,7 +196,7 @@ module.exports = function (results, data) {
sarifRepresentation.ruleIndex = sarifRuleIndices[message.ruleId];
}

if (containsSuppressedMessages) {
if (containsSuppressedMessages && !ignoreSuppressed) {
sarifRepresentation.suppressions = message.suppressions
? message.suppressions.map((suppression) => {
return {
Expand Down

0 comments on commit fa09dc7

Please sign in to comment.