A common bug in JavaScript is to forget the await keyword when calling an async function.

Of course you don't always want to await, sometimes you really want to get a promise. And of course you can't statically determine all target functions.

But there's still a vast majority of trivial cases that we'd like to check in order to avoid silly bugs.

Excluding naming schemes (which are cumbersome) what convenient strategies are there to deal with that problem ? Any linter ? checker ? colorization plugin ?


Use TypeScript.

  • TypeScript can statically infer and check JavaScript code. You don't need to have an actual build and/or compilation.
  • TypeScript has a fairly mature API for editors, or a node API if you want to run it yourself.
  • Visual Studio Code allows you to add a //@ts-check comment at the top of a file to instantly get errors displayed in the editor for the file.
|improve this answer|||||
  • Thanks. I just tested this idea. This is interesting. But I'm afraid it needs to work to have a little too much the JS code modified (or switch is to TypeScript which is a sane option but not the context of the question) – Denys Séguret Jan 31 '18 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.