Skip to content

Comments

feat: add allowedIgnoreCase option to no-html#500

Merged
nzakas merged 2 commits intoeslint:mainfrom
TKDev7:allowedIgnoreCase
Aug 19, 2025
Merged

feat: add allowedIgnoreCase option to no-html#500
nzakas merged 2 commits intoeslint:mainfrom
TKDev7:allowedIgnoreCase

Conversation

@TKDev7
Copy link
Contributor

@TKDev7 TKDev7 commented Aug 6, 2025

Prerequisites checklist

What is the purpose of this pull request?

This PR adds a new allowedIgnoreCase option to the no-html rule to enable case-insensitive matching for HTML tag names against the allowed array. This addresses the issue where HTML tag names are case-insensitive by specification, but the rule was performing case-sensitive matching, leading to false positives.
For example, with allowed: ["DIV"] configured:

  • Before: Only <DIV></DIV> was allowed, but <div></div> was reported as an error
  • After: With allowedIgnoreCase: true, both <div></div>, <DIV></DIV>, and <DiV></DiV> are allowed

What changes did you make? (Give an overview)

  • Implemented case-insensitive matching logic that converts both the allowed tags and found tag names to lowercase when allowedIgnoreCase is true
  • Added test cases for case-insensitive scenarios and mixed case handling
  • Added examples and explanation for the new option

Related Issues

Fixes #479

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

@lumirlumir lumirlumir added this to Triage Aug 7, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Aug 7, 2025
@lumirlumir lumirlumir requested a review from Copilot August 7, 2025 13:58
Copy link

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

This PR introduces a new allowedIgnoreCase option to the no-html rule to enable case-insensitive matching of HTML tag names against the allowed list, addressing HTML's case-insensitive nature.

  • Adds allowedIgnoreCase boolean option for case-insensitive tag matching
  • Implements lowercase conversion logic for both allowed tags and found tag names when the option is enabled
  • Includes comprehensive test coverage for various case scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/rules/no-html.js Implements the core logic for case-insensitive matching with new option schema and comparison logic
tests/rules/no-html.test.js Adds comprehensive test cases covering valid/invalid scenarios for case-sensitive and case-insensitive matching
docs/rules/no-html.md Documents the new option with examples showing case-insensitive behavior

Copy link
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

@TKDev7 Before starting work, please wait for the issue to be accepted. The team is still finalizing the solution approach, and you can find more details in the contributing guidelines.

Screenshot 2025-08-09 at 12 27 04 PM

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.

It mostly looks good to me. I’ve left a few comments regarding documentation cleanups.

@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Aug 11, 2025
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.

LGTM, Would like another review before merging.

@lumirlumir lumirlumir moved this from Implementing to Second Review Needed in Triage Aug 15, 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 06ac53d into eslint:main Aug 19, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Aug 19, 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: Make no-html rule's allowed option case-insensitive

4 participants