@@ -12,7 +12,7 @@ export default createConformanceRule<{ mdGlobPattern: string }>({
12
12
name : 'blog-description' ,
13
13
category : 'consistency' ,
14
14
description :
15
- 'Ensures that blog posts have a description in their frontmatter' ,
15
+ 'Ensures that markdown documentation files have a description in their frontmatter' ,
16
16
reporter : 'project-files-reporter' ,
17
17
implementation : async ( { projectGraph, ruleOptions } ) => {
18
18
const violations : ProjectFilesViolation [ ] = [ ] ;
@@ -43,26 +43,32 @@ export default createConformanceRule<{ mdGlobPattern: string }>({
43
43
const content = readFileSync ( file , 'utf-8' ) ;
44
44
const frontmatterMatch = content . match ( / ^ - - - \n ( [ \s \S ] * ?) \n - - - / ) ;
45
45
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
+ > ;
53
60
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
+ } ) ;
65
68
}
69
+ } catch ( e ) {
70
+ // If YAML parsing fails, we skip the file
71
+ continue ;
66
72
}
67
73
}
68
74
0 commit comments