Skip to content

New Rule: no-top-level-await #439

Open
@DMartens

Description

@DMartens

Rule details

It would warn about using top-level awaits as it conflicts with require(esm).
Unfortunately no-restricted-syntax cannot be used as the following should be ignored:

  • files with a shebang or without exports
  • files called from package.json scripts

What type of rule is this?

Warns about a potential problem

Example code

await fn();

for await (const x of asyncGenerator()) {
}

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

This rule was discussed in the eslint repo but declined with a reference to open here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions