lib/rules/no-promise-in-if.js
function hasPromise (node, inBooleanPosition) {
      switch (node.type) {
        case 'CallExpression':
          return hasPromiseMethod(node)

        case 'UnaryExpression':
          return hasPromise(node.argument, true)

        case 'BinaryExpression':
          return hasPromise(node.left, false) || hasPromise(node.right, false)

        case 'LogicalExpression':
          var leftHasPromise = hasPromise(node.left, inBooleanPosition)
          var rightHasPromise = hasPromise(node.right, inBooleanPosition)

          return leftHasPromise || rightHasPromise

        case 'AssignmentExpression':
          return (node.operator === '=') && hasPromise(node.right, inBooleanPosition)

        case 'SequenceExpression':
          return hasPromise(node.expressions[node.expressions.length - 1], inBooleanPosition)
      }
      return false
    }
function hasPromise (node, inBooleanPosition) {
      switch (node.type) {
        case 'CallExpression':
          return hasPromiseMethod(node)

        case 'UnaryExpression':
          return hasPromise(node.argument, true)

        case 'BinaryExpression':
          return hasPromise(node.left, false) || hasPromise(node.right, false)

        case 'LogicalExpression':
          var leftHasPromise = hasPromise(node.left, inBooleanPosition)
          var rightHasPromise = hasPromise(node.right, inBooleanPosition)

          return leftHasPromise || rightHasPromise

        case 'AssignmentExpression':
          return (node.operator === '=') && hasPromise(node.right, inBooleanPosition)

        case 'SequenceExpression':
          return hasPromise(node.expressions[node.expressions.length - 1], inBooleanPosition)
      }
      return false
    }
function hasPromise ( node , inBooleanPosition ) { switch ( node . type ) { case 'CallExpression' : return hasPromiseMethod ( node ) case 'UnaryExpression' : return hasPromise ( node . argument , true ) case 'BinaryExpression' : return hasPromise ( node . left , false ) || hasPromise ( node . right , false ) case 'LogicalExpression' : var leftHasPromise = hasPromise ( node . left , inBooleanPosition ) var rightHasPromise = hasPromise ( node . right , inBooleanPosition ) return leftHasPromise || rightHasPromise case 'AssignmentExpression' : return ( node . operator === '=' ) && hasPromise ( node . right , inBooleanPosition ) case 'SequenceExpression' : return hasPromise ( node . expressions [ node . expressions . length - 1 ] , inBooleanPosition ) } return false }
Checks if a node has a promise checked for truthiness.
@param {ASTNode} node The AST node to check.
@param {boolean} inBooleanPosition `false` if checking branch of a condition.
`true` in all other cases
@returns {Bool} method name, false if no promise truthiness check found.
@private
Checks if a node has a promise checked for truthiness .