Skip to content

Commit

Permalink
Make SuppressedMessages in ESLintLog optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
akhushnood committed Mar 19, 2024
1 parent 205bdd2 commit 6e88f08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion sample/eslint/eslint-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"nodeType": "Identifier",
"messageId": "unusedVar",
"endLine": 30,
"endColumn": 30
"endColumn": 30,
"suppressions": [{ "kind": "directive", "justification": "" }]
}
],
"errorCount": 1,
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/@types/ESLintLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SuppressedESLintIssue } from './SuppressedESLintIssue';
export type ESLintLog = {
filePath: string;
messages: ESLintIssue[];
suppressedMessages: SuppressedESLintIssue[];
suppressedMessages?: SuppressedESLintIssue[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
Expand Down
13 changes: 7 additions & 6 deletions src/Parser/ESLintParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProjectType } from '../Config/@enums';
import { ProjectType } from '../Config';
import { Log } from '../Logger';
import { getRelativePath } from './utils/path.util';
import { LintSeverity } from './@enums/LintSeverity';
Expand All @@ -15,12 +15,13 @@ export class ESLintParser extends Parser {
.filter((log) => log.messages.length !== 0)
.concat(
logs
.filter((log) => log.suppressedMessages.length !== 0)
.filter((log) => log.suppressedMessages?.length !== 0)
.map((log) => {
const messages = log.suppressedMessages.map((msg) => ({
...msg,
severity: 0,
}));
const messages =
log.suppressedMessages?.map((msg) => ({
...msg,
severity: 0,
})) ?? [];
return { ...log, messages: messages };
}),
)
Expand Down

0 comments on commit 6e88f08

Please sign in to comment.