Skip to content

Commit e3c0d48

Browse files
committed
add category
1 parent 01d044e commit e3c0d48

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

code-pushup.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import 'dotenv/config';
2-
import {z} from 'zod';
2+
import { z } from 'zod';
33
import {
44
coverageCoreConfigNx,
55
eslintCoreConfigNx,
66
jsPackagesCoreConfig,
77
lighthouseCoreConfig,
88
typescriptPluginConfigNx,
99
} from './code-pushup.preset.js';
10-
import type {CoreConfig} from './packages/models/src/index.js';
11-
import {BASIC_CHECKES} from './packages/plugin-typescript/src/lib/constants';
12-
import {mergeConfigs} from './packages/utils/src/index.js';
10+
import type { CoreConfig } from './packages/models/src/index.js';
11+
import { BASIC_CHECKES } from './packages/plugin-typescript/src/lib/constants';
12+
import { mergeConfigs } from './packages/utils/src/index.js';
1313

1414
// load upload configuration from environment
1515
const envSchema = z.object({
@@ -18,7 +18,7 @@ const envSchema = z.object({
1818
CP_ORGANIZATION: z.string().min(1),
1919
CP_PROJECT: z.string().min(1),
2020
});
21-
const {data: env} = await envSchema.safeParseAsync(process.env);
21+
const { data: env } = await envSchema.safeParseAsync(process.env);
2222

2323
const config: CoreConfig = {
2424
...(env && {

code-pushup.preset.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type {
2-
Audit,
32
CategoryConfig,
4-
CategoryRef,
53
CoreConfig,
64
} from './packages/models/src/index.js';
75
import coveragePlugin, {
@@ -16,7 +14,7 @@ import lighthousePlugin, {
1614
lighthouseGroupRef,
1715
} from './packages/plugin-lighthouse/src/index.js';
1816
import { typescriptPlugin } from './packages/plugin-typescript/src';
19-
import { AUDITS as tsAudits } from './packages/plugin-typescript/src/lib/generated/audits';
17+
import { AUDITS } from './packages/plugin-typescript/src/lib/generated/audits';
2018
import { TypescriptPluginOptions } from './packages/plugin-typescript/src/lib/typescript-plugin';
2119

2220
export const jsPackagesCategories: CategoryConfig[] = [
@@ -139,21 +137,18 @@ export const typescriptPluginConfigNx = async (
139137
): Promise<CoreConfig> => {
140138
return {
141139
plugins: [await typescriptPlugin(options)],
142-
/*...(supportedAuditSlugs.length > 0 ? {
143-
categories: [
144-
{
145-
slug: 'typescript',
146-
title: 'Typescript',
147-
refs: supportedAuditSlugs
148-
.map(({slug}) => ({
149-
plugin: 'typescript',
150-
type: 'audit' as const,
151-
slug,
152-
weight: 1
153-
}))
154-
}
155-
]
156-
} : {})*/
140+
categories: [
141+
{
142+
slug: 'typescript',
143+
title: 'Typescript',
144+
refs: AUDITS.map(({ slug }) => ({
145+
plugin: 'typescript',
146+
type: 'audit' as const,
147+
slug,
148+
weight: 1,
149+
})),
150+
},
151+
],
157152
};
158153
};
159154

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
RunnerFunction,
88
} from '@code-pushup/models';
99
import type { TypescriptPluginOptions } from '../config.js';
10+
import { AUDITS } from '../generated/audits.js';
1011
import type { AuditSlug } from '../types.js';
1112
import { getDiagnostics } from './typescript-runner.js';
1213
import {
@@ -53,10 +54,11 @@ export function createRunnerFunction(
5354
>,
5455
);
5556

56-
return Object.values(result).map(({ slug, details }) => {
57+
return AUDITS.map(audit => {
58+
const { details } = result[audit.slug as AuditSlug] ?? {};
5759
const issues = details?.issues ?? [];
5860
return {
59-
slug,
61+
...audit,
6062
score: issues.length === 0 ? 1 : 0,
6163
value: issues.length,
6264
...(issues.length > 0 ? { details } : {}),

0 commit comments

Comments
 (0)