@@ -7,6 +7,13 @@ const message =
77const requireCall = 'CallExpression[callee.name="require"]' ;
88const assertModuleSpecifier = '/^(node:)?assert(.strict)?$/' ;
99
10+ const isPromiseAllCallArg = ( node ) =>
11+ node . parent ?. type === 'CallExpression' &&
12+ node . parent . callee . type === 'MemberExpression' &&
13+ node . parent . callee . object . type === 'Identifier' && node . parent . callee . object . name === 'Promise' &&
14+ node . parent . callee . property . type === 'Identifier' && node . parent . callee . property . name === 'all' &&
15+ node . parent . arguments . length === 1 && node . parent . arguments [ 0 ] === node ;
16+
1017function findEnclosingFunction ( node ) {
1118 while ( true ) {
1219 node = node . parent ;
@@ -20,15 +27,18 @@ function findEnclosingFunction(node) {
2027 if (
2128 node . parent . callee . type === 'MemberExpression' &&
2229 ( node . parent . callee . object . type === 'ArrayExpression' || node . parent . callee . object . type === 'Identifier' ) &&
23- node . parent . callee . property . name === 'forEach'
30+ (
31+ node . parent . callee . property . name === 'forEach' ||
32+ ( node . parent . callee . property . name === 'map' && isPromiseAllCallArg ( node . parent ) )
33+ )
2434 ) continue ; // `[].forEach()` call
2535 } else if ( node . parent ?. type === 'NewExpression' ) {
2636 if ( node . parent . callee . type === 'Identifier' && node . parent . callee . name === 'Promise' ) continue ;
2737 } else if ( node . parent ?. type === 'Property' ) {
2838 const ancestor = node . parent . parent ?. parent ;
2939 if ( ancestor ?. type === 'CallExpression' &&
3040 ancestor . callee . type === 'Identifier' &&
31- ancestor . callee . name === 'spawnSyncAndAssert' ) {
41+ / ^ s p a w n S y n c A n d ( E x i t ( W i t h o u t E r r o r ) ? | A s s e r t ) $ / . test ( ancestor . callee . name ) ) {
3242 continue ;
3343 }
3444 }
@@ -75,6 +85,7 @@ module.exports = {
7585 parent . arguments [ 0 ] . type === 'Literal' &&
7686 parent . arguments [ 0 ] . value === 'exit'
7787 ) ,
88+ t : ( name ) => name === 'test' , // t.test
7889 } [ parent . callee . object . name ] ?. ( parent . callee . property . name )
7990 ) {
8091 return ;
0 commit comments