Skip to content

fix: ignore attribute key with templates #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: ignore attribute key with templates #393

wants to merge 3 commits into from

Conversation

yeonjuan
Copy link
Owner

Checklist

Description

@yeonjuan yeonjuan requested a review from Copilot July 21, 2025 13:25
Copy link
Contributor

@Copilot 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 pull request fixes issue #392 by modifying the no-duplicate-attrs ESLint rule to properly handle attribute keys that contain template expressions. The fix prevents false positive duplicate attribute warnings when template conditionals determine which attributes are rendered.

  • Adds early return logic to skip duplicate checking for attributes with template expressions
  • Adds test case to verify the fix works with Handlebars-style conditional templates
  • Improves rule accuracy by avoiding false positives on templated attributes

Reviewed Changes

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

File Description
packages/eslint-plugin/lib/rules/no-duplicate-attrs.js Adds template detection logic and early returns to skip duplicate checking for templated attribute keys
packages/eslint-plugin/tests/rules/no-duplicate-attrs.test.js Adds test case with conditional template attributes to verify the fix

@yeonjuan yeonjuan marked this pull request as ready for review July 21, 2025 14:14
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.53%. Comparing base (662b74c) to head (b40b0bf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #393   +/-   ##
=======================================
  Coverage   98.52%   98.53%           
=======================================
  Files          82       82           
  Lines        2651     2654    +3     
  Branches      730      731    +1     
=======================================
+ Hits         2612     2615    +3     
  Misses         39       39           
Flag Coverage Δ
unittest 98.53% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ages/eslint-plugin/lib/rules/no-duplicate-attrs.js 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] False positive on @html-eslint/no-duplicate-attrs
1 participant