1- import { ValidatorOutput , ValidationResult } from './types' ;
1+ import { ValidatorOutput , ValidationResult , StyleViolation } from './types' ;
22
33const MAX_CONTENT_LENGTH = 50 ;
44const MAX_ISSUES_PER_FILE = 10 ;
55const MAX_FILES = 10 ;
6+ const MAX_SUGGESTION_LENGTH = 100 ;
67
78function truncate ( str : string , maxLength : number ) : string {
89 if ( str . length <= maxLength ) return str ;
@@ -27,6 +28,22 @@ function groupByFile(results: ValidationResult[]): Map<string, ValidationResult[
2728 return grouped ;
2829}
2930
31+ function formatSuggestion ( details ?: StyleViolation [ ] ) : string {
32+ if ( ! details || details . length === 0 ) {
33+ return '-' ;
34+ }
35+
36+ const suggestions = details
37+ . filter ( d => d . suggestion )
38+ . map ( d => escapeHtml ( truncate ( d . suggestion ! , MAX_SUGGESTION_LENGTH ) ) ) ;
39+
40+ if ( suggestions . length === 0 ) {
41+ return '-' ;
42+ }
43+
44+ return suggestions . join ( '; ' ) ;
45+ }
46+
3047export function formatPRComment ( output : ValidatorOutput ) : string {
3148 const { results, summary } = output ;
3249 const icon = summary . pass ? '✅' : '❌' ;
@@ -61,20 +78,21 @@ export function formatPRComment(output: ValidatorOutput): string {
6178 comment += `<summary><code>${ file } </code> (${ issueCount } issue${ issueCount > 1 ? 's' : '' } )</summary>\n\n` ;
6279
6380 // Table header
64- comment += `| Line | Content | Issue |\n` ;
65- comment += `|------|---------|-------|\n` ;
81+ comment += `| Line | Content | Issue | Suggestion | \n` ;
82+ comment += `|------|---------|-------|------------| \n` ;
6683
6784 // Table rows
6885 const displayResults = fileResults . slice ( 0 , MAX_ISSUES_PER_FILE ) ;
6986 for ( const result of displayResults ) {
7087 const content = escapeHtml ( truncate ( result . content , MAX_CONTENT_LENGTH ) ) ;
7188 const message = escapeHtml ( result . message ) ;
72- comment += `| ${ result . line } | \`${ content } \` | ${ message } |\n` ;
89+ const suggestion = formatSuggestion ( result . details ) ;
90+ comment += `| ${ result . line } | \`${ content } \` | ${ message } | ${ suggestion } |\n` ;
7391 }
7492
7593 if ( fileResults . length > MAX_ISSUES_PER_FILE ) {
7694 const remaining = fileResults . length - MAX_ISSUES_PER_FILE ;
77- comment += `| ... | *${ remaining } more* | |\n` ;
95+ comment += `| ... | *${ remaining } more* | | | \n` ;
7896 }
7997
8098 comment += `\n</details>\n\n` ;
0 commit comments