eslint-community / eslint-plugin-promise

Enforce best practices for JavaScript promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prefer-await-to-then not throwing an error

alfechner opened this issue · comments

Description

I configured the rule like that:

'promise/prefer-await-to-then': 'error'

This code doesn't give me an error, though:

function foo(): void {
  alert('test');
}

const test = new Promise(foo);

test.then(foo).then(foo);

The other rules work fine, though.

Is there anything special about this rule?

I read the source code for the prefer-await-to-then rule.
It looks like we're intentionally excluding the top-level then. I think it's because there are platforms where top-level await is not yet available.