diff --git a/e2e/plugin-typescript-e2e/tests/__snapshots__/collect.e2e.test.ts.snap b/e2e/plugin-typescript-e2e/tests/__snapshots__/collect.e2e.test.ts.snap index a1bb0cb3e..09799e984 100644 --- a/e2e/plugin-typescript-e2e/tests/__snapshots__/collect.e2e.test.ts.snap +++ b/e2e/plugin-typescript-e2e/tests/__snapshots__/collect.e2e.test.ts.snap @@ -48,7 +48,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, ], }, - "displayValue": "1 issue", + "displayValue": "1 error", "score": 0, "slug": "syntax-errors", "title": "Syntax errors", @@ -80,7 +80,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, ], }, - "displayValue": "2 issues", + "displayValue": "2 errors", "score": 0, "slug": "semantic-errors", "title": "Semantic errors", @@ -102,7 +102,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, ], }, - "displayValue": "1 issue", + "displayValue": "1 error", "score": 0, "slug": "declaration-and-language-service-errors", "title": "Declaration and language service errors", @@ -110,7 +110,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, { "description": "Errors that occur during TypeScript internal operations", - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "internal-errors", "title": "Internal errors", @@ -132,7 +132,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, ], }, - "displayValue": "1 issue", + "displayValue": "1 error", "score": 0, "slug": "configuration-errors", "title": "Configuration errors", @@ -140,7 +140,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, { "description": "Errors related to no implicit any compiler option", - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "no-implicit-any-errors", "title": "No implicit any errors", @@ -148,14 +148,14 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p }, { "description": "Errors that do not match any known TypeScript error code", - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "unknown-codes", "title": "Unknown codes", "value": 0, }, ], - "description": "Official Code PushUp Typescript plugin.", + "description": "Official Code PushUp TypeScript plugin.", "docsUrl": "https://www.npmjs.com/package/@code-pushup/typescript-plugin/", "groups": [ { @@ -211,7 +211,7 @@ exports[`PLUGIN collect report with typescript-plugin NPM package > should run p "icon": "typescript", "packageName": "@code-pushup/typescript-plugin", "slug": "typescript", - "title": "Typescript", + "title": "TypeScript", }, ], } diff --git a/e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts b/e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts index b5db4dca1..648d56a07 100644 --- a/e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts +++ b/e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts @@ -7,7 +7,6 @@ import { E2E_ENVIRONMENTS_DIR, TEST_OUTPUT_DIR, omitVariableReportData, - removeColorCodes, teardownTestFolder, } from '@code-pushup/test-utils'; import { executeProcess, readJsonFile } from '@code-pushup/utils'; @@ -39,7 +38,7 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => { '.code-pushup', ); - const { code, stdout } = await executeProcess({ + const { code } = await executeProcess({ command: 'npx', // verbose exposes audits with perfect scores that are hidden in the default stdout args: [ @@ -53,16 +52,6 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => { }); expect(code).toBe(0); - const cleanStdout = removeColorCodes(stdout); - - expect(cleanStdout).toMatch(/● Semantic errors\s+\d+ issue/); - expect(cleanStdout).toMatch(/● Configuration errors\s+\d+ issue/); - expect(cleanStdout).toMatch( - /● Declaration and language service errors\s+\d+ issue/, - ); - expect(cleanStdout).toMatch(/● Syntax errors\s+\d+ issue/); - expect(cleanStdout).toMatch(/● Internal errors\s+\d+ issue/); - expect(cleanStdout).toMatch(/● No implicit any errors\s+\d+ issue/); const reportJson = await readJsonFile( path.join(envRoot, outputDir, 'report.json'), diff --git a/packages/plugin-typescript/README.md b/packages/plugin-typescript/README.md index 9ae5b9697..7f2d5da6b 100644 --- a/packages/plugin-typescript/README.md +++ b/packages/plugin-typescript/README.md @@ -151,7 +151,7 @@ categories: [ title: 'TypeScript', refs: [ { - slug: 'language-and-environment', + slug: 'problems', weight: 1, type: 'group', plugin: 'typescript', diff --git a/packages/plugin-typescript/src/lib/runner/__snapshots__/runner-function-all-audits.json b/packages/plugin-typescript/src/lib/runner/__snapshots__/runner.integration.test.ts.snap similarity index 90% rename from packages/plugin-typescript/src/lib/runner/__snapshots__/runner-function-all-audits.json rename to packages/plugin-typescript/src/lib/runner/__snapshots__/runner.integration.test.ts.snap index 919122510..57bd171ab 100644 --- a/packages/plugin-typescript/src/lib/runner/__snapshots__/runner-function-all-audits.json +++ b/packages/plugin-typescript/src/lib/runner/__snapshots__/runner.integration.test.ts.snap @@ -1,3 +1,6 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`createRunnerFunction > should create valid audit outputs when called 1`] = ` [ { "details": { @@ -14,7 +17,7 @@ }, ], }, - "displayValue": "1 issue", + "displayValue": "1 error", "score": 0, "slug": "syntax-errors", "value": 1, @@ -75,7 +78,7 @@ }, ], }, - "displayValue": "5 issues", + "displayValue": "5 errors", "score": 0, "slug": "semantic-errors", "value": 5, @@ -95,33 +98,34 @@ }, ], }, - "displayValue": "1 issue", + "displayValue": "1 error", "score": 0, "slug": "declaration-and-language-service-errors", "value": 1, }, { - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "internal-errors", "value": 0, }, { - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "configuration-errors", "value": 0, }, { - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "no-implicit-any-errors", "value": 0, }, { - "displayValue": "0 issues", + "displayValue": "passed", "score": 1, "slug": "unknown-codes", "value": 0, }, -] \ No newline at end of file +] +`; diff --git a/packages/plugin-typescript/src/lib/runner/runner.integration.test.ts b/packages/plugin-typescript/src/lib/runner/runner.integration.test.ts index ea2ae2da4..d68fc82bb 100644 --- a/packages/plugin-typescript/src/lib/runner/runner.integration.test.ts +++ b/packages/plugin-typescript/src/lib/runner/runner.integration.test.ts @@ -10,8 +10,6 @@ describe('createRunnerFunction', () => { 'packages/plugin-typescript/mocks/fixtures/basic-setup/tsconfig.all-audits.json', expectedAudits: getAudits(), })(() => void 0), - ).resolves.toMatchFileSnapshot( - '__snapshots__/runner-function-all-audits.json', - ); + ).resolves.toMatchSnapshot(); }, 35_000); }); diff --git a/packages/plugin-typescript/src/lib/runner/runner.ts b/packages/plugin-typescript/src/lib/runner/runner.ts index 30c560895..0b77b4d98 100644 --- a/packages/plugin-typescript/src/lib/runner/runner.ts +++ b/packages/plugin-typescript/src/lib/runner/runner.ts @@ -4,7 +4,7 @@ import type { Issue, RunnerFunction, } from '@code-pushup/models'; -import { pluralize } from '@code-pushup/utils'; +import { pluralizeToken } from '@code-pushup/utils'; import type { AuditSlug } from '../types.js'; import { type DiagnosticsOptions, @@ -37,7 +37,7 @@ export function createRunnerFunction(options: RunnerOptions): RunnerFunction { }; }, {}); - return expectedAudits.map(({ slug }) => { + return expectedAudits.map(({ slug }): AuditOutput => { const { details } = result[slug] ?? {}; const issues = details?.issues ?? []; @@ -45,9 +45,12 @@ export function createRunnerFunction(options: RunnerOptions): RunnerFunction { slug, score: issues.length === 0 ? 1 : 0, value: issues.length, - displayValue: `${issues.length} ${pluralize('issue', issues.length)}`, + displayValue: + issues.length === 0 + ? 'passed' + : pluralizeToken('error', issues.length), ...(issues.length > 0 ? { details } : {}), - } satisfies AuditOutput; + }; }); }; } diff --git a/packages/plugin-typescript/src/lib/runner/runner.unit.test.ts b/packages/plugin-typescript/src/lib/runner/runner.unit.test.ts index 063ac9583..58776c291 100644 --- a/packages/plugin-typescript/src/lib/runner/runner.unit.test.ts +++ b/packages/plugin-typescript/src/lib/runner/runner.unit.test.ts @@ -110,7 +110,7 @@ describe('createRunnerFunction', () => { slug: 'semantic-errors', score: 0, value: 2, - displayValue: '2 issues', + displayValue: '2 errors', details: { issues: [ expect.objectContaining({ diff --git a/packages/plugin-typescript/src/lib/typescript-plugin.ts b/packages/plugin-typescript/src/lib/typescript-plugin.ts index 345f7855d..588ce4d60 100644 --- a/packages/plugin-typescript/src/lib/typescript-plugin.ts +++ b/packages/plugin-typescript/src/lib/typescript-plugin.ts @@ -30,8 +30,8 @@ export async function typescriptPlugin( slug: TYPESCRIPT_PLUGIN_SLUG, packageName: packageJson.name, version: packageJson.version, - title: 'Typescript', - description: 'Official Code PushUp Typescript plugin.', + title: 'TypeScript', + description: 'Official Code PushUp TypeScript plugin.', docsUrl: 'https://www.npmjs.com/package/@code-pushup/typescript-plugin/', icon: 'typescript', audits: filteredAudits,