From 86029b398875d4e2ebc3ac08a9699b75fd986a47 Mon Sep 17 00:00:00 2001 From: Rachael Sewell Date: Fri, 6 Oct 2023 13:05:38 -0700 Subject: [PATCH] Tiny annotate lint rule update (#43926) --- src/content-linter/lib/helpers/utils.js | 2 +- .../lib/linting-rules/annotate-frontmatter.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/content-linter/lib/helpers/utils.js b/src/content-linter/lib/helpers/utils.js index 637ce78915..f8c394b256 100644 --- a/src/content-linter/lib/helpers/utils.js +++ b/src/content-linter/lib/helpers/utils.js @@ -114,7 +114,7 @@ export const docsDomains = ['docs.github.com', 'help.github.com', 'developer.git // frontmatter properties. export function getFrontmatter(lines) { const fmString = lines.join('\n') - const data = matter(fmString).data + const { data } = matter(fmString) // If there is no frontmatter or the frontmatter contains // no keys, matter will return an empty object. if (Object.keys(data).length === 0) return null diff --git a/src/content-linter/lib/linting-rules/annotate-frontmatter.js b/src/content-linter/lib/linting-rules/annotate-frontmatter.js index fc4b7a8f33..316e84356d 100644 --- a/src/content-linter/lib/linting-rules/annotate-frontmatter.js +++ b/src/content-linter/lib/linting-rules/annotate-frontmatter.js @@ -1,5 +1,5 @@ import { addError, filterTokens } from 'markdownlint-rule-helpers' -import matter from 'gray-matter' +import { getFrontmatter } from '../helpers/utils.js' export const annotateFrontmatter = { names: ['GHD040', 'annotate-frontmatter'], @@ -10,8 +10,8 @@ export const annotateFrontmatter = { function: function GHD040(params, onError) { filterTokens(params, 'fence', (token) => { if (!token.info.includes('annotate')) return - const fm = matter(params.frontMatterLines.join('\n')).data - if (fm.layout && fm.layout === 'inline') return + const fm = getFrontmatter(params.frontMatterLines) + if (!fm || (fm.layout && fm.layout === 'inline')) return addError( onError,