@@ -12,7 +12,7 @@ export default createConformanceRule<{ mdGlobPattern: string }>({
1212 name : 'blog-description' ,
1313 category : 'consistency' ,
1414 description :
15- 'Ensures that blog posts have a description in their frontmatter' ,
15+ 'Ensures that markdown documentation files have a description in their frontmatter' ,
1616 reporter : 'project-files-reporter' ,
1717 implementation : async ( { projectGraph, ruleOptions } ) => {
1818 const violations : ProjectFilesViolation [ ] = [ ] ;
@@ -43,26 +43,32 @@ export default createConformanceRule<{ mdGlobPattern: string }>({
4343 const content = readFileSync ( file , 'utf-8' ) ;
4444 const frontmatterMatch = content . match ( / ^ - - - \n ( [ \s \S ] * ?) \n - - - / ) ;
4545
46- // Only check files with frontmatter
47- if ( frontmatterMatch ) {
48- try {
49- const frontmatter = yamlLoad ( frontmatterMatch [ 1 ] ) as Record <
50- string ,
51- unknown
52- > ;
46+ if ( ! frontmatterMatch ) {
47+ violations . push ( {
48+ message : 'Markdown documentation files must have frontmatter' ,
49+ sourceProject : docsProject . name ,
50+ file : file ,
51+ } ) ;
52+ continue ;
53+ }
54+
55+ try {
56+ const frontmatter = yamlLoad ( frontmatterMatch [ 1 ] ) as Record <
57+ string ,
58+ unknown
59+ > ;
5360
54- if ( ! frontmatter . description ) {
55- violations . push ( {
56- message :
57- 'Blog posts with frontmatter must have a description field' ,
58- sourceProject : docsProject . name ,
59- file : file ,
60- } ) ;
61- }
62- } catch ( e ) {
63- // If YAML parsing fails, we skip the file
64- continue ;
61+ if ( ! frontmatter . description ) {
62+ violations . push ( {
63+ message :
64+ 'Markdown documentation files must have a description field in their frontmatter' ,
65+ sourceProject : docsProject . name ,
66+ file : file ,
67+ } ) ;
6568 }
69+ } catch ( e ) {
70+ // If YAML parsing fails, we skip the file
71+ continue ;
6672 }
6773 }
6874
0 commit comments