help wantednew rule
Métriques du dépôt
- Stars
- (5 022 étoiles)
- Métriques de merge PR
- (Merge moyen 1j 16h) (399 PRs mergées en 30 j)
Description
The rule name may be named unicorn/prefer-await.
This only applies for ES6 code that have the await keyword available.
Prefer 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.
Fail
await doSomething().then(() => {
// …
});
doSomething().then(() => {
// …
});
await doSomething().catch((err) => {
// …
});
doSomething().catch((err) => {
// …
});
Pass
await doSomething();
try {
await doSomething();
} catch (err) {
// …
}