Skip to content

Enhancement: [require-await] add option to ignore overrides methods #7536

@kkimdev

Description

@kkimdev

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/require-await

Description

"require-await" rule asserts an existence of await inside async function. However, when a class method is inherited from a parent async method, sometimes it's inevitable to keep async signature even when the body doesn't have any await. Of course, one workaround is declaring it as a sync function then returning Promise.resolve(...) but that's less ergonomic.

So my proposal is adding an option called, let's say "AllowInOverriddenFunctions", that allows async functions without await for overridden functions. Please take a look at the example below.

Pass

abstract class A {
  abstract func(): Promise<undefined>;
}

class B extends A {
  override async func() {
    return undefined;
  }
}

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: 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