The rule name may be named unicorn/prefer-await
.
This only applies for ES6 code that have the await
keyword available.
await
over Promise#then()
, Promise#catch()
and Promise#finally()
Prefer using await
operator over Promise#then()
, Promise#catch()
and Promise#finally()
, which is easier to write and to read afterwards.
This rule is fixable.
await doSomething().then(() => {
// …
});
doSomething().then(() => {
// …
});
await doSomething().catch((err) => {
// …
});
doSomething().catch((err) => {
// …
});
await doSomething();
try {
await doSomething();
} catch (err) {
// …
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too