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

Allow undefined in the first position of callbacks #25

Merged
merged 1 commit into from
Apr 16, 2018

Conversation

delaguilaluis
Copy link
Contributor

Fixes #21.

@xjamundx
Copy link
Contributor

I'm 👍 on this

@xjamundx xjamundx merged commit f0bc288 into standard:master Apr 16, 2018
@feross
Copy link
Member

feross commented Apr 18, 2018

I actually prefer undefined to represent the un-set, default value for "nothing". And null to represent an explicit, user-set value for "nothing".

Pretty sure we intentionally excluded undefined when making this rule.

What's the reasoning for allowing undefined?

@delaguilaluis
Copy link
Contributor Author

delaguilaluis commented Apr 19, 2018

Interesting way to see it. Thank you.

Lately I tried to stick with only one way to represent the absence of value (undefined), so I bumped with this rule, and, after looking at the README, the rule description deferred from the behaviour:

  • no-callback-literal - Ensures that we strictly follow the callback pattern with undefined, null or an error object in the first position of a callback.

That's the only reason for the change, and if this is a breaking change we don't want to ship, then maybe we should revert it and just update the README instead.

@feross
Copy link
Member

feross commented Apr 19, 2018

@delaguilaluis Thanks for pointing out the inconsistency with the documentation. I'm curious what @xjamundx's opinion is on this stylistic issue. Let's wait to hear from him before publishing a new version or reverting.

@delaguilaluis delaguilaluis deleted the allow-undefined-in-errbacks branch April 19, 2018 03:58
@xjamundx
Copy link
Contributor

Yeah hey I'm pretty out of touch on this stuff, but here's my 2 cents:

  1. The callback pattern has historically been callback(null, data)
  2. Since ES6 (especially with optional arguments) there has been a trend to use undefined as the one true empty value in JS

I don't see any special value in using undefined for the callback pattern, however, supporting this for folks that want to use undefined everywhere seems fine to me. 👍

@feross
Copy link
Member

feross commented Apr 24, 2018

Fair enough :)

@feross
Copy link
Member

feross commented Apr 24, 2018

Released as 3.1.0 ✨

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

Successfully merging this pull request may close these issues.

Expected "null" instead of "undefined" in error position of callback
3 participants