[GH-ISSUE #1202] QUESTION: Is it possible to write custom linting rules, including Quick Fix information, for frontmatter? #2486

Closed
opened 2026-03-07 20:08:13 +03:00 by kerem · 2 comments
Owner

Originally created by @cdeyoung on GitHub (May 8, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1202

I know I can access frontmatter data using params.frontMatterLines; however, the onError function seems to operate solely on the params.lines array. Is there any way to write custom linting rules to validate text in the frontmatter area of a document?

Originally created by @cdeyoung on GitHub (May 8, 2024). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1202 I know I can access frontmatter data using `params.frontMatterLines`; however, the `onError` function seems to operate solely on the `params.lines` array. Is there any way to write custom linting rules to validate text in the frontmatter area of a document?
kerem 2026-03-07 20:08:13 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (May 8, 2024):

Not directly. Front matter is so varied that I have not thought to support something like this.

But if you want to lint front matter, I suppose you could report errors for line 1 of the Markdown. It would be slightly wrong, but maybe good enough for your purposes.

<!-- gh-comment-id:2100901462 --> @DavidAnson commented on GitHub (May 8, 2024): Not directly. Front matter is so varied that I have not thought to support something like this. But if you want to lint front matter, I suppose you could report errors for line 1 of the Markdown. It would be slightly wrong, but maybe good enough for your purposes.
Author
Owner

@cdeyoung commented on GitHub (May 8, 2024):

Your decisions makes sense. I think everything is great in markdownlint as it is. The one thing that would make it perfect would be the ability to tell onError which array to operate on so people could write custom linters for their frontmatter, too, since it is only the reporting that doesn't currently work.

I'll try doing what you suggested with line one of the params.lines array.

Thanks for your response!

<!-- gh-comment-id:2100964719 --> @cdeyoung commented on GitHub (May 8, 2024): Your decisions makes sense. I think everything is great in markdownlint as it is. The one thing that would make it perfect would be the ability to tell onError which array to operate on so people could write custom linters for their frontmatter, too, since it is only the reporting that doesn't currently work. I'll try doing what you suggested with line one of the params.lines array. Thanks for your response!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2486
No description provided.