Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug: [return-await] allows function without return #8651

Closed as not planned
Closed as not planned
@devuxer

Description

@devuxer

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.4.2&fileType=.tsx&code=PTAEDkHtQUwJzpOpIGNUFc4GdQDMlQAXACwEtsAaWADwAcZUiYATUAQwDtYEkAuALAAoGPSREO2AJ6dU%2BDLKJlI3InCkAVdQEEA5uzKcAFAEpQAb2GgOAdwMSACogC2FGADo4MbJAA2ANxhTAG5QEFBsEkgMXzYAIxgObnhEZC42PDIaYmgvIixudjsyRxc3T28-QKMAIn92XwwYGpNhAF8gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQHYHsBaaRAF1ml0IEMB3agS1PSnwDM3IAacbGRAI6wGJGvSYtI7Tj2xQAAqQCeABxQBjaAxWlCKeA1ykA9CSEjEYxswyRE0aPmjdeORao1ade5AaOmyCio6axYAbVc%2Be0dnWTkoanh6JVRIgF1eAF8QTKA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

// No error occurs for this, expected an error:
export async function tryTryAgain() {
    await Promise.resolve(); // should be an error and fix to return await Promise.resolve("value")
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
     "no-return-await": "off",
     "require-await": "off",
     "@typescript-eslint/require-await": "error",
     "@typescript-eslint/return-await": ["error", "always"],
  },
};

tsconfig

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

Expected Result

Expected an error

Actual Result

No error, no autofix to return await

Additional Info

I do get an error and fix if I put only return Promise.resolve("value").

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething 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-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions