Blame view

node_modules/eslint-plugin-promise/rules/lib/has-promise-callback.js 451 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  /**
   * Library: Has Promis eCallback
   * Makes sure that an Expression node is part of a promise
   * with callback functions (like then() or catch())
   */
  
  'use strict'
  
  function hasPromiseCallback(node) {
    if (node.type !== 'CallExpression') return
    if (node.callee.type !== 'MemberExpression') return
    const propertyName = node.callee.property.name
    return propertyName === 'then' || propertyName === 'catch'
  }
  
  module.exports = hasPromiseCallback