Skip to content

Commit

Permalink
fix(plugin-js-packages): always include issues array, even if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed May 23, 2024
1 parent bd7c563 commit 748eb64
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function auditResultToAuditOutput(
score: calculateAuditScore(result.summary),
value: result.summary.total,
displayValue: summaryToDisplayValue(result.summary),
...(issues.length > 0 && { details: { issues } }),
details: { issues },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('auditResultToAuditOutput', () => {
score: 1,
value: 0,
displayValue: '0 vulnerabilities',
details: { issues: [] },
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReleaseType, clean, diff, neq } from 'semver';
import type { Issue } from '@code-pushup/models';
import type { AuditOutput, Issue } from '@code-pushup/models';
import { objectFromEntries, pluralize } from '@code-pushup/utils';
import { DependencyGroup, PackageManagerId } from '../../config';
import { dependencyGroupToLong } from '../../constants';
Expand All @@ -10,7 +10,7 @@ export function outdatedResultToAuditOutput(
result: OutdatedResult,
packageManager: PackageManagerId,
depGroup: DependencyGroup,
) {
): AuditOutput {
const relevantDependencies: OutdatedResult = result.filter(
dep => dep.type === dependencyGroupToLong[depGroup],
);
Expand Down Expand Up @@ -51,7 +51,7 @@ export function outdatedResultToAuditOutput(
),
value: outdatedDependencies.length,
displayValue: outdatedToDisplayValue(outdatedStats),
...(issues.length > 0 && { details: { issues } }),
details: { issues },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('outdatedResultToAuditOutput', () => {
score: 1,
value: 0,
displayValue: 'all dependencies are up to date',
details: { issues: [] },
});
});

Expand All @@ -188,6 +189,7 @@ describe('outdatedResultToAuditOutput', () => {
score: 1,
value: 0,
displayValue: 'all dependencies are up to date',
details: { issues: [] },
});
});

Expand Down

0 comments on commit 748eb64

Please sign in to comment.