Skip to content

Commit 28213f0

Browse files
author
John Doe
committed
chore: refine preset
1 parent 3166645 commit 28213f0

File tree

2 files changed

+12
-47
lines changed

2 files changed

+12
-47
lines changed

code-pushup.preset.ts

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,12 @@ export const eslintCategories: CategoryConfig[] = [
100100
export function getJsDocsCategories(
101101
config: JsDocsPluginConfig,
102102
): CategoryConfig[] {
103-
const filterOptions =
104-
typeof config === 'string' || Array.isArray(config)
105-
? {}
106-
: { onlyAudits: config.onlyAudits, skipAudits: config.skipAudits };
107103
return [
108104
{
109105
slug: 'docs',
110106
title: 'Documentation',
111107
description: 'Measures how much of your code is **documented**.',
112-
refs: filterGroupsByOnlyAudits(groups, filterOptions).map(group => ({
108+
refs: filterGroupsByOnlyAudits(groups, config).map(group => ({
113109
weight: 1,
114110
type: 'group',
115111
plugin: PLUGIN_SLUG,
@@ -163,13 +159,12 @@ export const jsDocsCoreConfig = (
163159

164160
export const eslintCoreConfigNx = async (
165161
projectName?: string,
166-
options?: { exclude?: string[] },
167162
): Promise<CoreConfig> => ({
168163
plugins: [
169164
await eslintPlugin(
170165
await (projectName
171166
? eslintConfigFromNxProject(projectName)
172-
: eslintConfigFromAllNxProjects(options)),
167+
: eslintConfigFromAllNxProjects()),
173168
),
174169
],
175170
categories: eslintCategories,
@@ -183,42 +178,18 @@ export const typescriptPluginConfig = async (
183178
});
184179

185180
export const coverageCoreConfigNx = async (
186-
projectOrConfig?:
187-
| string
188-
| {
189-
projectName: string;
190-
targetNames: string[];
191-
},
192-
options?: { exclude?: string[] },
181+
projectName?: string,
193182
): Promise<CoreConfig> => {
194-
const projectName =
195-
typeof projectOrConfig === 'string'
196-
? projectOrConfig
197-
: projectOrConfig?.projectName;
198-
const targetNames =
199-
typeof projectOrConfig === 'object' && projectOrConfig?.targetNames?.length
200-
? projectOrConfig.targetNames
201-
: ['unit-test', 'int-test'];
202-
203183
if (projectName) {
204184
throw new Error('coverageCoreConfigNx for single projects not implemented');
205185
}
206-
207-
const targetArgs = ['-t', ...targetNames];
208-
209-
// Compute projects list and apply exclude for efficient run-many execution
210-
const { createProjectGraphAsync } = await import('@nx/devkit');
211-
const { nodes } = await createProjectGraphAsync({ exitOnError: false });
212-
const projectsWithTargets = Object.values(nodes).filter(node =>
213-
targetNames.some(t => node.data.targets && t in node.data.targets),
214-
);
215-
const filteredProjects = options?.exclude?.length
216-
? projectsWithTargets.filter(node => !options.exclude!.includes(node.name))
217-
: projectsWithTargets;
218-
const projectsArg = `--projects=${filteredProjects
219-
.map(p => p.name)
220-
.join(',')}`;
221-
186+
const targetNames = ['unit-test', 'int-test'];
187+
const targetArgs = [
188+
'-t',
189+
...targetNames,
190+
'--coverage.enabled',
191+
'--skipNxCache',
192+
];
222193
return {
223194
plugins: [
224195
await coveragePlugin({
@@ -228,10 +199,9 @@ export const coverageCoreConfigNx = async (
228199
'nx',
229200
projectName ? `run --project ${projectName}` : 'run-many',
230201
...targetArgs,
231-
projectsArg,
232202
],
233203
},
234-
reports: await getNxCoveragePaths(targetNames, false, options?.exclude),
204+
reports: await getNxCoveragePaths(targetNames),
235205
}),
236206
],
237207
categories: coverageCategories,

packages/plugin-coverage/src/lib/nx/coverage-paths.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type { CoverageResult } from '../config.js';
1818
export async function getNxCoveragePaths(
1919
targets: string[] = ['test'],
2020
verbose?: boolean,
21-
exclude?: string[],
2221
): Promise<CoverageResult[]> {
2322
if (verbose) {
2423
ui().logger.info(
@@ -35,12 +34,8 @@ export async function getNxCoveragePaths(
3534
hasNxTarget(graph, target),
3635
);
3736

38-
const filteredNodes = exclude?.length
39-
? relevantNodes.filter(node => !exclude.includes(node.name))
40-
: relevantNodes;
41-
4237
return await Promise.all(
43-
filteredNodes.map<Promise<CoverageResult>>(async ({ name, data }) => {
38+
relevantNodes.map<Promise<CoverageResult>>(async ({ name, data }) => {
4439
const coveragePaths = await getCoveragePathsForTarget(data, target);
4540
if (verbose) {
4641
ui().logger.info(`- ${name}: ${target}`);

0 commit comments

Comments
 (0)