From 8546f81f4ad25e7f0c09f1e923ca87ba30bb214f Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Tue, 30 Apr 2024 02:42:22 +0800 Subject: [PATCH] fix: furthur improve iife matching --- packages/ast-utils/src/matchers/isIIFE.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/ast-utils/src/matchers/isIIFE.ts b/packages/ast-utils/src/matchers/isIIFE.ts index 940e3224..5bf1ddc6 100644 --- a/packages/ast-utils/src/matchers/isIIFE.ts +++ b/packages/ast-utils/src/matchers/isIIFE.ts @@ -6,10 +6,7 @@ import type { ASTNode, ASTPath, CallExpression, Collection, ExpressionStatement, * ```js * (() => { ... })(...) * (function() { ... })(...) - * ``` - * - * @example - * ```js + * !(() => { ... })(...) * !function() { ... }(...) * ``` */ @@ -25,10 +22,7 @@ export function isStatementIIFE(j: JSCodeshift, node: Statement): node is Expres * ```js * (() => { ... })(...) * (function() { ... })(...) - * ``` - * - * @example - * ```js + * !(() => { ... })(...) * !function() { ... }(...) * ``` */ @@ -73,6 +67,12 @@ export function findIIFEs( operator: '!', argument: { type: 'CallExpression', + callee: { + type: (type: string) => { + return type === 'FunctionExpression' + || type === 'ArrowFunctionExpression' + }, + }, }, }, })