Skip to content

Commit 59438e0

Browse files
committed
refactor: rename targetScoreIcon to scoreTargetIcon
1 parent ae6a5c2 commit 59438e0

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

packages/utils/src/lib/reports/__snapshots__/generate-md-report-category-section.unit.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports[`categoriesOverviewSection > should render filtered categories table 1`]
7272
"
7373
`;
7474

75-
exports[`categoriesOverviewSection > should render targetScore icon "❌" if score fails 1`] = `
75+
exports[`categoriesOverviewSection > should render scoreTarget icon "❌" if score fails 1`] = `
7676
"| 🏷 Category | ⭐ Score | 🛡 Audits |
7777
| :-------------------------------- | :---------: | :-------: |
7878
| [Bug Prevention](#bug-prevention) | 🟢 **98** ❌ | 1 |

packages/utils/src/lib/reports/generate-md-report-category-section.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
getPluginNameFromSlug,
1212
scoreFilter,
1313
scoreMarker,
14-
targetScoreIcon,
14+
scoreTargetIcon,
1515
} from './utils.js';
1616

1717
export function categoriesOverviewSection(
@@ -28,7 +28,7 @@ export function categoriesOverviewSection(
2828
categories
2929
.filter(scoreFilter(options))
3030
.map(({ title, refs, score, isBinary }) => [
31-
// @TODO refactor `isBinary: boolean` to `targetScore: number` #713
31+
// @TODO refactor `isBinary: boolean` to `scoreTarget: number` #713
3232
// The heading "ID" is inferred from the heading text in Markdown.
3333
md.link(`#${slugify(title)}`, title),
3434
md`${scoreMarker(score)} ${md.bold(
@@ -130,6 +130,6 @@ export function binaryIconSuffix(
130130
score: number,
131131
isBinary: boolean | undefined,
132132
): string {
133-
// @TODO refactor `isBinary: boolean` to `targetScore: number` #713
134-
return targetScoreIcon(score, isBinary ? 1 : undefined, { prefix: ' ' });
133+
// @TODO refactor `isBinary: boolean` to `scoreTarget: number` #713
134+
return scoreTargetIcon(score, isBinary ? 1 : undefined, { prefix: ' ' });
135135
}

packages/utils/src/lib/reports/generate-md-report-category-section.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('categoriesOverviewSection', () => {
9191
).toMatchSnapshot();
9292
});
9393

94-
it('should render targetScore icon "❌" if score fails', () => {
94+
it('should render scoreTarget icon "❌" if score fails', () => {
9595
expect(
9696
categoriesOverviewSection({
9797
plugins: [

packages/utils/src/lib/reports/log-stdout-summary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { ScoredReport } from './types.js';
1313
import {
1414
applyScoreColor,
1515
countCategoryAudits,
16-
targetScoreIcon,
16+
scoreTargetIcon,
1717
} from './utils.js';
1818

1919
function log(msg = ''): void {
@@ -130,12 +130,12 @@ export function logCategories({
130130
log();
131131
}
132132

133-
// @TODO refactor `isBinary: boolean` to `targetScore: number` #713
133+
// @TODO refactor `isBinary: boolean` to `scoreTarget: number` #713
134134
export function binaryIconPrefix(
135135
score: number,
136136
isBinary: boolean | undefined,
137137
): string {
138-
return targetScoreIcon(score, isBinary ? 1 : undefined, {
138+
return scoreTargetIcon(score, isBinary ? 1 : undefined, {
139139
passIcon: bold(green('✓')),
140140
failIcon: bold(red('✗')),
141141
postfix: ' ',

packages/utils/src/lib/reports/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,24 +297,24 @@ export function applyScoreColor(
297297
: style.bold(style.red(formattedScore));
298298
}
299299

300-
export function targetScoreIcon(
300+
export function scoreTargetIcon(
301301
score: number,
302-
targetScore?: number,
302+
scoreTarget?: number,
303303
options: {
304304
passIcon?: string;
305305
failIcon?: string;
306306
prefix?: string;
307307
postfix?: string;
308308
} = {},
309309
): string {
310-
if (targetScore != null) {
310+
if (scoreTarget != null) {
311311
const {
312312
passIcon = '✅',
313313
failIcon = '❌',
314314
prefix = '',
315315
postfix = '',
316316
} = options;
317-
if (score >= targetScore) {
317+
if (score >= scoreTarget) {
318318
return `${prefix}${passIcon}${postfix}`;
319319
}
320320
return `${prefix}${failIcon}${postfix}`;

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import {
2828
roundValue,
2929
scoreFilter,
3030
scoreMarker,
31+
scoreTargetIcon,
3132
severityMarker,
32-
targetScoreIcon,
3333
} from './utils.js';
3434

3535
describe('scoreFilter', () => {
@@ -497,42 +497,42 @@ describe('applyScoreColor', () => {
497497
});
498498
});
499499

500-
describe('targetScoreIcon', () => {
501-
it('should return target score icon "✅" for passed score', () => {
502-
expect(targetScoreIcon(0.42, 0.4)).toBe('✅');
500+
describe('scoreTargetIcon', () => {
501+
it('should return score target icon "✅" for passed score', () => {
502+
expect(scoreTargetIcon(0.42, 0.4)).toBe('✅');
503503
});
504504

505-
it('should return target score icon "❌" for failed score', () => {
506-
expect(targetScoreIcon(0.42, 0.5)).toBe('❌');
505+
it('should return score target icon "❌" for failed score', () => {
506+
expect(scoreTargetIcon(0.42, 0.5)).toBe('❌');
507507
});
508508

509-
it('should return prefixed target score icon if prefix is provided', () => {
509+
it('should return prefixed score target icon if prefix is provided', () => {
510510
expect(
511-
targetScoreIcon(0.42, 0.1, {
511+
scoreTargetIcon(0.42, 0.1, {
512512
prefix: '<',
513513
}),
514514
).toBe('<✅');
515515
});
516516

517-
it('should return prefixed target score icon if postfix is provided', () => {
517+
it('should return prefixed score target icon if postfix is provided', () => {
518518
expect(
519-
targetScoreIcon(0.42, 0.1, {
519+
scoreTargetIcon(0.42, 0.1, {
520520
postfix: '>',
521521
}),
522522
).toBe('✅>');
523523
});
524524

525-
it('should return pre and postfixed target score icon if both are provided', () => {
525+
it('should return pre and postfixed score target icon if both are provided', () => {
526526
expect(
527-
targetScoreIcon(0.42, 0.1, {
527+
scoreTargetIcon(0.42, 0.1, {
528528
prefix: '<',
529529
postfix: '>',
530530
}),
531531
).toBe('<✅>');
532532
});
533533

534-
it('should return no target score icon if no targetScore is provided', () => {
535-
expect(targetScoreIcon(0.42)).toBe('');
534+
it('should return no score target icon if no scoreTarget is provided', () => {
535+
expect(scoreTargetIcon(0.42)).toBe('');
536536
});
537537
});
538538

0 commit comments

Comments
 (0)