-
Notifications
You must be signed in to change notification settings - Fork 61
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
Implement no-return-from-async rule #190
Implement no-return-from-async rule #190
Conversation
7c55c58
to
a548690
Compare
I guess this could be extended to disallow |
@lo1tuma, sorry to "at" you, but is this something you would consider adopting? |
Hi @papandreou, sorry for the late response. I think this rule makes sense. I haven’t had a closer look at the code yet (I hope I find the time soon), but I’m a bit concerned about the copy-pasted code you mentioned in the PR description. Is there any chance to extract and re-use similarities? |
@lo1tuma, thanks for taking a look! I'll see about move the copy/pasted helper functions into What do you think about the idea of having a mode where returning from any |
What would be the rationale behind it? But now that your are saying it I could imagine a generic |
It would be a way to enforce the use of
... while still allowing a value-less (early) return:
... seeing that a promise is the only type of return value from an So it's really mostly a stylistic thing. I came up with the idea when I did a sweep through a test suite that used promise chains, converting it to |
I've moved the identical helper functions into |
My gut feeling is that handling returns in callback-based and |
... Right, except that the naming would be off because the rule would then also affect non- |
Maybe it is the best to make small steps. Let’s start with those two separate rules for now and once we have gained some usage experience we can think about if it would make sense to combine them in a generic |
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 👍. Thank you!
Regarding a rule disallowing It would be nice, as long as arrow functions with implicit // Much nice, such arrow
it('works with a promise', () => expect(getpromise()).to.eventually.not.throw(Error)) |
While upgrading a codebase to use async/await I've found it to be a bit confusing when the two Promise styles are mixed so a Promise is returned from an
async
test:I've implemented a rule that prohibits mixing these two styles, similar to to the
no-return-and-callback
. And pretty much all copy/pasted from it because of the similarities :)