@eslint-react/ast 5.0.1-next.1 → 5.0.2-beta.0
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.ts +8 -41
- package/dist/index.js +4 -42
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -199,7 +199,7 @@ declare function isDirectiveInFunction(node: TSESTreeFunction, name: string): bo
|
|
|
199
199
|
* where JS gives anonymous function expressions names. We roughly detect the
|
|
200
200
|
* same AST nodes with some exceptions to better fit our use case.
|
|
201
201
|
*/
|
|
202
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.
|
|
202
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | TSESTree.PrivateIdentifier | null;
|
|
203
203
|
/**
|
|
204
204
|
* Type representing the return type of getFunctionId
|
|
205
205
|
*/
|
|
@@ -319,19 +319,19 @@ declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(no
|
|
|
319
319
|
* @param node The node to check
|
|
320
320
|
* @returns True if the node is a function
|
|
321
321
|
*/
|
|
322
|
-
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.
|
|
322
|
+
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;
|
|
323
323
|
/**
|
|
324
324
|
* Check if a node is a function type (including TypeScript function types)
|
|
325
325
|
* @param node The node to check
|
|
326
326
|
* @returns True if the node is a function type
|
|
327
327
|
*/
|
|
328
|
-
declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.
|
|
328
|
+
declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignatureComputedName | TSESTree.TSMethodSignatureNonComputedName;
|
|
329
329
|
/**
|
|
330
330
|
* Check if a node is a class declaration or expression
|
|
331
331
|
* @param node The node to check
|
|
332
332
|
* @returns True if the node is a class
|
|
333
333
|
*/
|
|
334
|
-
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.
|
|
334
|
+
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassExpression | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName;
|
|
335
335
|
/**
|
|
336
336
|
* Check if a node is a method or property definition
|
|
337
337
|
* @param node The node to check
|
|
@@ -374,7 +374,7 @@ declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) =
|
|
|
374
374
|
* @returns True if the node is a JSX node
|
|
375
375
|
* @see TSESTreeJSX
|
|
376
376
|
*/
|
|
377
|
-
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.
|
|
377
|
+
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
378
378
|
/**
|
|
379
379
|
* Check if a node is a loop statement
|
|
380
380
|
* @param node The node to check
|
|
@@ -392,7 +392,7 @@ declare const isControlFlow: (data: TSESTree.Node | null | undefined) => data is
|
|
|
392
392
|
* @param node The node to check
|
|
393
393
|
* @returns True if the node is conditional
|
|
394
394
|
*/
|
|
395
|
-
declare const isConditional: (data: TSESTree.Node | null | undefined) => data is TSESTree.ConditionalExpression | TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.
|
|
395
|
+
declare const isConditional: (data: TSESTree.Node | null | undefined) => data is TSESTree.ConditionalExpression | TSESTree.LogicalExpression | TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
396
396
|
/**
|
|
397
397
|
* Check if a node is a TypeScript type expression
|
|
398
398
|
* @param node The node to check
|
|
@@ -434,7 +434,6 @@ type ObjectDestructuringVariableDeclarator = TSESTree.VariableDeclarator & {
|
|
|
434
434
|
* Represents an assignment expression that assigns to a displayName property
|
|
435
435
|
*/
|
|
436
436
|
type DisplayNameAssignmentExpression = TSESTree.AssignmentExpression & {
|
|
437
|
-
type: "AssignmentExpression";
|
|
438
437
|
left: TSESTree.MemberExpression & {
|
|
439
438
|
property: TSESTree.Identifier & {
|
|
440
439
|
name: "displayName";
|
|
@@ -498,39 +497,7 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null): node is TSESTr
|
|
|
498
497
|
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
499
498
|
//#endregion
|
|
500
499
|
//#region src/pattern-test-mock.d.ts
|
|
501
|
-
|
|
502
|
-
* Check if the given node is a `vi.mock`.
|
|
503
|
-
* @param node The node to check
|
|
504
|
-
* @returns `true` if the node is a `vi.mock`, otherwise `false`.
|
|
505
|
-
* @internal
|
|
506
|
-
*/
|
|
507
|
-
declare function isViMock(node: TSESTree.Node | null): node is TSESTree.MemberExpression;
|
|
508
|
-
/**
|
|
509
|
-
* Check if the given node is a `jest.mock`.
|
|
510
|
-
* @param node The node to check
|
|
511
|
-
* @returns `true` if the node is a `jest.mock`, otherwise `false`.
|
|
512
|
-
* @internal
|
|
513
|
-
*/
|
|
514
|
-
declare function isJestMock(node: TSESTree.Node | null): node is TSESTree.MemberExpression;
|
|
515
|
-
/**
|
|
516
|
-
* Check if the given node is a `vi.mock` callback.
|
|
517
|
-
* @param node The node to check
|
|
518
|
-
* @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
|
|
519
|
-
* @internal
|
|
520
|
-
*/
|
|
521
|
-
declare function isViMockCallback(node: TSESTree.Node | null): boolean;
|
|
522
|
-
/**
|
|
523
|
-
* Check if the given node is a `jest.mock` callback.
|
|
524
|
-
* @param node The node to check
|
|
525
|
-
* @returns `true` if the node is a `jest.mock` callback, otherwise `false`.
|
|
526
|
-
* @internal
|
|
527
|
-
*/
|
|
528
|
-
declare function isJestMockCallback(node: TSESTree.Node | null): boolean;
|
|
529
|
-
/**
|
|
530
|
-
* Check if the given node is a `vi.mock` or `jest.mock` callback.
|
|
531
|
-
* @param node The node to check
|
|
532
|
-
* @returns `true` if the node is a test mock callback, otherwise `false`.
|
|
533
|
-
*/
|
|
500
|
+
declare function isTestMock(node: TSESTree.Node | null): node is TSESTree.MemberExpression;
|
|
534
501
|
declare function isTestMockCallback(node: TSESTree.Node | null): boolean;
|
|
535
502
|
//#endregion
|
|
536
503
|
//#region src/property-name.d.ts
|
|
@@ -553,4 +520,4 @@ declare function getPropertyName(node: TSESTree.Node): string | null;
|
|
|
553
520
|
*/
|
|
554
521
|
declare function findProperty(properties: TSESTree.ObjectLiteralElement[], name: string): TSESTree.Property | null;
|
|
555
522
|
//#endregion
|
|
556
|
-
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeJSXElementLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression,
|
|
523
|
+
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeJSXElementLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isTestMock, isTestMockCallback, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression };
|
package/dist/index.js
CHANGED
|
@@ -926,49 +926,11 @@ function isProcessEnvNodeEnvCompare(node, operator, value) {
|
|
|
926
926
|
|
|
927
927
|
//#endregion
|
|
928
928
|
//#region src/pattern-test-mock.ts
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
* @param node The node to check
|
|
932
|
-
* @returns `true` if the node is a `vi.mock`, otherwise `false`.
|
|
933
|
-
* @internal
|
|
934
|
-
*/
|
|
935
|
-
function isViMock(node) {
|
|
936
|
-
return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.object.name === "vi" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "mock";
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* Check if the given node is a `jest.mock`.
|
|
940
|
-
* @param node The node to check
|
|
941
|
-
* @returns `true` if the node is a `jest.mock`, otherwise `false`.
|
|
942
|
-
* @internal
|
|
943
|
-
*/
|
|
944
|
-
function isJestMock(node) {
|
|
945
|
-
return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.object.name === "jest" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "mock";
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Check if the given node is a `vi.mock` callback.
|
|
949
|
-
* @param node The node to check
|
|
950
|
-
* @returns `true` if the node is a `vi.mock` callback, otherwise `false`.
|
|
951
|
-
* @internal
|
|
952
|
-
*/
|
|
953
|
-
function isViMockCallback(node) {
|
|
954
|
-
return node != null && isFunction(node) && node.parent.type === AST_NODE_TYPES.CallExpression && isViMock(node.parent.callee) && node.parent.arguments[1] === node;
|
|
929
|
+
function isTestMock(node) {
|
|
930
|
+
return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "mock";
|
|
955
931
|
}
|
|
956
|
-
/**
|
|
957
|
-
* Check if the given node is a `jest.mock` callback.
|
|
958
|
-
* @param node The node to check
|
|
959
|
-
* @returns `true` if the node is a `jest.mock` callback, otherwise `false`.
|
|
960
|
-
* @internal
|
|
961
|
-
*/
|
|
962
|
-
function isJestMockCallback(node) {
|
|
963
|
-
return node != null && isFunction(node) && node.parent.type === AST_NODE_TYPES.CallExpression && isJestMock(node.parent.callee) && node.parent.arguments[1] === node;
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Check if the given node is a `vi.mock` or `jest.mock` callback.
|
|
967
|
-
* @param node The node to check
|
|
968
|
-
* @returns `true` if the node is a test mock callback, otherwise `false`.
|
|
969
|
-
*/
|
|
970
932
|
function isTestMockCallback(node) {
|
|
971
|
-
return
|
|
933
|
+
return node != null && isFunction(node) && node.parent.type === AST_NODE_TYPES.CallExpression && isTestMock(node.parent.callee) && node.parent.arguments[1] === node;
|
|
972
934
|
}
|
|
973
935
|
|
|
974
936
|
//#endregion
|
|
@@ -1009,4 +971,4 @@ function findProperty(properties, name) {
|
|
|
1009
971
|
}
|
|
1010
972
|
|
|
1011
973
|
//#endregion
|
|
1012
|
-
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression,
|
|
974
|
+
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isTestMock, isTestMockCallback, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression };
|