Skip to content

Comments

fix: improve HTML id/name regex for unquoted values and spaces#480

Merged
nzakas merged 1 commit intoeslint:mainfrom
TKDev7:html-id-name-pattern-fixes
Jul 30, 2025
Merged

fix: improve HTML id/name regex for unquoted values and spaces#480
nzakas merged 1 commit intoeslint:mainfrom
TKDev7:html-id-name-pattern-fixes

Conversation

@TKDev7
Copy link
Contributor

@TKDev7 TKDev7 commented Jul 20, 2025

Prerequisites checklist

What is the purpose of this pull request?

To improve the detection of HTML id and name attributes in the no-missing-link-fragments rule, ensuring that unquoted attribute values and spaces around the equals sign are correctly handled. This fixes false negatives/positives for valid anchor references in Markdown files.

What changes did you make? (Give an overview)

  • Updated the regex used to match HTML id and name attributes to support:
    • Unquoted attribute values (e.g., <h1 id=bookmark>)
    • Optional spaces before and after the equals sign (e.g., <h2 id = bookmark-2>)
  • Added tests for all these cases

Related Issues

Fixes #481

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

@snitin315
Copy link
Contributor

Hey @TKDev7, before raising a PR, please create an issue first and wait for it to be accepted, so the team can align on the change and ensure the effort is well-directed.

@TKDev7
Copy link
Contributor Author

TKDev7 commented Jul 20, 2025

@snitin315 This is 100% a bug though. Do we create an issue first for these as well?

@snitin315
Copy link
Contributor

Yes, please create an issue first for any change, be it refactoring code, tests, docs, or a bug.

@TKDev7
Copy link
Contributor Author

TKDev7 commented Jul 20, 2025

Alright, I created one: #481

@lumirlumir

This comment was marked as resolved.

@TKDev7
Copy link
Contributor Author

TKDev7 commented Jul 24, 2025

I tried to use ultrahtml here but it has a bug.

Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

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

Thanks for trying out ultrahtml. It needs a bit more investigation, so it's fine not to use it here for now.

LGTM, Would like another review before merging.

@lumirlumir lumirlumir moved this from Needs Triage to Second Review Needed in Triage Jul 24, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 24, 2025
Copy link
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 6c35261 into eslint:main Jul 30, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jul 30, 2025
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.

Rule Change: Improve HTML id/name attribute parsing in no-missing-link-fragments

4 participants