Skip to content

Commit 378e2b5

Browse files
author
Fernando Basello
committed
fix: babel plugin
1 parent 767e56a commit 378e2b5

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/plugins/index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ module.exports = function (babel) {
7878
path.node.callee.property.name === 'enqueueItem');
7979

8080
if (isEnqueueItemCall && path.node.arguments.length > 0) {
81-
const arg = path.node.arguments[0];
81+
const localArg = path.node.arguments[0];
8282

8383
// New Case: Handle function calls with arguments
84-
if (t.isCallExpression(arg)) {
85-
const callee = arg.callee;
84+
if (t.isCallExpression(localArg)) {
85+
const callee = localArg.callee;
8686
if (t.isIdentifier(callee)) {
8787
const binding = path.scope.getBinding(callee.name);
8888

@@ -93,7 +93,7 @@ module.exports = function (babel) {
9393
t.isImportDeclaration(binding.path.parent))
9494
) {
9595
// Check arguments for runtime values
96-
const args = arg.arguments.map((arg) => {
96+
const args = localArg.arguments.map((arg) => {
9797
if (t.isIdentifier(arg)) {
9898
const argBinding = path.scope.getBinding(arg.name);
9999
if (argBinding) {
@@ -247,9 +247,9 @@ module.exports = function (babel) {
247247
);
248248
} else {
249249
// If no runtime values, use string literal
250-
const arg = args.map((arg) => arg.value).join(', ');
250+
const valueArg = args.map((arg) => arg.value).join(', ');
251251
path.node.arguments[0] = t.stringLiteral(
252-
`${callee.name}(${arg})`
252+
`${callee.name}(${valueArg})`
253253
);
254254
}
255255
return;
@@ -274,7 +274,7 @@ module.exports = function (babel) {
274274
extractFunctionParts(path, functionNode);
275275

276276
// Extract argument values and their declarations if they are variables
277-
const args = arg.arguments.map((arg) => {
277+
const args = localArg.arguments.map((arg) => {
278278
if (t.isBinaryExpression(arg)) {
279279
// For binary expressions, check if either operand is a runtime value
280280
const left =
@@ -440,8 +440,8 @@ module.exports = function (babel) {
440440
}
441441
}
442442
}
443-
} else if (t.isIdentifier(arg)) {
444-
const binding = path.scope.getBinding(arg.name);
443+
} else if (t.isIdentifier(localArg)) {
444+
const binding = path.scope.getBinding(localArg.name);
445445

446446
if (binding) {
447447
const bindingNode = binding.path.node;
@@ -453,7 +453,7 @@ module.exports = function (babel) {
453453
bindingNode
454454
);
455455
const functionString = generateES5Function(
456-
arg.name,
456+
localArg.name,
457457
functionBody,
458458
isAsync,
459459
params
@@ -472,7 +472,7 @@ module.exports = function (babel) {
472472
bindingNode.init
473473
);
474474
const functionString = generateES5Function(
475-
arg.name,
475+
localArg.name,
476476
functionBody,
477477
isAsync,
478478
params
@@ -484,12 +484,12 @@ module.exports = function (babel) {
484484

485485
// Case 3: Directly Passed Arrow Functions or Function Expressions
486486
else if (
487-
t.isArrowFunctionExpression(arg) ||
488-
t.isFunctionExpression(arg)
487+
t.isArrowFunctionExpression(localArg) ||
488+
t.isFunctionExpression(localArg)
489489
) {
490490
const { functionBody, params, isAsync } = extractFunctionParts(
491491
path,
492-
arg
492+
localArg
493493
);
494494
const functionString = generateES5Function(
495495
'anonymousFunction',

0 commit comments

Comments
 (0)