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
classA{staticformat(status:{name:string|undefined}|undefined):string|undefined{returnstatus?.name ?`${status.name||''}`.trim() :undefined;}}
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-useless-template-literals":"error"}}
tsconfig
{"compilerOptions": {}}
Expected Result
classA{staticformat(status:{name:string|undefined}|undefined):string|undefined{returnstatus?.name ?(status.name||'').trim() :undefined;}}
I think the autofixer should have added parens when it removed the template literal.
Actual Result
classA{staticformat(status:{name:string|undefined}|undefined):string|undefined{returnstatus?.name ?status.name||''.trim() :undefined;}}
Additional Info
This seems to repro in Playground with or withoutstrictNullChecks
. I'm my project, I was not usingstrictNullChecks
.
The autofix highlights that the original code is silly.
I tested this also with minimal eslint config, and it still happens.
Edit: I changed Playground link to be most minimal rule set & tsConfig.