Skip to content

feat: fix incorrect regex pattern in no-multiple-h1#624

Merged
snitin315 merged 7 commits intomainfrom
fix/incorrect-html-regex-patterns-in-rules
Mar 18, 2026
Merged

feat: fix incorrect regex pattern in no-multiple-h1#624
snitin315 merged 7 commits intomainfrom
fix/incorrect-html-regex-patterns-in-rules

Conversation

@lumirlumir
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir commented Feb 23, 2026

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

Which language are you using?

CommonMark and GFM.

What did you do?

I expected the # Another H1 heading in the following example to be reported.

<!-- eslint markdown/no-multiple-h1: "error" -->

<h1>Heading</h1       >

# Another H1

What did you expect to happen?

According to the HTML specification, I expected the following Markdown code to be reported, but it isn't. It's a false negative because the h1TagPattern regex does not recognize tags that contain whitespace (any amount) immediately after the tag name, as shown below:

<!-- eslint markdown/no-multiple-h1: "error" -->

<h1>Heading</h1       >

# Another H1

https://html.spec.whatwg.org/multipage/syntax.html#end-tags

image

Link to minimal reproducible Example

The following example would help identify the problem:

It should report an error for # Another H1, but it doesn't.

<!-- eslint markdown/no-multiple-h1: "error" -->

<h1>Heading</h1       >

# Another H1

What changes did you make? (Give an overview)

This PR fixes an incorrect regex pattern in no-multiple-h1.

Although this is a fix PR, per our Semantic Versioning Policy's clause "A bug fix in a rule that results in ESLint reporting more linting errors", I've marked the PR prefix as feat.

Related Issues

N/A

Is there anything you'd like reviewers to focus on?

N/A

@eslintbot eslintbot added this to Triage Feb 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Feb 23, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Feb 23, 2026
@lumirlumir lumirlumir changed the title fix: refine HTML regex patterns across rules feat: fix incorrect regex pattern in no-multiple-h1 Feb 26, 2026
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace removal in the test cases was applied automatically by .editorconfig, and I've verified that this change has no side effects.

@lumirlumir lumirlumir marked this pull request as ready for review February 26, 2026 14:46
Copilot AI review requested due to automatic review settings February 26, 2026 14:46
@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Feb 26, 2026
@lumirlumir lumirlumir removed the bug label Feb 26, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

// This heading tag is invalid because there is a whitespace between `</` and `h1`.
// HTML Spec: https://html.spec.whatwg.org/multipage/syntax.html#end-tags
dedent`
<h1>Heading</ h1>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add test case with whitespaces in start tag like <h1 >

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've updated it in dd3359a.

I've also updated the ----^- marker pattern to be slightly more precise.

@snitin315 snitin315 requested a review from Copilot March 16, 2026 14:54
@snitin315 snitin315 moved this from Needs Triage to Implementing in Triage Mar 16, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@lumirlumir lumirlumir requested a review from snitin315 March 18, 2026 11:30
@snitin315 snitin315 merged commit e57e398 into main Mar 18, 2026
34 checks passed
@snitin315 snitin315 deleted the fix/incorrect-html-regex-patterns-in-rules branch March 18, 2026 17:33
@github-project-automation github-project-automation Bot moved this from Implementing to Complete in Triage Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

4 participants