Skip to content

Bug: [restrict-template-expressions] customizing severity or options loses the strictTypeChecked options #11462

@fabio-colella-md

Description

@fabio-colella-md

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.9.2&fileType=.ts&code=MYewdgzgLgBAhgJwOYwLwwIwCYDMBuAKFElkSSzRigQFcBTQ46eZHSsGgG08fGYFsISDJQAGZSgBIA3mQC%2BAWhlksi5azmjeJGIPJiJ6dSgA%2BJmAHIAXnQQgLmvEA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6aFfKsu-RAW2LwAhn3oAPYh2TJKAeyaoMAbXDYciaNDnRIAGjXqs67JGHx4cgO4A5WPwBGm9GC6xEh7AF9PAXTU%2BXkA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

const arg = 123;
const arg2 = true;
const arg3 = null;
const msg1 = `arg = ${arg}-${arg2}-${arg3}`;
const msg2 = `arg = ${arg || 'zero'}`;

ESLint Config

{
  "rules": {
    "@typescript-eslint/restrict-template-expressions": [
      "error",
      {
        "allowNumber": true
      }
    ]
  }
}

tsconfig

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

Expected Result

Line 4, where I use null and boolean in the expression should show an error.

const msg1 = `arg = ${arg}-${arg2}-${arg3}`;

Actual Result

Line 4, where I use null and boolean show no error.

const msg1 = `arg = ${arg}-${arg2}-${arg3}`;

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions