11import type { Audit } from '@code-pushup/models' ;
2- import { slugify } from '@code-pushup/utils' ;
3- import { formatBytes } from '@code-pushup/utils' ;
2+ import { formatBytes , slugify } from '@code-pushup/utils' ;
43import type { BundleStatsConfig as ExportedBundleStatsConfig } from '../index.js' ;
54import type { InsightsTableConfig } from './runner/audits/details/table.js' ;
6- import { type DependencyTreeConfig } from './runner/audits/details/tree.js' ;
5+ import type { DependencyTreeConfig } from './runner/audits/details/tree.js' ;
76import type { PenaltyConfig , ScoringConfig } from './runner/audits/scoring.js' ;
87import { DEFAULT_PENALTY } from './runner/audits/scoring.js' ;
98import type { SelectionConfig } from './runner/audits/selection.js' ;
@@ -55,8 +54,8 @@ function formatStandardizedIssuesSection(scoring: ScoringConfig): string {
5554 if ( penalty . blacklist && penalty . blacklist . length > 0 ) {
5655 items . push (
5756 ` - Error: \`1+\` candidates - Violation detected, requires action` ,
57+ ` - Info: \`0\` candidates - No violations found` ,
5858 ) ;
59- items . push ( ` - Info: \`0\` candidates - No violations found` ) ;
6059 } else if ( penalty . artefactSize ) {
6160 const [ , max ] = penalty . artefactSize ;
6261 items . push (
@@ -110,14 +109,18 @@ function formatStandardizedTreeSection(
110109 let pruningText = 'Default settings' ;
111110 if ( pruning ) {
112111 const pruningParts : string [ ] = [ ] ;
113- if ( pruning . minSize )
112+ if ( pruning . minSize ) {
114113 pruningParts . push ( `Min size: \`${ formatBytes ( pruning . minSize ) } \`` ) ;
115- if ( pruning . maxChildren )
114+ }
115+ if ( pruning . maxChildren ) {
116116 pruningParts . push ( `Max children: \`${ pruning . maxChildren } \`` ) ;
117- if ( pruning . maxDepth )
117+ }
118+ if ( pruning . maxDepth ) {
118119 pruningParts . push ( `Max depth: \`${ pruning . maxDepth } \`` ) ;
119- if ( pruning . pathLength )
120+ }
121+ if ( pruning . pathLength ) {
120122 pruningParts . push ( `Path length: \`${ pruning . pathLength } \`` ) ;
123+ }
121124
122125 if ( pruningParts . length > 0 ) {
123126 pruningText = pruningParts . join ( ', ' ) ;
@@ -129,8 +132,12 @@ function formatStandardizedTreeSection(
129132 if ( groups && groups . length > 0 ) {
130133 const groupSummaries = groups . map ( group => {
131134 const parts : string [ ] = [ ] ;
132- if ( group . title ) parts . push ( `"${ group . title } "` ) ;
133- if ( group . icon ) parts . push ( `${ group . icon } ` ) ;
135+ if ( group . title ) {
136+ parts . push ( `"${ group . title } "` ) ;
137+ }
138+ if ( group . icon ) {
139+ parts . push ( `${ group . icon } ` ) ;
140+ }
134141 if ( group . includeInputs ) {
135142 if ( Array . isArray ( group . includeInputs ) ) {
136143 const includePatterns = group . includeInputs
@@ -257,24 +264,34 @@ export function prepareDescription(config: BundleStatsConfig): string {
257264
258265 // Add standardized sections
259266 const scoringSection = formatStandardizedScoringSection ( scoring ) ;
260- if ( scoringSection ) sections . push ( scoringSection ) ;
267+ if ( scoringSection ) {
268+ sections . push ( scoringSection ) ;
269+ }
261270
262271 const issuesSection = formatStandardizedIssuesSection ( scoring ) ;
263- if ( issuesSection ) sections . push ( issuesSection ) ;
272+ if ( issuesSection ) {
273+ sections . push ( issuesSection ) ;
274+ }
264275
265276 const selectionSection = formatStandardizedSelectionSection ( selection ) ;
266- if ( selectionSection ) sections . push ( selectionSection ) ;
277+ if ( selectionSection ) {
278+ sections . push ( selectionSection ) ;
279+ }
267280
268281 // Handle insightsTable which could be false
269282 const normalizedInsightsTable =
270283 insightsTable === false ? undefined : insightsTable ;
271284 const tableSection = formatStandardizedTableSection (
272285 normalizedInsightsTable ,
273286 ) ;
274- if ( tableSection ) sections . push ( tableSection ) ;
287+ if ( tableSection ) {
288+ sections . push ( tableSection ) ;
289+ }
275290
276291 const treeSection = formatStandardizedTreeSection ( dependencyTree ) ;
277- if ( treeSection ) sections . push ( treeSection ) ;
292+ if ( treeSection ) {
293+ sections . push ( treeSection ) ;
294+ }
278295
279296 // Wrap config sections in details if any exist
280297 if ( sections . length > 0 ) {
@@ -342,7 +359,7 @@ export function normalizeBundleStatsOptions(
342359 // Use the proper selection normalization helper that merges global patterns
343360 const normalizedSelection = normalizeSelectionOptions ( selection ) ;
344361
345- let normalizedPenalty : false | PenaltyConfig | undefined = undefined ;
362+ let normalizedPenalty : false | PenaltyConfig | undefined ;
346363 if ( penalty && typeof penalty === 'object' ) {
347364 const { artefactSize, ...restPenalty } = penalty ;
348365 normalizedPenalty = {
@@ -413,7 +430,7 @@ export function normalizeDependencyTreeOptions(
413430 maxChildren : 10 ,
414431 minSize : 1000 ,
415432 pathLength : 60 ,
416- ...( options ?. pruning ?? { } ) ,
433+ ...options ?. pruning ,
417434 } ,
418435 mode : options ?. mode ?? 'onlyMatching' ,
419436 } ;
@@ -451,13 +468,11 @@ export function normalizeRange(range: MinMax | number): MinMax {
451468}
452469
453470export function getAuditsFromConfigs ( configs : BundleStatsConfig [ ] ) : Audit [ ] {
454- return configs . map ( ( { slug, title, description } ) => {
455- return {
456- slug,
457- title,
458- description,
459- } ;
460- } ) ;
471+ return configs . map ( ( { slug, title, description } ) => ( {
472+ slug,
473+ title,
474+ description,
475+ } ) ) ;
461476}
462477
463478/**
0 commit comments