Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
`${"\u00E5"}`;// autofixes to// "\u00E5";`${"\u00E5"} `;// autofixes to// ` å `;
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-useless-template-literals":"error","no-useless-escape":"error"}}
tsconfig
{"compilerOptions": {// ... }}
Expected Result
I expect that the autofixed strings should preserve the string type and the escaped characters as the author wrote them.
So, we should have
`${"\u00E5"}`;// autofixes to// `\u00E5`;`${"\u00E5"} `;// autofixes to// ` \u00E5 `;
Actual Result
actual autofix results change user's input regarding template and and escaped characters.
Additional Info
This can also result in multiline template literals instead of single line literals that include a\n
.
It doesn't impact correctness at runtime, but it isn't the purview of this rule to make these stylistic changes (with the caveat, of course, that obviously$
s and backticks still need to be escaped in order to incorporate a string literal into a template string)