Skip to content

Commit

Permalink
fix: make isIIFE match what it claims to match
Browse files Browse the repository at this point in the history
More specifically
  !function(){...}()
wasn't matched, only
  !function(){...}
which isn't an IIFE
  • Loading branch information
anka-213 authored and pionxzh committed May 1, 2024
1 parent cbfbc04 commit a1b56f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ast-utils/src/matchers/isIIFE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export function isStatementIIFE(j: JSCodeshift, node: Statement): node is Expres
* ```
*/
export function isIIFE(j: JSCodeshift, node: ASTNode): node is ExpressionStatement {
if (j.UnaryExpression.check(node) && node.operator === '!') {
node = node.argument
}

if (j.CallExpression.check(node)) {
return j.FunctionExpression.check(node.callee)
|| j.ArrowFunctionExpression.check(node.callee)
}

if (j.UnaryExpression.check(node) && node.operator === '!') {
return j.FunctionExpression.check(node.argument)
}

return false
}

Expand Down

0 comments on commit a1b56f1

Please sign in to comment.