-
Notifications
You must be signed in to change notification settings - Fork 37
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this 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 |
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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.
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Checklist
quotes
rule incorrectly reports error for attribute with template expression #333Description