Skip to content

Commit 1264c7d

Browse files
chore(utils): add conditions for absent position for compareIssues
1 parent d7d9d75 commit 1264c7d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/utils/src/lib/report.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ export function compareIssues(a: Issue, b: Issue): number {
297297
return a.source?.file.localeCompare(b.source?.file || '') || 0;
298298
}
299299

300+
if (!a.source?.position && b.source?.position) {
301+
return -1;
302+
}
303+
304+
if (a.source?.position && !b.source?.position) {
305+
return 1;
306+
}
307+
300308
if (a.source?.position?.startLine !== b.source?.position?.startLine) {
301309
return (
302310
(a.source?.position?.startLine || 0) -

packages/utils/src/lib/report.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('sortAuditIssues', () => {
272272
source: { file: 'a', position: { startLine: 2 } },
273273
},
274274
{ severity: 'info', source: { file: 'b', position: { startLine: 1 } } },
275-
{ severity: 'info' },
275+
{ severity: 'info', source: { file: 'b' } },
276276
{ severity: 'error' },
277277
] as Issue[];
278278
const sortedIssues = [...mockIssues].sort(compareIssues);
@@ -282,7 +282,7 @@ describe('sortAuditIssues', () => {
282282
severity: 'warning',
283283
source: { file: 'a', position: { startLine: 2 } },
284284
},
285-
{ severity: 'info' },
285+
{ severity: 'info', source: { file: 'b' } },
286286
{ severity: 'info', source: { file: 'b', position: { startLine: 1 } } },
287287
{ severity: 'info', source: { file: 'b', position: { startLine: 2 } } },
288288
{ severity: 'info', source: { file: 'c', position: { startLine: 1 } } },

0 commit comments

Comments
 (0)