Skip to content

Bug: [no-unnecessary-template-expression] Report squigglies should underline template syntax, not just expression inside #8597

Closed
@kirkwaiblinger

Description

@kirkwaiblinger

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&showAST=es&fileType=.tsx&code=AYJwpgDg9iAuAEBnAjgVwJYHNMBt1kXgBIBvAKHngHor4ATKeAOygVSbrBDybHlgAW6QgGMoAW3FgmsADTwY-AX1IKmSvhHAA3dFFSEeYAHQV4AIgAqygJ5qcd9p27peS4UlghXmeQDMQCXg0Vj5YRhDYE3MzGnhrPgBDVHC-dAAPeAB3dBwcT28IBRSNRD4xSWlYQkSODWISeFq6eABfeURGAEl3JgBreHQERAF9HBbY2icuIw1xJsIssDz5cPgRRLym2CiZPXU1wT4s0Zw%2BVyiQaBxE2H34ACMwH0n6rSgHs-F5FgQjwaYvBA8DA6S0BEQ9yGZRwflMrWAQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tmUSWWS18iALbF4AQ2G1Gw6BPioMkRNGgdokcGAC%2BIHUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

`report squigglies ${
  // do not underline this comment, or the ${ on the previous line.
  "They only underline this string, from quote to quote."
  // The autofix will strip out these comments and the ${ and }, so I think it should 
  // underline them as well, to call attention to the whole interpolation being
  // the problem, not the inner expression itself.
}`

ESLint Config

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

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

Expect error squigglies starting on the ${ and continuing all the way through the closing }

Actual Result

only the quoted string itself has squigglies

Additional Info

I was playing around with this, and it's a very easy change to make. Would be happy to toss up a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions