@@ -13,14 +13,12 @@ export class ContextLinter {
1313 private contextdocsLinter : ContextdocsLinter ;
1414 private contextignoreLinter : ContextignoreLinter ;
1515 private contextValidator : ContextValidator ;
16- private missingFieldsSummary : Map < string , string [ ] > ;
1716
1817 constructor ( ) {
1918 this . md = new MarkdownIt ( ) ;
2019 this . contextdocsLinter = new ContextdocsLinter ( ) ;
2120 this . contextignoreLinter = new ContextignoreLinter ( ) ;
2221 this . contextValidator = new ContextValidator ( ) ;
23- this . missingFieldsSummary = new Map ( ) ;
2422 }
2523
2624 public async lintDirectory ( directoryPath : string , packageVersion : string ) : Promise < boolean > {
@@ -32,14 +30,6 @@ export class ContextLinter {
3230
3331 console . log ( '\nLinting completed.' ) ;
3432
35- if ( this . missingFieldsSummary . size > 0 ) {
36- console . log ( '\nMissing Fields Summary:' ) ;
37- for ( const [ file , missingFields ] of this . missingFieldsSummary . entries ( ) ) {
38- console . log ( ` ${ file } :` ) ;
39- console . log ( ` ${ missingFields . join ( ', ' ) } ` ) ;
40- }
41- }
42-
4333 return isValid ;
4434 }
4535
@@ -90,14 +80,19 @@ export class ContextLinter {
9080 } else {
9181 result = { isValid : false , coveragePercentage : 0 , missingFields : [ ] } ;
9282 }
93- this . printValidationResult ( result . isValid , filePath ) ;
83+ this . printValidationResult ( result , filePath ) ;
9484 return result . isValid ;
9585 } ) || false ;
9686 }
9787
98- private printValidationResult ( isValid : boolean , filePath : string ) : void {
88+ private printValidationResult ( result : ValidationResult , filePath : string ) : void {
9989 const fileName = path . basename ( filePath ) ;
100- if ( isValid ) {
90+ const totalFields = result . missingFields . length + Math . round ( result . coveragePercentage * 100 / 100 ) ;
91+ console . log ( ` Context coverage: ${ result . coveragePercentage . toFixed ( 2 ) } % (${ totalFields - result . missingFields . length } /${ totalFields } fields)` ) ;
92+ if ( result . missingFields . length > 0 ) {
93+ console . log ( ` Missing fields: ${ result . missingFields . join ( ', ' ) } ` ) ;
94+ }
95+ if ( result . isValid ) {
10196 console . log ( ` ✅ ${ fileName } passed validation` ) ;
10297 } else {
10398 console . error ( ` ❌ ${ fileName } failed validation` ) ;
@@ -113,10 +108,6 @@ export class ContextLinter {
113108 const validationResult = this . contextValidator . validateContextData ( frontmatterData , 'markdown' ) ;
114109 const markdownValid = this . validateMarkdownContent ( markdownContent . trim ( ) ) ;
115110
116- if ( validationResult . missingFields . length > 0 ) {
117- this . missingFieldsSummary . set ( path . basename ( filePath ) , validationResult . missingFields ) ;
118- }
119-
120111 return {
121112 isValid : validationResult . isValid && markdownValid ,
122113 coveragePercentage : validationResult . coveragePercentage ,
@@ -165,13 +156,7 @@ export class ContextLinter {
165156
166157 try {
167158 const yamlData = this . parseYaml ( content ) ;
168- const validationResult = this . contextValidator . validateContextData ( yamlData , 'yaml' ) ;
169-
170- if ( validationResult . missingFields . length > 0 ) {
171- this . missingFieldsSummary . set ( path . basename ( filePath ) , validationResult . missingFields ) ;
172- }
173-
174- return validationResult ;
159+ return this . contextValidator . validateContextData ( yamlData , 'yaml' ) ;
175160 } catch ( error ) {
176161 if ( error instanceof yaml . YAMLException ) {
177162 console . error ( ` Error parsing YAML file: ${ this . formatYamlError ( error ) } ` ) ;
@@ -187,13 +172,7 @@ export class ContextLinter {
187172
188173 try {
189174 const jsonData = JSON . parse ( content ) as Record < string , unknown > ;
190- const validationResult = this . contextValidator . validateContextData ( jsonData , 'json' ) ;
191-
192- if ( validationResult . missingFields . length > 0 ) {
193- this . missingFieldsSummary . set ( path . basename ( filePath ) , validationResult . missingFields ) ;
194- }
195-
196- return validationResult ;
175+ return this . contextValidator . validateContextData ( jsonData , 'json' ) ;
197176 } catch ( error ) {
198177 if ( error instanceof SyntaxError ) {
199178 console . error ( ` Error parsing JSON file: ${ this . formatJsonError ( error , content ) } ` ) ;
0 commit comments