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 have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
class A {
static format(status: { name: string | undefined } | undefined): string | undefined {
return status?.name ? `${status.name || ''}`.trim() : undefined;
}
}
ESLint Config
module.exports = {
"rules": {"@typescript-eslint/no-useless-template-literals": "error"}
}
tsconfig
Expected Result
class A {
static format(status: { name: string | undefined } | undefined): string | undefined {
return status?.name ? (status.name || '').trim() : undefined;
}
}
I think the autofixer should have added parens when it removed the template literal.
Actual Result
class A {
static format(status: { name: string | undefined } | undefined): string | undefined {
return status?.name ? status.name || ''.trim() : undefined;
}
}
Additional Info
This seems to repro in Playground with or without strictNullChecks
. I'm my project, I was not using strictNullChecks
.
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.
{ "compilerOptions": {} }