I'm using Babel and Webpack. If I forget to await
an async function, it can often go unnoticed. Once in a while, if I forgot the await
, an error occurs in the async function and I get an Unhandled promise rejection
. Then, I realize that I forgot the await
.
Is there a way to get a warning when I forget to add an await
?
require-await
lint be enough for your needs? It won't catch imported async functions defined elsewhere but it will catch some casesrequire all async function calls to have an await before them
- I wouldn't recommend you require it, warning would be sufficient, because it is perfectly valid not to require to await anasync
function - in fact, at least one place in your code would have to call a function taggedasync
without usingawait
, because of the relationship betweenawait/async
keywordsawait
directly in front of it (if we build the array dynamically). I guess what I'm looking for is a way to requireawait
by default, but we can suppress the error explicitly. This way, it ensures that async functions calls withoutawait
were intentional.