Skip to content

[return-await] wrong autofix of return undefined ?? promise to return await undefined ?? promise #4090

Closed
@fregante

Description

@fregante
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/await-thenable": "error"
  }
}
async function bar() {}
async function foo() {
	try {
		return window.foo ?? bar();
	} catch {}
}

tsconfig: https://github.com/sindresorhus/tsconfig/blob/67d56ca87d2790081696fe3d745befa7e9ff38b8/tsconfig.json

Expected Result

async function bar() {}
async function foo() {
	try {
		return window.foo ?? await bar();
		                  // ^ correct position of `await`
	} catch {}
}

Actual Result

async function bar() {}
async function foo() {
	try {
		return await await await await await await await await await await window.foo ?? bar();
		    // ^ incorrect position of `await`, which is then "autofixed" repeatedly
	} catch {}
}

Versions

package version
@typescript-eslint/eslint-plugin 5.3.0
@typescript-eslint/parser 5.3.0
TypeScript 4.4.4
ESLint 8.1.0
node 16.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy