Skip to content
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

Bug: [no-useless-template-literals] Comments are removed by auto-fix #8609

Closed
4 tasks done
JoshuaKGoldberg opened this issue Mar 6, 2024 · 3 comments
Closed
4 tasks done
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look

Comments

@JoshuaKGoldberg
Copy link
Member

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

https://typescript-eslint.io/play/#ts=5.3.3&fileType=.ts&code=AYQwJA3g9AVABAIzjKcDkBjNdZwCbJQC%2BApsANxA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tmUSWWS18iALbF4AQ2G1Gw6BPioMkRNGgdokcGAC%2BIHUA&tsconfig=&tokens=false

Repro Code

`a${/* b */ 'c' /* d */}e`;

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-useless-template-literals": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

The fix result should be... well, I'm not sure what. Maybe the comments should be moved to before the string?:

// b
// d
`ace`;

Actual Result

`ace`;

Additional Info

This is a common thing to look out for in rule reviews. Ref: #8549

@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 6, 2024
@bradzacher
Copy link
Member

personally I'm okay with removing the comments there.
I don't think there's much value in keeping them. I also would say that in a provably useless template literal the odds of having comments is very low.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Mar 6, 2024
@JoshuaKGoldberg
Copy link
Member Author

`Hello, ${/* TODO: Switch to the user's name once the API works (GH-1234) */ 'user'}!`;

I think cases like this would be rare, but not impossible.

@JoshuaKGoldberg JoshuaKGoldberg added triage Waiting for maintainers to take a look and removed awaiting response Issues waiting for a reply from the OP or another party labels Mar 6, 2024
@bradzacher
Copy link
Member

bradzacher commented Mar 6, 2024

I think cases like this would be rare, but not impossible.

Hence 😄

the odds of having comments is very low

I'd personally be okay with closing this with a comment saying "please file a new issue if you run into this and we'll fix it". I doubt anyone would ever run into it in reality though

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look
Projects
None yet
Development

No branches or pull requests

2 participants