New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add information to no-return-await
docs about potential pitfalls.
#9695
Comments
Hi @Alxandr, thanks for the issue! We always appreciate improvements to our documentation, so definitely feel free to submit a PR. That said, do you know why the behavior you described is the way it is? It would be great to have both an example and an explanation that draws from the spec, since some users will understand the example better and others will understand the explanation/spec better. |
In fact, the |
Well, what do you know? I'm sorry for coming here with misinformation :(. But regardless, the difference is explained pretty well here: https://jakearchibald.com/2017/await-vs-return-vs-return-await/ Basically, the issue is that when you do I don't know where in the spec this is described, as I don't normally read the javascript spec, but I would guess it's for the same reason that in This behavior makes me wish I could have a linter tell me to always require |
Good catch, i had same problem recently 👍 |
If this still needs help, I am interested in taking this one on. I'll probably need a week or so (July 31st). It seems like the page that needs updating is this one. As you guys already mentioned, the following case is already on the page under "The following patterns are not warnings:"
So no need to update that part. But, I can see where Alxandr is coming from, it seems like the top paragraph is a little misleading, saying in the first line:
It is a little bit confusing that the rule says return await is useless and then further on down the page, says it allows it under some circumstances. I'd like to go in and clean up that first paragraph a little bit to make it clearer what is meant. LMK if any issues with my taking this on. Otherwise, I'll get to it. |
@not-an-aardvark Any direction you want to provide in response to this comment? Or does the proposal there sound good? Thanks! |
Sounds good to me! |
return await
has subtly different semantics from justreturn
in async functions. Example:This will call
console.warn
with the 'foo' error, which is thrown fromnoAwait
. But it will logoops
from thewithAwait
function. This is confusing behaviour, which might completely catch people off guard. So no, theawait
afterreturn
is not always superfluous, and recommending it's removal might lead to subtle changes that was not expected.The text was updated successfully, but these errors were encountered: