@code-pushup/utils
Advanced tools
Comparing version 0.3.2 to 0.4.0
26
index.js
@@ -908,2 +908,26 @@ // packages/utils/src/lib/execute-process.ts | ||
} | ||
function compareIssues(a, b) { | ||
if (a.severity !== b.severity) { | ||
return -compareIssueSeverity(a.severity, b.severity); | ||
} | ||
if (!a.source && b.source) { | ||
return -1; | ||
} | ||
if (a.source && !b.source) { | ||
return 1; | ||
} | ||
if (a.source?.file !== b.source?.file) { | ||
return a.source?.file.localeCompare(b.source?.file || "") || 0; | ||
} | ||
if (!a.source?.position && b.source?.position) { | ||
return -1; | ||
} | ||
if (a.source?.position && !b.source?.position) { | ||
return 1; | ||
} | ||
if (a.source?.position?.startLine !== b.source?.position?.startLine) { | ||
return (a.source?.position?.startLine || 0) - (b.source?.position?.startLine || 0); | ||
} | ||
return 0; | ||
} | ||
@@ -1240,3 +1264,3 @@ // packages/utils/src/lib/execute-process.ts | ||
detailsTableHeaders, | ||
...audit.details.issues.map((issue) => { | ||
...audit.details.issues.sort(compareIssues).map((issue) => { | ||
const severity = `${getSeverityIcon(issue.severity)} <i>${issue.severity}</i>`; | ||
@@ -1243,0 +1267,0 @@ const message = issue.message; |
{ | ||
"name": "@code-pushup/utils", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "@code-pushup/models": "*", |
@@ -1,2 +0,2 @@ | ||
import { CategoryRef, IssueSeverity as CliIssueSeverity, Format, PersistConfig, Report } from '@code-pushup/models'; | ||
import { CategoryRef, IssueSeverity as CliIssueSeverity, Format, Issue, PersistConfig, Report } from '@code-pushup/models'; | ||
import { EnrichedAuditReport, EnrichedScoredAuditGroupWithAudits, ScoredReport, WeighedAuditReport } from './scoring'; | ||
@@ -30,2 +30,3 @@ export declare const FOOTER_PREFIX = "Made with \u2764 by"; | ||
export declare function getPluginNameFromSlug(slug: string, plugins: ScoredReport['plugins']): string; | ||
export declare function compareIssues(a: Issue, b: Issue): number; | ||
export {}; |
71814
1906