Skip to content

Bug: [no-floating-promises] Not marking as error when combined with a logical operator variable #6343

Closed
@aurislt7

Description

@aurislt7

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=4.9.3&sourceType=module&code=IYZwngdgxgBAZgV2gFwJYHsL3egFAShgG8BYAKBhikxGRgFswAFAJ3XtRAFMYBeGVu05cAdCy4h0AGwBuXXMhYIu+ANzlK1CLSqYAJqjSY+MRcvVkNuiAaNYAZPYbM2HbhYC+QA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDN4OBDfMwDmtYtA4BbSshTooiaBOiQANOGx4ipZBWp0GzNp1rTksWQBMxEs3IyRFyyBoC+IV0A&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

async function foo() {
  const myPromise = Promise.resolve(true);
  const condition = true;

  condition && myPromise;
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-floating-promises": "error",
    "@typescript-eslint/no-misused-promises": "error",
  },
};

Expected Result

This promise should be marked as floating-promises or misused-promise.

// Wrong usage
 condition && myPromise;

// Correct usage
 condition && await myPromise;

Actual Result

This promise is not marked as floating/misused.

Additional Info

Similar issue was closed: #2544

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: 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