(node)
| 22 | node.parent.arguments.length === 1 && node.parent.arguments[0] === node; |
| 23 | |
| 24 | function findEnclosingFunction(node) { |
| 25 | while (true) { |
| 26 | node = node.parent; |
| 27 | if (!node) break; |
| 28 | |
| 29 | if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') continue; |
| 30 | |
| 31 | if (node.parent?.type === 'CallExpression') { |
| 32 | if (node.parent.callee === node) continue; // IIFE |
| 33 | |
| 34 | if ( |
| 35 | node.parent.callee.type === 'MemberExpression' && |
| 36 | ( |
| 37 | node.parent.callee.object.type === 'ArrayExpression' || |
| 38 | node.parent.callee.object.type === 'Identifier' || |
| 39 | isObjectKeysOrEntries(node.parent.callee.object) |
| 40 | ) && |
| 41 | ( |
| 42 | node.parent.callee.property.name === 'forEach' || |
| 43 | (node.parent.callee.property.name === 'map' && isPromiseAllCallArg(node.parent)) |
| 44 | ) |
| 45 | ) continue; // `[].forEach()` call |
| 46 | } else if (node.parent?.type === 'NewExpression') { |
| 47 | if (node.parent.callee.type === 'Identifier' && node.parent.callee.name === 'Promise') continue; |
| 48 | } else if (node.parent?.type === 'Property') { |
| 49 | const ancestor = node.parent.parent?.parent; |
| 50 | if (ancestor?.type === 'CallExpression' && |
| 51 | ancestor.callee.type === 'Identifier' && |
| 52 | /^spawnSyncAnd(Exit(WithoutError)?|Assert)$/.test(ancestor.callee.name)) { |
| 53 | continue; |
| 54 | } |
| 55 | } |
| 56 | break; |
| 57 | } |
| 58 | return node; |
| 59 | } |
| 60 | |
| 61 | function isMustCallOrMustCallAtLeast(str) { |
| 62 | return str === 'mustCall' || str === 'mustCallAtLeast' || str === 'mustSucceed'; |
no test coverage detected