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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions rules/no-callback-literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,10 @@ module.exports = {

CallExpression: function (node) {
var errorArg = node.arguments[0]
if (errorArg && isCallback(node.callee.name)) {
if (!couldBeError(errorArg)) {
context.report(node, 'Unexpected literal in error position of callback.')
} else if (node.arguments.length > 1 && errorArg.type === 'Identifier') {
if (errorArg.name === 'undefined') {
context.report(node, 'Expected "null" instead of "undefined" in error position of callback.')
}
}
var calleeName = node.callee.name

if (errorArg && !couldBeError(errorArg) && isCallback(calleeName)) {
context.report(node, 'Unexpected literal in error position of callback.')
}
}
}
Expand Down