eslint-plugin-promise icon indicating copy to clipboard operation
eslint-plugin-promise copied to clipboard

prefer-await-to-then not throwing an error

Open alfechner opened this issue 5 years ago • 2 comments
trafficstars

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?

alfechner avatar Jan 15 '20 12:01 alfechner

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.

ota-meshi avatar Sep 29 '22 07:09 ota-meshi

I think this should be configurable now.

brettz9 avatar Jul 20 '24 10:07 brettz9