require-await: allow `async function` with `throw` or `return`?
See original GitHub issuerequire-await
as currently written is a terrible rule; there’s zero value in requiring that an async function
have an await
.
However, an async function
that has no await
, no throw
, and no return
truly has no purpose, because it can’t block on anything.
Would you be open to adding an option (or better, changing the default behavior) to this rule so that it only warns on async function
s that lack await+throw+return?
(to be fair, even if it calls a function that throws synchronously, it could still be valuable to have an async function
because it ensures a rejected promise)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:17 (15 by maintainers)
Top Results From Across the Web
require-await - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >How to Throw Errors From Async Functions in JavaScript?
Async functions and async methods always return a Promise, either resolved or rejected. You must attach then() and catch() , no matter what....
Read more >How to warn when you forget to `await` an async function in ...
I guess what I'm looking for is a way to require await by default, but we can suppress the error explicitly. This way,...
Read more >require-await | typescript-eslint
This rule extends the base eslint/require-await rule. It uses type information to add support for async functions that return a Promise .
Read more >Error handling with Async/Await in JS | by Ian Segers | ITNEXT
Let's step through the code: thisThrows() is an async method; We throw an error in thisThrows(); As thisThrows() is async the thrown error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 🎊10000th issue! 🎊 🎉
Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get consensus from the team, so I’m closing it. We define consensus as having three 👍s from team members, as well as a team member willing to champion the proposal. This is a high bar by design – we can’t realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they’re worth adding.
Since ESLint is pluggable and can load custom rules at runtime, the lack of consensus among the ESLint team doesn’t need to be a blocker for you using this in your project, if you’d find it useful. It just means that you would need to implement the rule yourself, rather than using a bundled rule that is packaged with ESLint.