Skip to content

fix: false positive triggered by HTML inside comments in no-html#592

Merged
nzakas merged 1 commit intomainfrom
fix-false-positives-in-no-html
Dec 3, 2025
Merged

fix: false positive triggered by HTML inside comments in no-html#592
nzakas merged 1 commit intomainfrom
fix-false-positives-in-no-html

Conversation

@lumirlumir
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir commented Dec 1, 2025

Prerequisites checklist

What is the purpose of this pull request?

Which language are you using?

CommonMark and GFM.

What did you do?

I expected HTML tag syntax in comments not to trigger the no-html rule.

However, currently HTML tag syntax within comments triggers this rule, as shown below:

image

What did you expect to happen?

I expected HTML tag syntax in comments not to trigger the no-html rule.

Link to minimal reproducible Example

The following Markdown code may help identify the problem:

<!-- eslint markdown/no-html: "error" -->
 
<!-- <h1> -->
<!-- <div id="foo"> -->
<!-- abcdefg <abcdefg> -->

What changes did you make? (Give an overview)

In this PR, I've fixed false positive triggered by HTML inside comments in no-html.

I've simply reused the stripHtmlComments util to resolve this issue. This is a common pattern in Markdown rules, as shown below:

const text = stripHtmlComments(sourceCode.getText(node));
/** @type {RegExpExecArray} */
let match;
while ((match = imgTagPattern.exec(text)) !== null) {

Related Issues

N/A

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

N/A

@eslint-github-bot eslint-github-bot Bot added the bug label Dec 1, 2025
@eslintbot eslintbot added this to Triage Dec 1, 2025
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Dec 1, 2025
@lumirlumir lumirlumir changed the title fix: false positive triggered by comments in no-html fix: false positive triggered within comments in no-html Dec 1, 2025
@lumirlumir lumirlumir changed the title fix: false positive triggered within comments in no-html fix: false positive triggered by HTML inside comments in no-html Dec 1, 2025
@lumirlumir lumirlumir marked this pull request as ready for review December 1, 2025 07:53
Copy link
Copy Markdown
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit a2ccff8 into main Dec 3, 2025
25 checks passed
@nzakas nzakas deleted the fix-false-positives-in-no-html branch December 3, 2025 19:33
@github-project-automation github-project-automation Bot moved this from Needs Triage to Complete in Triage Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants