8000 fix: handle template expression in quotes by yeonjuan · Pull Request #336 · yeonjuan/html-eslint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: handle template expression in quotes #336

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

Merged
merged 2 commits into from
May 7, 2025
Merged

fix: handle template expression in quotes #336

merged 2 commits into from
May 7, 2025

Conversation

yeonjuan
Copy link
Owner
@yeonjuan yeonjuan commented May 7, 2025

Checklist

Description

@yeonjuan yeonjuan requested a review from Copilot May 7, 2025 13:35
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 PR fixes issue #333 by updating the quote handling logic to correctly handle template expressions included in attribute values. Key changes include:

  • Adding a new test case for template expressions in the test suite.
  • Enhancing the rule logic in quotes.js to skip quote validation when encountering template expressions.
  • Updating invalid test cases to cover scenarios where a handler is passed in a template literal.

Reviewed Changes

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

File Description
packages/eslint-plugin/tests/rules/quotes.test.js Added tests for template expressions and handler usage in template literals
packages/eslint-plugin/lib/rules/quotes.js Modified quote-checking logic to bypass attributes containing template expressions

@yeonjuan yeonjuan requested a review from Copilot May 7, 2025 13:38
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 PR addresses bug #333 by modifying the quotes rule to properly handle template expressions in attribute values. The changes include adding test cases to verify the acceptance of template expressions and updating the quotes rule to bypass quote verification when encountering such expressions.

  • Updated tests in packages/eslint-plugin/tests/rules/quotes.test.js to cover template expressions.
  • Modified logic in packages/eslint-plugin/lib/rules/quotes.js to ignore nodes containing template expressions.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/eslint-plugin/tests/rules/quotes.test.js Added test cases for template expressions in quotes
packages/eslint-plugin/lib/rules/quotes.js Updated rule logic to bypass quote mismatch errors for template expressions

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 PR addresses issue #333 by fixing how template expressions within quotes are handled in the ESLint plugin.

  • Added tests to verify template expression handling with custom template engine syntax and inline handler functions.
  • Modified the quotes rule to bypass quote enforcement when a template expression is detected.

Reviewed Changes

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

File Description
packages/eslint-plugin/tests/rules/quotes.test.js Added test cases for template expressions in quotes and with custom templateEngineSyntax.
packages/eslint-plugin/lib/rules/quotes.js Updated the quotes rule to allow template expressions by checking for NodeTypes.Template.

* Allow template expression.
* ex: html`<div foo=${foo}></div>`
*/
if (attr.value.parts.some((part) => part.type === NodeTypes.Template)) {
Copy link
Preview
Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

Consider adding a defensive check to verify that 'attr.value.parts' is defined before calling 'some()' to prevent potential runtime errors in unexpected cases.

Suggested change
if (attr.value.parts.some((part) => part.type === NodeTypes.Template)) {
if (attr.value.parts && attr.value.parts.some((part) => part.type === NodeTypes.Template)) {

Copilot uses AI. Check for mistakes.

@yeonjuan yeonjuan merged commit 390a69b into main May 7, 2025
5 checks passed
Copy link
codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (85fe773) to head (6a8bc8f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #336   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files          76       76           
  Lines        2329     2332    +3     
  Branches      639      640    +1     
=======================================
+ Hits         2295     2298    +3     
  Misses         34       34           
Flag Coverage Δ
unittest 98.54% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/eslint-plugin/lib/rules/quotes.js 97.82% <100.00%> (+0.15%) ⬆️
🚀 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] quotes rule incorrectly reports error for attribute with template expression
1 participant
0