Skip to content

Commit 3c13f34

Browse files
committed
fix(plugin-typescript): use same displayValue formatting as eslint
1 parent 7de2a1e commit 3c13f34

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

e2e/plugin-typescript-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p
4848
},
4949
],
5050
},
51-
"displayValue": "1 issue",
51+
"displayValue": "1 error",
5252
"score": 0,
5353
"slug": "syntax-errors",
5454
"title": "Syntax errors",
@@ -80,7 +80,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p
8080
},
8181
],
8282
},
83-
"displayValue": "2 issues",
83+
"displayValue": "2 errors",
8484
"score": 0,
8585
"slug": "semantic-errors",
8686
"title": "Semantic errors",
@@ -102,15 +102,15 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p
102102
},
103103
],
104104
},
105-
"displayValue": "1 issue",
105+
"displayValue": "1 error",
106106
"score": 0,
107107
"slug": "declaration-and-language-service-errors",
108108
"title": "Declaration and language service errors",
109109
"value": 1,
110110
},
111111
{
112112
"description": "Errors that occur during TypeScript internal operations",
113-
"displayValue": "0 issues",
113+
"displayValue": "passed",
114114
"score": 1,
115115
"slug": "internal-errors",
116116
"title": "Internal errors",
@@ -132,23 +132,23 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p
132132
},
133133
],
134134
},
135-
"displayValue": "1 issue",
135+
"displayValue": "1 error",
136136
"score": 0,
137137
"slug": "configuration-errors",
138138
"title": "Configuration errors",
139139
"value": 1,
140140
},
141141
{
142142
"description": "Errors related to no implicit any compiler option",
143-
"displayValue": "0 issues",
143+
"displayValue": "passed",
144144
"score": 1,
145145
"slug": "no-implicit-any-errors",
146146
"title": "No implicit any errors",
147147
"value": 0,
148148
},
149149
{
150150
"description": "Errors that do not match any known TypeScript error code",
151-
"displayValue": "0 issues",
151+
"displayValue": "passed",
152152
"score": 1,
153153
"slug": "unknown-codes",
154154
"title": "Unknown codes",

e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
E2E_ENVIRONMENTS_DIR,
88
TEST_OUTPUT_DIR,
99
omitVariableReportData,
10-
removeColorCodes,
1110
teardownTestFolder,
1211
} from '@code-pushup/test-utils';
1312
import { executeProcess, readJsonFile } from '@code-pushup/utils';
@@ -39,7 +38,7 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => {
3938
'.code-pushup',
4039
);
4140

42-
const { code, stdout } = await executeProcess({
41+
const { code } = await executeProcess({
4342
command: 'npx',
4443
// verbose exposes audits with perfect scores that are hidden in the default stdout
4544
args: [
@@ -53,16 +52,6 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => {
5352
});
5453

5554
expect(code).toBe(0);
56-
const cleanStdout = removeColorCodes(stdout);
57-
58-
expect(cleanStdout).toMatch(/ Semantic errors\s+\d+ issue/);
59-
expect(cleanStdout).toMatch(/ Configuration errors\s+\d+ issue/);
60-
expect(cleanStdout).toMatch(
61-
/ Declaration and language service errors\s+\d+ issue/,
62-
);
63-
expect(cleanStdout).toMatch(/ Syntax errors\s+\d+ issue/);
64-
expect(cleanStdout).toMatch(/ Internal errors\s+\d+ issue/);
65-
expect(cleanStdout).toMatch(/ No implicit any errors\s+\d+ issue/);
6655

6756
const reportJson = await readJsonFile<Report>(
6857
path.join(envRoot, outputDir, 'report.json'),

packages/plugin-typescript/src/lib/runner/runner.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
Issue,
55
RunnerFunction,
66
} from '@code-pushup/models';
7-
import { pluralize } from '@code-pushup/utils';
7+
import { pluralizeToken } from '@code-pushup/utils';
88
import type { AuditSlug } from '../types.js';
99
import {
1010
type DiagnosticsOptions,
@@ -37,17 +37,20 @@ export function createRunnerFunction(options: RunnerOptions): RunnerFunction {
3737
};
3838
}, {});
3939

40-
return expectedAudits.map(({ slug }) => {
40+
return expectedAudits.map(({ slug }): AuditOutput => {
4141
const { details } = result[slug] ?? {};
4242

4343
const issues = details?.issues ?? [];
4444
return {
4545
slug,
4646
score: issues.length === 0 ? 1 : 0,
4747
value: issues.length,
48-
displayValue: `${issues.length} ${pluralize('issue', issues.length)}`,
48+
displayValue:
49+
issues.length === 0
50+
? 'passed'
51+
: pluralizeToken('error', issues.length),
4952
...(issues.length > 0 ? { details } : {}),
50-
} satisfies AuditOutput;
53+
};
5154
});
5255
};
5356
}

0 commit comments

Comments
 (0)