Skip to content
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

handle-done-callback: allow passing done as callback #119

Open
shaharmor opened this issue Dec 14, 2016 · 3 comments
Open

handle-done-callback: allow passing done as callback #119

shaharmor opened this issue Dec 14, 2016 · 3 comments

Comments

@shaharmor
Copy link

this should not cause an error:

it('should not cause an error', function(done) {
  var obj = {someFunc: done};
  somethingThatCallsSomeFuncOnObj(obj);
});

should it?

@lo1tuma
Copy link
Owner

lo1tuma commented Dec 23, 2016

Yes, I think you are right.
The current implementation explicitly checks for a CallExpression of done or its direct parent, so passing done to a function should work but not if it is nested in other expressions like an object literal.
Maybe we should just relax the rule and treat any read of the done callback as "handled".

What do you think @jfmengels?

@jfmengels
Copy link
Collaborator

jfmengels commented Dec 23, 2016

I agree with you, the code excerpt should not cause an error.

We do lose the "assurance" that the function is at least called at some point in the code, but that did not make sure that the callback was correctly triggered anyway. Just checking the presence of an Identifier with the same name as the callback would be fine IMO.

@edg2s
Copy link
Contributor

edg2s commented May 27, 2020

Wouldn't that then just be a very specific version of no-unused-vars, which is in eslint:recommend?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants