@@ -9,10 +9,13 @@ import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.js";
99import { asciiTable } from "./asciiTable.js" ;
1010import type { RenderOptions } from "./index.js" ;
1111
12- export async function typed ( analysis : core . Analysis , opts : RenderOptions ) : Promise < string > {
12+ export async function typed (
13+ analysis : core . Analysis ,
14+ { emoji = true , summary = true , format = "auto" , ignoreRules = [ ] } : RenderOptions ,
15+ ) : Promise < string > {
1316 let output = "" ;
1417 const problems = analysis . problems . filter (
15- ( problem ) => ! opts . ignoreRules || ! opts . ignoreRules . includes ( problemFlags [ problem . kind ] ) ,
18+ ( problem ) => ! ignoreRules || ! ignoreRules . includes ( problemFlags [ problem . kind ] ) ,
1619 ) ;
1720 const grouped = groupProblemsByKind ( problems ) ;
1821 const entrypoints = Object . keys ( analysis . entrypoints ) ;
@@ -37,17 +40,16 @@ export async function typed(analysis: core.Analysis, opts: RenderOptions): Promi
3740 out ( ) ;
3841 }
3942
40- if ( opts . ignoreRules && opts . ignoreRules . length ) {
41- out ( chalk . gray ( ` (ignoring rules: ${ opts . ignoreRules . map ( ( rule ) => `'${ rule } '` ) . join ( ", " ) } )\n` ) ) ;
43+ if ( ignoreRules && ignoreRules . length ) {
44+ out ( chalk . gray ( ` (ignoring rules: ${ ignoreRules . map ( ( rule ) => `'${ rule } '` ) . join ( ", " ) } )\n` ) ) ;
4245 }
4346
44- if ( opts . summary ) {
45- const defaultSummary = marked ( ! opts . emoji ? " No problems found" : " No problems found 🌟" ) ;
47+ if ( summary ) {
48+ const defaultSummary = marked ( ! emoji ? " No problems found" : " No problems found 🌟" ) ;
4649 const summaryTexts = Object . keys ( grouped ) . map ( ( kind ) => {
4750 const info = problemKindInfo [ kind as core . ProblemKind ] ;
48- const emoji = opts . emoji ? `${ info . emoji } ` : "" ;
4951 const description = marked ( `${ info . description } ${ info . docsUrl } ` ) ;
50- return `${ emoji } ${ description } ` ;
52+ return `${ emoji ? ` ${ info . emoji } ` : "" } ${ description } ` ;
5153 } ) ;
5254
5355 out ( summaryTexts . join ( "" ) || defaultSummary ) ;
@@ -71,14 +73,14 @@ export async function typed(analysis: core.Analysis, opts: RenderOptions): Promi
7173 const kinds = Object . keys ( problemsForCell ) as core . ProblemKind [ ] ;
7274 if ( kinds . length ) {
7375 return kinds
74- . map ( ( kind ) => ( opts . emoji ? `${ problemKindInfo [ kind ] . emoji } ` : "" ) + problemKindInfo [ kind ] . shortDescription )
76+ . map ( ( kind ) => ( emoji ? `${ problemKindInfo [ kind ] . emoji } ` : "" ) + problemKindInfo [ kind ] . shortDescription )
7577 . join ( "\n" ) ;
7678 }
7779
78- const jsonResult = ! opts . emoji ? "OK (JSON)" : "🟢 (JSON)" ;
80+ const jsonResult = ! emoji ? "OK (JSON)" : "🟢 (JSON)" ;
7981 const moduleResult = entrypoint . isWildcard
8082 ? "(wildcard)"
81- : ( ! opts . emoji ? "OK " : "🟢 " ) +
83+ : ( ! emoji ? "OK " : "🟢 " ) +
8284 moduleKinds [
8385 analysis . programInfo [ getResolutionOption ( resolutionKind ) ] . moduleKinds ?. [ resolution ?. fileName ?? "" ]
8486 ?. detectedKind || ""
@@ -87,7 +89,7 @@ export async function typed(analysis: core.Analysis, opts: RenderOptions): Promi
8789 } ) ;
8890
8991 const flippedTable =
90- opts . format === "auto" || opts . format === "table-flipped"
92+ format === "auto" || format === "table-flipped"
9193 ? new Table ( {
9294 head : [ "" , ...allResolutionKinds . map ( ( kind ) => chalk . reset ( resolutionKinds [ kind ] ) ) ] ,
9395 } )
@@ -102,7 +104,7 @@ export async function typed(analysis: core.Analysis, opts: RenderOptions): Promi
102104 }
103105
104106 const table =
105- opts . format === "auto" || ! flippedTable
107+ format === "auto" || ! flippedTable
106108 ? ( new Table ( {
107109 head : [ "" , ...entrypointHeaders ] ,
108110 } ) as GenericTable < HorizontalTableRow > )
@@ -113,7 +115,7 @@ export async function typed(analysis: core.Analysis, opts: RenderOptions): Promi
113115 } ) ;
114116 }
115117
116- switch ( opts . format ) {
118+ switch ( format ) {
117119 case "table" :
118120 out ( table ! . toString ( ) ) ;
119121 break ;
0 commit comments