Skip to content

Bug: no-multiple-h1 and require-alt-text miss errors after a HTML comment is closed #464

@ericcornelissen

Description

@ericcornelissen

Environment

ESLint version: 9.31.0
@eslint/markdown version: 7.0.0
Node version: 22.15.0
npm version: 10.9.2
Operating System: Ubuntu 24.04

Which language are you using?

gfm

What did you do?

Configuration
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";

export default defineConfig({
  files: ["**/*.md"],
  plugins: { markdown },
  language: "markdown/gfm",
  rules: {
    "markdown/no-multiple-h1": "error",
    "markdown/require-alt-text": "error",
  },
});

# Heading 1

<h1>Reported</h1>
<!-- --> <h1>Not reported</h1>

---

<img src="reported.png" />
<!-- --> <img src="not-reported.png" />

What did you expect to happen?

With no-multiple-h1: error the substring <h1>Not reported</h1> should be reported.

With require-alt-text: error the substring <img src="not-reported.png" /> should be reported.

What actually happened?

Neither is reported.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-cttfryej?file=eslint.config.js,markdown.md&view=editor

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

For both this is due to the regular subexpression (?<!<!--[\s\S]*?)<, which does not end after the closing -->.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Implementing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions