-
Notifications
You must be signed in to change notification settings - Fork 245
fix(eslint-plugin-template): [prefer-template-literal] handle nested and concatenations in template literal #2466
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
… template literal
View your CI Pipeline Execution ↗ for commit 49631e6.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2466 +/- ##
==========================================
+ Coverage 92.85% 92.91% +0.06%
==========================================
Files 200 200
Lines 4169 4220 +51
Branches 973 993 +20
==========================================
+ Hits 3871 3921 +50
- Misses 229 230 +1
Partials 69 69
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… template literal
Please could you add a failing commented out test for the Angular issue and link to the Angular issue on GitHub and also link to the bugs in question in your existing commented out tests? And add a TODO comment if they simply require more investigation on our side, just so they are easier to find and track as follow ups |
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.
Thanks!
I'm going to do it now so that I can get it out in the final v19 release |
Apart from this one, please let me know what the Angular issue is: Angular bug with quotes in nested template literals with @let (including in Angular 20) Parsing error : X [ERROR] NG5002: Parser Error: Lexer Error: Unexpected character [@] at column 17 in expression [ I will write an Angular issue. |
@g-drouard Hmm I didn't get a parse error locally on v19 a2be68f |
Ah I do on the Angular 20 branch, I had to comment it out: https://github.com/angular-eslint/angular-eslint/pull/2448/files#diff-2989d9c9a6837b274845d66ef14d3d3d8cdd4ea1d6aa0323b4c8b9f035059a13R26 Has it already been reported to the Angular Team? |
Sorry for the delay in my response, I was sick. I create an Angular issue. I reproduce the bug well on version 19 or 20 of Angular. It's very strange that the rule test doesn't trigger an error. Regarding the line break bug, I have no idea if the problem comes from the Angular parser, the Angular-eslint parser, or even the rule code. |
resolves #2462
Explanation
Autofix steps of
a + ' ' + b + ' ' + c
are:`${a + ' ' + b} ` + c
`${a + ' ' + b} ${c}`
`${`${a} ` + b} ${c}`
`${`${a} ${b}`} ${c}`
This fix handle nested and concatenations in template literal to avoid this result.
Angular bug with quotes in nested template literals with @let (including in Angular 20)
Example :
@let bugWithQuote = `${`'`}`;
(same with back quote and double quote)Parsing error :
X [ERROR] NG5002: Parser Error: Lexer Error: Unexpected character [@] at column 17 in expression [`${`'`}`;
I will write an Angular issue.
Bug when the first line breaks
This is the cause of all others bugs reported from #2425.
I will create an issue.
Works
Current fix :
Doesn't work
Current fix :
Explanation
When the first line breaks,
sourceSpan
positions are wrong.I added tests and investigated it for several hours, but I don't have enough knowledge of how it works to fix this.