-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [return-await] don't error for in-try-catch
if the return is in a catch
without a finally
#2356
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
fix(eslint-plugin): [return-await] don't error for in-try-catch
if the return is in a catch
without a finally
#2356
Conversation
Thanks for the PR, @soobing! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #2356 +/- ##
==========================================
+ Coverage 92.81% 92.82% +0.01%
==========================================
Files 290 290
Lines 9453 9481 +28
Branches 2647 2657 +10
==========================================
+ Hits 8774 8801 +27
- Misses 322 323 +1
Partials 357 357
Flags with carried forward coverage won't be shown. Click here to find out more.
|
So the issue in question isn't that the code was erroring - it's that it shouldn't error. The code should work in the following way for
|
in-try-catch
if the return is in a catch
without a finally
Aha.. thanks for the kind explanation. |
This reverts commit aba2f89.
@bradzacher |
@bradzacher hi, could you review again? I don't know How to ask review again so I am mentioning 🦊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code LGTM.
Thanks for your work!
Could you please update the docs for the in-try-catch
option?
Specifically, could you make it very clear how it works, doing something like this will be good.
in-try-catch
Requires that a returned promise must be await
ed in try-catch-finally
blocks, and disallows it elsewhere. Specifically:
- if you
return
a promise within atry
, then it must beawait
ed. - if you
return
a promise within acatch
, and there is nofinally
, then it must not beawait
ed. - if you
return
a promise within acatch
, and there is afinally
, then it must beawait
ed. - if you
return
a promise within afinally
, then it must not beawait
ed.
@bradzacher Thanks for review! |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks for your work
Fixes #2344
Added below two TC, and fixed.