@eslint-react/ast 1.28.0-next.1 → 1.28.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -30
- package/dist/index.d.ts +7 -30
- package/dist/index.js +20 -49
- package/dist/index.mjs +20 -43
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -148,8 +148,6 @@ declare function getClassIdentifier(node: TSESTreeClass): TSESTree.Identifier |
|
|
|
148
148
|
|
|
149
149
|
declare function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | _;
|
|
150
150
|
|
|
151
|
-
declare function getIdentifiersFromBinaryExpression(side: TSESTree.BinaryExpression | TSESTree.BinaryExpression["left"] | TSESTree.BinaryExpression["right"]): readonly TSESTree.Identifier[];
|
|
152
|
-
|
|
153
151
|
declare function getLiteralValueType(input: bigint | boolean | null | number | string | symbol): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null";
|
|
154
152
|
|
|
155
153
|
/**********************************************
|
|
@@ -2362,31 +2360,14 @@ declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => no
|
|
|
2362
2360
|
|
|
2363
2361
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
2364
2362
|
|
|
2365
|
-
/**
|
|
2366
|
-
* Checks if the given node is a function expression or arrow function expression of a class method.
|
|
2367
|
-
* @param node The node to check.
|
|
2368
|
-
* @returns `true` if the node is a function expression or arrow function expression of a class method, `false` otherwise.
|
|
2369
|
-
*/
|
|
2370
|
-
declare function isFunctionOfClassMethod(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
|
|
2371
|
-
|
|
2372
|
-
/**
|
|
2373
|
-
* Checks if the given node is a function expression or arrow function expression of a class property.
|
|
2374
|
-
* @param node The node to check.
|
|
2375
|
-
* @returns `true` if the node is a function expression or arrow function expression of a class property, `false` otherwise.
|
|
2376
|
-
*/
|
|
2377
|
-
declare function isFunctionOfClassProperty(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
|
|
2378
|
-
|
|
2379
|
-
declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
2380
|
-
|
|
2381
|
-
/**
|
|
2382
|
-
* Checks if the given node is a function expression or arrow function expression of a object method.
|
|
2383
|
-
* @param node The node to check.
|
|
2384
|
-
* @returns `true` if the node is a function expression or arrow function expression of a object method, `false` otherwise.
|
|
2385
|
-
*/
|
|
2386
|
-
declare function isFunctionOfObjectMethod(node: TSESTree.Node): boolean;
|
|
2387
|
-
|
|
2388
2363
|
declare function isKeyLiteralLike(node: TSESTree.MemberExpression | TSESTree.MethodDefinition | TSESTree.Property | TSESTree.PropertyDefinition, property: TSESTree.Node): boolean;
|
|
2389
2364
|
|
|
2365
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "boolean"): node is TSESTree.BooleanLiteral;
|
|
2366
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "null"): node is TSESTree.NullLiteral;
|
|
2367
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "number"): node is TSESTree.NumberLiteral;
|
|
2368
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "regexp"): node is TSESTree.RegExpLiteral;
|
|
2369
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is TSESTree.StringLiteral;
|
|
2370
|
+
|
|
2390
2371
|
declare function isMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
|
|
2391
2372
|
|
|
2392
2373
|
/**
|
|
@@ -2408,10 +2389,6 @@ declare const isNodeEqual: {
|
|
|
2408
2389
|
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
2409
2390
|
};
|
|
2410
2391
|
|
|
2411
|
-
declare function isRegExpLiteral(node: TSESTree.Node): node is TSESTree.RegExpLiteral;
|
|
2412
|
-
|
|
2413
|
-
declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
|
|
2414
|
-
|
|
2415
2392
|
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
2416
2393
|
|
|
2417
2394
|
/**
|
|
@@ -2432,4 +2409,4 @@ type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
|
|
|
2432
2409
|
|
|
2433
2410
|
declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
|
|
2434
2411
|
|
|
2435
|
-
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath,
|
|
2412
|
+
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
|
package/dist/index.d.ts
CHANGED
|
@@ -148,8 +148,6 @@ declare function getClassIdentifier(node: TSESTreeClass): TSESTree.Identifier |
|
|
|
148
148
|
|
|
149
149
|
declare function getFunctionIdentifier(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | _;
|
|
150
150
|
|
|
151
|
-
declare function getIdentifiersFromBinaryExpression(side: TSESTree.BinaryExpression | TSESTree.BinaryExpression["left"] | TSESTree.BinaryExpression["right"]): readonly TSESTree.Identifier[];
|
|
152
|
-
|
|
153
151
|
declare function getLiteralValueType(input: bigint | boolean | null | number | string | symbol): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null";
|
|
154
152
|
|
|
155
153
|
/**********************************************
|
|
@@ -2362,31 +2360,14 @@ declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => no
|
|
|
2362
2360
|
|
|
2363
2361
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
2364
2362
|
|
|
2365
|
-
/**
|
|
2366
|
-
* Checks if the given node is a function expression or arrow function expression of a class method.
|
|
2367
|
-
* @param node The node to check.
|
|
2368
|
-
* @returns `true` if the node is a function expression or arrow function expression of a class method, `false` otherwise.
|
|
2369
|
-
*/
|
|
2370
|
-
declare function isFunctionOfClassMethod(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
|
|
2371
|
-
|
|
2372
|
-
/**
|
|
2373
|
-
* Checks if the given node is a function expression or arrow function expression of a class property.
|
|
2374
|
-
* @param node The node to check.
|
|
2375
|
-
* @returns `true` if the node is a function expression or arrow function expression of a class property, `false` otherwise.
|
|
2376
|
-
*/
|
|
2377
|
-
declare function isFunctionOfClassProperty(node: TSESTree.Node): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
|
|
2378
|
-
|
|
2379
|
-
declare function isFunctionOfImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
2380
|
-
|
|
2381
|
-
/**
|
|
2382
|
-
* Checks if the given node is a function expression or arrow function expression of a object method.
|
|
2383
|
-
* @param node The node to check.
|
|
2384
|
-
* @returns `true` if the node is a function expression or arrow function expression of a object method, `false` otherwise.
|
|
2385
|
-
*/
|
|
2386
|
-
declare function isFunctionOfObjectMethod(node: TSESTree.Node): boolean;
|
|
2387
|
-
|
|
2388
2363
|
declare function isKeyLiteralLike(node: TSESTree.MemberExpression | TSESTree.MethodDefinition | TSESTree.Property | TSESTree.PropertyDefinition, property: TSESTree.Node): boolean;
|
|
2389
2364
|
|
|
2365
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "boolean"): node is TSESTree.BooleanLiteral;
|
|
2366
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "null"): node is TSESTree.NullLiteral;
|
|
2367
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "number"): node is TSESTree.NumberLiteral;
|
|
2368
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "regexp"): node is TSESTree.RegExpLiteral;
|
|
2369
|
+
declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is TSESTree.StringLiteral;
|
|
2370
|
+
|
|
2390
2371
|
declare function isMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
|
|
2391
2372
|
|
|
2392
2373
|
/**
|
|
@@ -2408,10 +2389,6 @@ declare const isNodeEqual: {
|
|
|
2408
2389
|
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
2409
2390
|
};
|
|
2410
2391
|
|
|
2411
|
-
declare function isRegExpLiteral(node: TSESTree.Node): node is TSESTree.RegExpLiteral;
|
|
2412
|
-
|
|
2413
|
-
declare function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral;
|
|
2414
|
-
|
|
2415
2392
|
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
2416
2393
|
|
|
2417
2394
|
/**
|
|
@@ -2432,4 +2409,4 @@ type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
|
|
|
2432
2409
|
|
|
2433
2410
|
declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
|
|
2434
2411
|
|
|
2435
|
-
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath,
|
|
2412
|
+
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
|
package/dist/index.js
CHANGED
|
@@ -269,18 +269,6 @@ function getFunctionIdentifier(node) {
|
|
|
269
269
|
}
|
|
270
270
|
return eff._;
|
|
271
271
|
}
|
|
272
|
-
function getIdentifiersFromBinaryExpression(side) {
|
|
273
|
-
if (side.type === types.AST_NODE_TYPES.Identifier) {
|
|
274
|
-
return [side];
|
|
275
|
-
}
|
|
276
|
-
if (side.type === types.AST_NODE_TYPES.BinaryExpression) {
|
|
277
|
-
return [
|
|
278
|
-
...getIdentifiersFromBinaryExpression(side.left),
|
|
279
|
-
...getIdentifiersFromBinaryExpression(side.right)
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
|
-
return [];
|
|
283
|
-
}
|
|
284
272
|
|
|
285
273
|
// src/get-literal-value-type.ts
|
|
286
274
|
function getLiteralValueType(input) {
|
|
@@ -467,31 +455,28 @@ function getTopLevelIdentifier(node) {
|
|
|
467
455
|
function isEmptyFunction(node) {
|
|
468
456
|
return node.body.type === types.AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
|
|
469
457
|
}
|
|
470
|
-
function isFunctionOfClassMethod(node) {
|
|
471
|
-
return (node.type === types.AST_NODE_TYPES.FunctionExpression || node.type === types.AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === types.AST_NODE_TYPES.MethodDefinition;
|
|
472
|
-
}
|
|
473
|
-
function isFunctionOfClassProperty(node) {
|
|
474
|
-
return (node.type === types.AST_NODE_TYPES.FunctionExpression || node.type === types.AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === types.AST_NODE_TYPES.Property;
|
|
475
|
-
}
|
|
476
|
-
function isFunctionOfImmediatelyInvoked(node) {
|
|
477
|
-
return node.type !== types.AST_NODE_TYPES.FunctionDeclaration && node.parent.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
478
|
-
}
|
|
479
|
-
function isFunctionOfObjectMethod(node) {
|
|
480
|
-
return (node.type === types.AST_NODE_TYPES.FunctionExpression || node.type === types.AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === types.AST_NODE_TYPES.Property && node.parent.parent.type === types.AST_NODE_TYPES.ObjectExpression;
|
|
481
|
-
}
|
|
482
458
|
function isKeyLiteralLike(node, property) {
|
|
483
459
|
return tsPattern.match(property).with({ type: types.AST_NODE_TYPES.Literal }, eff.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.constFalse);
|
|
484
460
|
}
|
|
485
|
-
function
|
|
486
|
-
if (node.type !== types.AST_NODE_TYPES.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
461
|
+
function isKindOfLiteral(node, kind) {
|
|
462
|
+
if (node.type !== types.AST_NODE_TYPES.Literal) return false;
|
|
463
|
+
switch (kind) {
|
|
464
|
+
case "boolean":
|
|
465
|
+
return typeof node.value === "boolean";
|
|
466
|
+
case "null":
|
|
467
|
+
return node.value === null;
|
|
468
|
+
case "number":
|
|
469
|
+
return typeof node.value === "number";
|
|
470
|
+
case "regexp":
|
|
471
|
+
return "regex" in node;
|
|
472
|
+
case "string":
|
|
473
|
+
return typeof node.value === "string";
|
|
494
474
|
}
|
|
475
|
+
}
|
|
476
|
+
function isMapCallLoose(node) {
|
|
477
|
+
if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
478
|
+
if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
|
|
479
|
+
if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
|
|
495
480
|
const { name } = node.callee.property;
|
|
496
481
|
return name === "map" || name.endsWith("Map");
|
|
497
482
|
}
|
|
@@ -551,16 +536,8 @@ var isNodeEqual = eff.dual(2, (a, b) => {
|
|
|
551
536
|
return false;
|
|
552
537
|
}
|
|
553
538
|
});
|
|
554
|
-
function isRegExpLiteral(node) {
|
|
555
|
-
return node.type === types.AST_NODE_TYPES.Literal && "regex" in node;
|
|
556
|
-
}
|
|
557
|
-
function isStringLiteral(node) {
|
|
558
|
-
return node.type === types.AST_NODE_TYPES.Literal && typeof node.value === "string";
|
|
559
|
-
}
|
|
560
539
|
function isThisExpression(node) {
|
|
561
|
-
if (isTypeExpression(node))
|
|
562
|
-
return isThisExpression(node.expression);
|
|
563
|
-
}
|
|
540
|
+
if (isTypeExpression(node)) return isThisExpression(node.expression);
|
|
564
541
|
return node.type === types.AST_NODE_TYPES.ThisExpression;
|
|
565
542
|
}
|
|
566
543
|
function toReadableNodeName(node, getText) {
|
|
@@ -610,7 +587,6 @@ exports.findParentNode = findParentNode;
|
|
|
610
587
|
exports.getClassIdentifier = getClassIdentifier;
|
|
611
588
|
exports.getFunctionIdentifier = getFunctionIdentifier;
|
|
612
589
|
exports.getFunctionInitPath = getFunctionInitPath;
|
|
613
|
-
exports.getIdentifiersFromBinaryExpression = getIdentifiersFromBinaryExpression;
|
|
614
590
|
exports.getLiteralValueType = getLiteralValueType;
|
|
615
591
|
exports.getNestedCallExpressions = getNestedCallExpressions;
|
|
616
592
|
exports.getNestedExpressionsOfType = getNestedExpressionsOfType;
|
|
@@ -627,16 +603,13 @@ exports.isControlFlow = isControlFlow;
|
|
|
627
603
|
exports.isDestructuringPattern = isDestructuringPattern;
|
|
628
604
|
exports.isEmptyFunction = isEmptyFunction;
|
|
629
605
|
exports.isFunction = isFunction;
|
|
630
|
-
exports.isFunctionOfClassMethod = isFunctionOfClassMethod;
|
|
631
|
-
exports.isFunctionOfClassProperty = isFunctionOfClassProperty;
|
|
632
|
-
exports.isFunctionOfImmediatelyInvoked = isFunctionOfImmediatelyInvoked;
|
|
633
|
-
exports.isFunctionOfObjectMethod = isFunctionOfObjectMethod;
|
|
634
606
|
exports.isFunctionType = isFunctionType;
|
|
635
607
|
exports.isJSX = isJSX;
|
|
636
608
|
exports.isJSXElement = isJSXElement;
|
|
637
609
|
exports.isJSXFragment = isJSXFragment;
|
|
638
610
|
exports.isJSXTagNameExpression = isJSXTagNameExpression;
|
|
639
611
|
exports.isKeyLiteralLike = isKeyLiteralLike;
|
|
612
|
+
exports.isKindOfLiteral = isKindOfLiteral;
|
|
640
613
|
exports.isLeftHandSideExpression = isLeftHandSideExpression;
|
|
641
614
|
exports.isLeftHandSideExpressionType = isLeftHandSideExpressionType;
|
|
642
615
|
exports.isLoop = isLoop;
|
|
@@ -646,8 +619,6 @@ exports.isMultiLine = isMultiLine;
|
|
|
646
619
|
exports.isNodeEqual = isNodeEqual;
|
|
647
620
|
exports.isOneOf = isOneOf;
|
|
648
621
|
exports.isProperty = isProperty;
|
|
649
|
-
exports.isRegExpLiteral = isRegExpLiteral;
|
|
650
|
-
exports.isStringLiteral = isStringLiteral;
|
|
651
622
|
exports.isThisExpression = isThisExpression;
|
|
652
623
|
exports.isTypeDeclaration = isTypeDeclaration;
|
|
653
624
|
exports.isTypeExpression = isTypeExpression;
|
package/dist/index.mjs
CHANGED
|
@@ -267,18 +267,6 @@ function getFunctionIdentifier(node) {
|
|
|
267
267
|
}
|
|
268
268
|
return _;
|
|
269
269
|
}
|
|
270
|
-
function getIdentifiersFromBinaryExpression(side) {
|
|
271
|
-
if (side.type === AST_NODE_TYPES.Identifier) {
|
|
272
|
-
return [side];
|
|
273
|
-
}
|
|
274
|
-
if (side.type === AST_NODE_TYPES.BinaryExpression) {
|
|
275
|
-
return [
|
|
276
|
-
...getIdentifiersFromBinaryExpression(side.left),
|
|
277
|
-
...getIdentifiersFromBinaryExpression(side.right)
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
return [];
|
|
281
|
-
}
|
|
282
270
|
|
|
283
271
|
// src/get-literal-value-type.ts
|
|
284
272
|
function getLiteralValueType(input) {
|
|
@@ -465,31 +453,28 @@ function getTopLevelIdentifier(node) {
|
|
|
465
453
|
function isEmptyFunction(node) {
|
|
466
454
|
return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
|
|
467
455
|
}
|
|
468
|
-
function isFunctionOfClassMethod(node) {
|
|
469
|
-
return (node.type === AST_NODE_TYPES.FunctionExpression || node.type === AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === AST_NODE_TYPES.MethodDefinition;
|
|
470
|
-
}
|
|
471
|
-
function isFunctionOfClassProperty(node) {
|
|
472
|
-
return (node.type === AST_NODE_TYPES.FunctionExpression || node.type === AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === AST_NODE_TYPES.Property;
|
|
473
|
-
}
|
|
474
|
-
function isFunctionOfImmediatelyInvoked(node) {
|
|
475
|
-
return node.type !== AST_NODE_TYPES.FunctionDeclaration && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
476
|
-
}
|
|
477
|
-
function isFunctionOfObjectMethod(node) {
|
|
478
|
-
return (node.type === AST_NODE_TYPES.FunctionExpression || node.type === AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === AST_NODE_TYPES.Property && node.parent.parent.type === AST_NODE_TYPES.ObjectExpression;
|
|
479
|
-
}
|
|
480
456
|
function isKeyLiteralLike(node, property) {
|
|
481
457
|
return match(property).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(constFalse);
|
|
482
458
|
}
|
|
483
|
-
function
|
|
484
|
-
if (node.type !== AST_NODE_TYPES.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
459
|
+
function isKindOfLiteral(node, kind) {
|
|
460
|
+
if (node.type !== AST_NODE_TYPES.Literal) return false;
|
|
461
|
+
switch (kind) {
|
|
462
|
+
case "boolean":
|
|
463
|
+
return typeof node.value === "boolean";
|
|
464
|
+
case "null":
|
|
465
|
+
return node.value === null;
|
|
466
|
+
case "number":
|
|
467
|
+
return typeof node.value === "number";
|
|
468
|
+
case "regexp":
|
|
469
|
+
return "regex" in node;
|
|
470
|
+
case "string":
|
|
471
|
+
return typeof node.value === "string";
|
|
492
472
|
}
|
|
473
|
+
}
|
|
474
|
+
function isMapCallLoose(node) {
|
|
475
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
476
|
+
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
477
|
+
if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
|
|
493
478
|
const { name } = node.callee.property;
|
|
494
479
|
return name === "map" || name.endsWith("Map");
|
|
495
480
|
}
|
|
@@ -549,16 +534,8 @@ var isNodeEqual = dual(2, (a, b) => {
|
|
|
549
534
|
return false;
|
|
550
535
|
}
|
|
551
536
|
});
|
|
552
|
-
function isRegExpLiteral(node) {
|
|
553
|
-
return node.type === AST_NODE_TYPES.Literal && "regex" in node;
|
|
554
|
-
}
|
|
555
|
-
function isStringLiteral(node) {
|
|
556
|
-
return node.type === AST_NODE_TYPES.Literal && typeof node.value === "string";
|
|
557
|
-
}
|
|
558
537
|
function isThisExpression(node) {
|
|
559
|
-
if (isTypeExpression(node))
|
|
560
|
-
return isThisExpression(node.expression);
|
|
561
|
-
}
|
|
538
|
+
if (isTypeExpression(node)) return isThisExpression(node.expression);
|
|
562
539
|
return node.type === AST_NODE_TYPES.ThisExpression;
|
|
563
540
|
}
|
|
564
541
|
function toReadableNodeName(node, getText) {
|
|
@@ -604,4 +581,4 @@ function unwrapTypeExpression(node) {
|
|
|
604
581
|
return node;
|
|
605
582
|
}
|
|
606
583
|
|
|
607
|
-
export { findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath,
|
|
584
|
+
export { findParentNode, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "1.28.0-next.
|
|
3
|
+
"version": "1.28.0-next.3",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@typescript-eslint/utils": "^8.25.0",
|
|
41
41
|
"string-ts": "^2.2.1",
|
|
42
42
|
"ts-pattern": "^5.6.2",
|
|
43
|
-
"@eslint-react/eff": "1.28.0-next.
|
|
43
|
+
"@eslint-react/eff": "1.28.0-next.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"tsup": "^8.3.6",
|