Tiny annotate lint rule update (#43926)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user