fix: improve no-html rule's tag location reporting#491
Merged
nzakas merged 6 commits intoeslint:mainfrom Aug 22, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves the error reporting precision for the no-html rule by highlighting the entire opening HTML tag instead of just the tag name plus one character. The change enhances developer experience by providing clearer visual feedback about which portion of code violates the rule.
- Updated regex pattern to capture complete opening HTML tags including attributes
- Modified position calculation logic to report the full tag or first line if multi-line
- Added comprehensive test cases covering various HTML tag scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/rules/no-html.js | Updated regex pattern and position calculation to report entire opening HTML tags |
| tests/rules/no-html.test.js | Added test cases for various HTML tag formats including attributes and multi-line scenarios |
nzakas
previously approved these changes
Aug 1, 2025
lumirlumir
requested changes
Aug 4, 2025
1 task
snitin315
reviewed
Aug 9, 2025
snitin315
previously approved these changes
Aug 10, 2025
1 task
lumirlumir
requested changes
Aug 10, 2025
lumirlumir
previously approved these changes
Aug 18, 2025
Member
lumirlumir
left a comment
There was a problem hiding this comment.
LGTM. Would like @snitin315 and @nzakas to verify the changes before merging.
Member
|
@TKDev7 can you take a look at the conflicts? |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
This pull request aims to enhance the clarity and precision of error reporting for the
no-htmlrule. Previously, rule violations for HTML tags would highlight only a partial segment, specifically the tag name and an extra character.What changes did you make? (Give an overview)
I've modified the
no-htmlrule's reporting logic to report the entire opening HTML tag, including any attributes and spaces, as long as it's on a single line. If the opening tag spans multiple lines, only the first line of the tag will be reported.<div id="foo">, it will report the full<div id="foo">.<p\n data-attribute="value">, it will report only<p.Related Issues
Fixes #478
Is there anything you'd like reviewers to focus on?