-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add no-multiple-h1 rule #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, Markdownlint’s MD025 supports the title
field in YAML front matter. It also provides an option to customize which field should be recognized as the valid H1 heading.
In contrast, @eslint/markdown
supports both YAML and TOML front matter (while Markdownlint only supports YAML).
Given that, I think we should support the title
field in both YAML and TOML front matter as valid H1 headings.
That’s my personal opinion — I’d love to hear what other team members think about supporting H1 detection from both YAML and TOML front matter, similar to how Markdownlint handles it.
@eslint/eslint-team
Also, we should support detecting <h1>
HTML tags. The following code should trigger a warning:
<h1> Heading </h1>
# Heading
That seems reasonable to me. So if there's a frontmatter |
---
hello: world # title: My Title
---
# Heading 1 Still a false positive when handling comments. Should we introduce a YAML or TOML parser like Using only regular expressions seems too fragile. |
@lumirlumir Do you have specific examples or edge cases in mind where regex parsing might fail? |
Let's not introduce a parser. Rules shouldn't be doing parsing. If we can't accurately detect frontmatter H1s then let's leave it off this initial version. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@ntdiary please open a separate issue to request enhancements. We like to keep PRs focused on the original request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Leaving it open for 2nd review.
Prerequisites checklist
What is the purpose of this pull request?
This PR adds a new rule no-multiple-h1 to enforce at most one h1 heading in Markdown.
What changes did you make? (Give an overview)
Added the no-multiple-h1 rule, along with documentation and tests.
I decided to name it no-multiple-h1 instead to be more explicit about what the rule does.
Related Issues
Closes #373
Is there anything you'd like reviewers to focus on?