1
0
mirror of synced 2025-12-23 21:07:12 -05:00

Tiny annotate lint rule update (#43926)

This commit is contained in:
Rachael Sewell
2023-10-06 13:05:38 -07:00
committed by GitHub
parent 53304e8468
commit 86029b3988
2 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -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,