Skip to content

Commit

Permalink
Merge pull request #25 from delaguilaluis/allow-undefined-in-errbacks
Browse files Browse the repository at this point in the history
Allow undefined in the first position of callbacks
  • Loading branch information
xjamundx authored Apr 16, 2018
2 parents a2f6742 + 7ce136a commit f0bc288
Showing 1 changed file with 4 additions and 8 deletions.
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

0 comments on commit f0bc288

Please sign in to comment.