| 
7 | 7 | 
 
  | 
8 | 8 | const { getAncestors } = require('./lib/eslint-compat')  | 
9 | 9 | const getDocsUrl = require('./lib/get-docs-url')  | 
 | 10 | +const hasPromiseCallback = require('./lib/has-promise-callback')  | 
10 | 11 | const isInsidePromise = require('./lib/is-inside-promise')  | 
11 | 12 | const isCallback = require('./lib/is-callback')  | 
12 | 13 | 
 
  | 
@@ -67,20 +68,30 @@ module.exports = {  | 
67 | 68 |         const options = context.options[0] || {}  | 
68 | 69 |         const exceptions = options.exceptions || []  | 
69 | 70 |         if (!isCallback(node, exceptions)) {  | 
70 |  | -          const callingName = node.callee.name || node.callee.property?.name  | 
71 |  | -          const name =  | 
72 |  | -            node.arguments && node.arguments[0] && node.arguments[0].name  | 
73 |  | -          if (  | 
74 |  | -            !exceptions.includes(name) &&  | 
75 |  | -            CB_BLACKLIST.includes(name) &&  | 
76 |  | -            (timeoutsErr || !TIMEOUT_WHITELIST.includes(callingName))  | 
77 |  | -          ) {  | 
78 |  | -            context.report({  | 
79 |  | -              node: node.arguments[0],  | 
80 |  | -              messageId: 'callback',  | 
81 |  | -            })  | 
 | 71 | +          if (hasPromiseCallback(node)) {  | 
 | 72 | +            const callingName = node.callee.name || node.callee.property?.name  | 
 | 73 | +            const name = node.arguments?.[0]?.name  | 
 | 74 | +            if (  | 
 | 75 | +              !exceptions.includes(name) &&  | 
 | 76 | +              CB_BLACKLIST.includes(name) &&  | 
 | 77 | +              (timeoutsErr || !TIMEOUT_WHITELIST.includes(callingName))  | 
 | 78 | +            ) {  | 
 | 79 | +              context.report({  | 
 | 80 | +                node: node.arguments[0],  | 
 | 81 | +                messageId: 'callback',  | 
 | 82 | +              })  | 
 | 83 | +            }  | 
 | 84 | +            return  | 
 | 85 | +          }  | 
 | 86 | +          if (!timeoutsErr) {  | 
 | 87 | +            return  | 
 | 88 | +          }  | 
 | 89 | + | 
 | 90 | +          const name = node.arguments?.[0]?.name  | 
 | 91 | +          if (!name) {  | 
 | 92 | +            // Will be handled elsewhere  | 
 | 93 | +            return  | 
82 | 94 |           }  | 
83 |  | -          return  | 
84 | 95 |         }  | 
85 | 96 | 
 
  | 
86 | 97 |         const ancestors = getAncestors(context, node)  | 
 | 
0 commit comments