Skip to content

[no-floating-promises] flag .map(async) result #5958

Closed
@rvsit

Description

@rvsit

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.8.4&sourceType=module&code=MYewdgzgLgBAJgQygmBeGBtA5FAptLAXQG4AoUxZAOgFsEAHACgQgE8xgZGBKNAPhgBvUjBgIA7ggCWsMLnEwACgCcQNKRFyNGAfWX4ANDH0ArXqgGaoAFSk1cIAK5RGpowEYADN+7cyAXz9SIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6aRAR1ko9oEMA7v0r50URNGgB7aJAA04bHiKlkFanQbM2TabQBm8af3zMA5rWIyAtpWQpxkSTLlKAviHdA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

const data = ['test'];

data.map(async () => {
  await new Promise((_res, rej) => setTimeout(rej, 1000));
});

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/require-await": "error",
    "@typescript-eslint/no-floating-promises": "error"
  }
}

tsconfig

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

Expected Result

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator.

Actual Result

No eslint error, but ERR_UNHANDLED_REJECTION when running

Additional Info

No response

Versions

package version
@typescript-eslint/eslint-plugin 5.42.1
@typescript-eslint/parser 5.42.1
TypeScript 4.8.4
ESLint 8.15.0
node web

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: 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