File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
src/content-linter/scripts Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -575,18 +575,22 @@ function getMarkdownLintConfig(errorsOnly, runRules) {
575575 for ( const searchRule of ruleConfig . rules ) {
576576 const searchRuleSeverity = getRuleSeverity ( searchRule , isPrecommit )
577577 if ( errorsOnly && searchRuleSeverity !== 'error' ) continue
578- searchReplaceRules . push ( searchRule )
578+ // Add search-replace rules to frontmatter configuration for rules that make sense in frontmatter
579+ // This ensures rules like TODOCS detection work in frontmatter
580+ // Rules with applyToFrontmatter should ONLY run in the frontmatter pass (which lints the entire file)
581+ // to avoid duplicate detections
582+ if ( searchRule . applyToFrontmatter ) {
583+ frontmatterSearchReplaceRules . push ( searchRule )
584+ } else {
585+ // Only add to content rules if not a frontmatter-specific rule
586+ searchReplaceRules . push ( searchRule )
587+ }
579588 if ( searchRule [ 'partial-markdown-files' ] ) {
580589 dataSearchReplaceRules . push ( searchRule )
581590 }
582591 if ( searchRule [ 'yml-files' ] ) {
583592 ymlSearchReplaceRules . push ( searchRule )
584593 }
585- // Add search-replace rules to frontmatter configuration for rules that make sense in frontmatter
586- // This ensures rules like TODOCS detection work in frontmatter
587- if ( searchRule . applyToFrontmatter ) {
588- frontmatterSearchReplaceRules . push ( searchRule )
589- }
590594 }
591595
592596 if ( searchReplaceRules . length > 0 ) {
You can’t perform that action at this time.
0 commit comments