question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require-await: allow `async function` with `throw` or `return`?

See original GitHub issue

require-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 functions 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:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:17 (15 by maintainers)

github_iconTop GitHub Comments

23reactions
not-an-aardvarkcommented, Feb 21, 2018

🎉 🎊10000th issue! 🎊 🎉

1reaction
not-an-aardvarkcommented, Jul 22, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found