thoughtbot / eslint-config

A sharable ESLint configuration that enforces thoughtbot’s JavaScript guides.
https://thoughtbot.com
MIT License
10 stars 1 forks source link

Allow using void keyword with promises #6

Closed stevehanson closed 1 year ago

stevehanson commented 1 year ago

We use the no-floating-promises rule with the ignoreVoid option. This allows us to use the void keyword to explicitly mark promises as intentionally not awaited and can be handy when we want to allow a promise to raise without handling at a certain layer of the application.

This conflicts with our no-void rule which disallows the void keyword entirely. Per the documentation for the no-floating-promises ignoreVoid rule:

With this option set to true, and if you are using no-void, you should turn on the allowAsStatement option.

This commit turns on this option so we can now use promises with the "void" keyword.

Before:

someAsyncFn() // ✅ error no-floating-promises
void someAsyncFn() // ❌ error no-void

Now:

someAsyncFn() // ✅ error no-floating-promises
void someAsyncFn() // ✅ no error
stevehanson commented 1 year ago

Published in 1.0.2.