Skip to content

Bug: [no-floating-promises] adds extra parentheses to already-parenthesized expression #11486

@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.9.2&showAST=ts&fileType=.tsx&code=IYZwngdgxgBAZgV2gFwJYHsL3egFAShgG8AoGGXKTEdAGwFMA6W9Ac1wHI4cP8AaGAAUATugC2qEE2H0atAG71O3dL3wBuEgF8SQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDN4OBDfMwDmtYtA4BbSshTooAd37QmkcGAC%2BIDUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

async function foo() {
  (console.log('foo'), Promise.resolve('foo'));
}

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-floating-promises": "warn"
  }
}

tsconfig

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

Expected Result

suggestion gives

async function foo() {
  await (console.log('foo'), Promise.resolve('foo'));
}

Actual Result

suggestion gives

async function foo() {
  await ((console.log('foo'), Promise.resolve('foo')));
}

Additional Info

Noticed in #11479 since prettier now formats comma operator expressions as (a, b); instead of a, b;

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