@eslint-react/ast 5.27.0 → 5.27.2
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 +35 -29
- package/dist/index.js +75 -58
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,25 +4,27 @@ import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
|
|
|
4
4
|
type TSESTreeFunction = TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
|
|
5
5
|
/** Union of class-like node types. */
|
|
6
6
|
type TSESTreeClass = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
|
|
7
|
+
/** Union of function-like and class-like node types. */
|
|
8
|
+
type TSESTreeFunctionOrClass = TSESTreeFunction | TSESTreeClass;
|
|
7
9
|
/** Union of method and property definition node types. */
|
|
8
10
|
type TSESTreeMethodOrPropertyDefinition = TSESTree.PropertyDefinition | TSESTree.MethodDefinition;
|
|
11
|
+
/** An expression statement that is a directive (ex: `"use strict"`). */
|
|
12
|
+
type TSESTreeDirective = TSESTree.ExpressionStatement & {
|
|
13
|
+
directive: string;
|
|
14
|
+
expression: TSESTree.StringLiteral;
|
|
15
|
+
};
|
|
9
16
|
/** Union of all JSX-related node types. */
|
|
10
17
|
type TSESTreeJSX = TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
11
18
|
/** Union of JSX element-like node types (element or fragment). */
|
|
12
19
|
type TSESTreeJSXElementLike = TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
13
20
|
/** Union of JSX attribute-like node types (attribute or spread attribute). */
|
|
14
21
|
type TSESTreeJSXAttributeLike = TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute;
|
|
15
|
-
/** An expression statement that is a directive (ex: `"use strict"`). */
|
|
16
|
-
type TSESTreeDirective = TSESTree.ExpressionStatement & {
|
|
17
|
-
directive: string;
|
|
18
|
-
expression: TSESTree.StringLiteral;
|
|
19
|
-
};
|
|
20
22
|
/** Union of TypeScript type expression node types. */
|
|
21
23
|
type TSESTreeTypeExpression = TSESTree.TSAsExpression | TSESTree.TSTypeAssertion | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSInstantiationExpression;
|
|
22
|
-
/**
|
|
23
|
-
type
|
|
24
|
+
/** Union of expression node types that wrap another expression (TypeScript type expressions and chain expressions) — the nodes `Extract.unwrap` strips. */
|
|
25
|
+
type TSESTreeTypeOrChainExpression = TSESTreeTypeExpression | TSESTree.ChainExpression;
|
|
24
26
|
declare namespace check_d_exports {
|
|
25
|
-
export { is, isCallExpression, isClass, isConditional, isDirective, isExpression, isFunction, isIdentifier, isJSX, isJSXElement, isJSXElementOrFragment, isJSXExpressionContainer, isJSXFragment, isJSXSpreadAttribute, isJSXTagNameExpression, isMemberExpression, isObjectExpression, isOneOf, isProperty, isPropertyOrMethod, isReturnStatement, isTypeAssertionExpression, isTypeExpression };
|
|
27
|
+
export { is, isCallExpression, isClass, isConditional, isDirective, isExpression, isFunction, isFunctionOrClass, isIdentifier, isJSX, isJSXElement, isJSXElementOrFragment, isJSXExpressionContainer, isJSXFragment, isJSXSpreadAttribute, isJSXTagNameExpression, isMemberExpression, isObjectExpression, isOneOf, isProperty, isPropertyOrMethod, isReturnStatement, isTypeAssertionExpression, isTypeExpression, isTypeOrChainExpression };
|
|
26
28
|
}
|
|
27
29
|
/** Check if a node is of the given type. */
|
|
28
30
|
declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
@@ -32,13 +34,6 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
|
|
|
32
34
|
declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
33
35
|
type: NodeTypes[number];
|
|
34
36
|
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Check if a node is a directive statement (ex: `"use client"`), optionally matching a specific directive name.
|
|
37
|
-
* @param node The node to check.
|
|
38
|
-
* @param name The directive name to match. When omitted, any directive matches.
|
|
39
|
-
* @returns `true` if the node is a matching directive statement.
|
|
40
|
-
*/
|
|
41
|
-
declare function isDirective(node: TSESTree.Node, name?: string): node is TSESTreeDirective;
|
|
42
37
|
/**
|
|
43
38
|
* Check if a node is an identifier, optionally matching a specific name.
|
|
44
39
|
* @param node The node to check.
|
|
@@ -46,44 +41,55 @@ declare function isDirective(node: TSESTree.Node, name?: string): node is TSESTr
|
|
|
46
41
|
* @returns `true` if the node is a matching identifier.
|
|
47
42
|
*/
|
|
48
43
|
declare function isIdentifier(node: TSESTree.Node, name?: string): node is TSESTree.Identifier;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a node is a directive statement (ex: `"use client"`), optionally matching a specific directive name.
|
|
46
|
+
* @param node The node to check.
|
|
47
|
+
* @param name The directive name to match. When omitted, any directive matches.
|
|
48
|
+
* @returns `true` if the node is a matching directive statement.
|
|
49
|
+
*/
|
|
50
|
+
declare function isDirective(node: TSESTree.Node, name?: string): node is TSESTreeDirective;
|
|
49
51
|
/** Check if a node is a call expression. */
|
|
50
52
|
declare const isCallExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.CallExpression;
|
|
51
53
|
/** Check if a node is a member expression. */
|
|
52
54
|
declare const isMemberExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName;
|
|
53
55
|
/** Check if a node is an object expression. */
|
|
54
56
|
declare const isObjectExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ObjectExpression;
|
|
57
|
+
/** Check if a node is an expression node. */
|
|
58
|
+
declare const isExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | 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.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | 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.YieldNoStarExpression | TSESTree.YieldStarExpression;
|
|
55
59
|
/** Check if a node is a return statement. */
|
|
56
60
|
declare const isReturnStatement: (node: TSESTree.Node | null | undefined) => node is TSESTree.ReturnStatement;
|
|
57
61
|
/** Check if a node is a class declaration or class expression. */
|
|
58
62
|
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
|
|
59
63
|
/** Check if a node is a function declaration, function expression, or arrow function expression. */
|
|
60
64
|
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
65
|
+
/** Check if a node is a function declaration, function expression, arrow function expression, class declaration, or class expression. */
|
|
66
|
+
declare const isFunctionOrClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
61
67
|
/** Check if a node is a property-like node (property definition, index signature, parameter property, or property signature). */
|
|
62
68
|
declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
|
|
63
69
|
/** Check if a node is a property or method definition. */
|
|
64
70
|
declare const isPropertyOrMethod: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
|
|
71
|
+
/** Check if a node is a conditional expression or a control flow statement. */
|
|
72
|
+
declare const isConditional: (node: TSESTree.Node | null | undefined) => node is TSESTree.ConditionalExpression | TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.LogicalExpression | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
73
|
+
/** Check if a node is any JSX-related node. */
|
|
74
|
+
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
65
75
|
/** Check if a node is a JSX element. */
|
|
66
76
|
declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
|
|
67
|
-
/** Check if a node is a JSX expression container. */
|
|
68
|
-
declare const isJSXExpressionContainer: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXExpressionContainer;
|
|
69
|
-
/** Check if a node is a JSX spread attribute. */
|
|
70
|
-
declare const isJSXSpreadAttribute: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXSpreadAttribute;
|
|
71
77
|
/** Check if a node is a JSX fragment. */
|
|
72
78
|
declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
|
|
73
79
|
/** Check if a node is a JSX element or JSX fragment. */
|
|
74
80
|
declare const isJSXElementOrFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
81
|
+
/** Check if a node is a JSX expression container. */
|
|
82
|
+
declare const isJSXExpressionContainer: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXExpressionContainer;
|
|
83
|
+
/** Check if a node is a JSX spread attribute. */
|
|
84
|
+
declare const isJSXSpreadAttribute: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXSpreadAttribute;
|
|
75
85
|
/** Check if a node can appear as a JSX tag name. */
|
|
76
86
|
declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
|
|
77
|
-
/** Check if a node is any JSX-related node. */
|
|
78
|
-
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
79
87
|
/** Check if a node is a TypeScript type expression (assertion, non-null, satisfies, or instantiation). */
|
|
80
88
|
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
81
89
|
/** Check if a node is a TypeScript type assertion-like expression (as, assertion, non-null, or satisfies). */
|
|
82
90
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
83
|
-
/** Check if a node is
|
|
84
|
-
declare const
|
|
85
|
-
/** Check if a node is a conditional expression or a control flow statement. */
|
|
86
|
-
declare const isConditional: (node: TSESTree.Node | null | undefined) => node is TSESTree.ConditionalExpression | TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.LogicalExpression | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
91
|
+
/** Check if a node is a TypeScript type expression or a chain expression (i.e. a transparent wrapper around an inner expression). */
|
|
92
|
+
declare const isTypeOrChainExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ChainExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
87
93
|
declare namespace compare_d_exports {
|
|
88
94
|
export { isEqual };
|
|
89
95
|
}
|
|
@@ -106,8 +112,8 @@ declare namespace extract_d_exports {
|
|
|
106
112
|
* @param node The node to unwrap.
|
|
107
113
|
* @returns The innermost non-type-expression node — a reference into the original tree, never a copy.
|
|
108
114
|
*/
|
|
109
|
-
declare function unwrap(node:
|
|
110
|
-
declare function unwrap<T extends TSESTree.Node>(node: T):
|
|
115
|
+
declare function unwrap(node: TSESTreeTypeOrChainExpression): Exclude<TSESTree.Expression, TSESTreeTypeOrChainExpression>;
|
|
116
|
+
declare function unwrap<T extends TSESTree.Node>(node: T): Exclude<T, TSESTreeTypeOrChainExpression>;
|
|
111
117
|
/**
|
|
112
118
|
* Find a property by name in a list of object literal properties, recursing into spread object expressions.
|
|
113
119
|
* @param properties The object literal properties to search.
|
|
@@ -127,7 +133,7 @@ declare function getCalleeName(node: TSESTree.CallExpression): string | null;
|
|
|
127
133
|
* @param node The expression to inspect.
|
|
128
134
|
* @returns The base node followed by each member property in access order.
|
|
129
135
|
*/
|
|
130
|
-
declare function getMemberChain(node: TSESTree.Expression | TSESTree.PrivateIdentifier): (TSESTree.AccessorProperty | TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AssignmentPattern | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.BlockStatement | TSESTree.BreakStatement | TSESTree.CallExpression | TSESTree.CatchClause | TSESTree.
|
|
136
|
+
declare function getMemberChain(node: TSESTree.Expression | TSESTree.PrivateIdentifier): (TSESTree.AccessorProperty | TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AssignmentPattern | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.BlockStatement | TSESTree.BreakStatement | TSESTree.CallExpression | TSESTree.CatchClause | TSESTree.ClassBody | TSESTree.ClassDeclaration | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.ContinueStatement | TSESTree.DebuggerStatement | TSESTree.Decorator | TSESTree.DoWhileStatement | TSESTree.EmptyStatement | TSESTree.ExportAllDeclaration | TSESTree.ExportDefaultDeclaration | TSESTree.ExportNamedDeclaration | TSESTree.ExportSpecifier | TSESTree.ExpressionStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.IfStatement | TSESTree.ImportAttribute | TSESTree.ImportDeclaration | TSESTree.ImportDefaultSpecifier | TSESTree.ImportExpression | TSESTree.ImportNamespaceSpecifier | TSESTree.ImportSpecifier | TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText | TSESTree.LabeledStatement | TSESTree.Literal | TSESTree.LogicalExpression | TSESTree.MemberExpression | TSESTree.MetaProperty | TSESTree.MethodDefinition | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.Program | TSESTree.Property | TSESTree.PropertyDefinition | TSESTree.RestElement | TSESTree.ReturnStatement | TSESTree.SequenceExpression | TSESTree.SpreadElement | TSESTree.StaticBlock | TSESTree.Super | TSESTree.SwitchCase | TSESTree.SwitchStatement | TSESTree.TaggedTemplateExpression | TSESTree.TemplateElement | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.ThrowStatement | TSESTree.TryStatement | TSESTree.TSAbstractAccessorProperty | TSESTree.TSAbstractKeyword | TSESTree.TSAbstractMethodDefinition | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSAnyKeyword | TSESTree.TSArrayType | TSESTree.TSAsyncKeyword | TSESTree.TSBigIntKeyword | TSESTree.TSBooleanKeyword | TSESTree.TSCallSignatureDeclaration | TSESTree.TSClassImplements | TSESTree.TSConditionalType | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunction | TSESTree.TSDeclareKeyword | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSEnumBody | TSESTree.TSEnumDeclaration | TSESTree.TSEnumMember | TSESTree.TSExportAssignment | TSESTree.TSExportKeyword | TSESTree.TSExternalModuleReference | TSESTree.TSFunctionType | TSESTree.TSImportEqualsDeclaration | TSESTree.TSImportType | TSESTree.TSIndexedAccessType | TSESTree.TSIndexSignature | TSESTree.TSInferType | TSESTree.TSInterfaceBody | TSESTree.TSInterfaceDeclaration | TSESTree.TSInterfaceHeritage | TSESTree.TSIntersectionType | TSESTree.TSIntrinsicKeyword | TSESTree.TSLiteralType | TSESTree.TSMappedType | TSESTree.TSMethodSignature | TSESTree.TSModuleBlock | TSESTree.TSModuleDeclaration | TSESTree.TSNamedTupleMember | TSESTree.TSNamespaceExportDeclaration | TSESTree.TSNeverKeyword | TSESTree.TSNullKeyword | TSESTree.TSNumberKeyword | TSESTree.TSObjectKeyword | TSESTree.TSOptionalType | TSESTree.TSParameterProperty | TSESTree.TSPrivateKeyword | TSESTree.TSPropertySignature | TSESTree.TSProtectedKeyword | TSESTree.TSPublicKeyword | TSESTree.TSQualifiedName | TSESTree.TSReadonlyKeyword | TSESTree.TSRestType | TSESTree.TSStaticKeyword | TSESTree.TSStringKeyword | TSESTree.TSSymbolKeyword | TSESTree.TSTemplateLiteralType | TSESTree.TSThisType | TSESTree.TSTupleType | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeAnnotation | TSESTree.TSTypeLiteral | TSESTree.TSTypeOperator | TSESTree.TSTypeParameter | TSESTree.TSTypeParameterDeclaration | TSESTree.TSTypeParameterInstantiation | TSESTree.TSTypePredicate | TSESTree.TSTypeQuery | TSESTree.TSTypeReference | TSESTree.TSUndefinedKeyword | TSESTree.TSUnionType | TSESTree.TSUnknownKeyword | TSESTree.TSVoidKeyword | TSESTree.UnaryExpression | TSESTree.UpdateExpression | TSESTree.VariableDeclaration | TSESTree.VariableDeclarator | TSESTree.WhileStatement | TSESTree.WithStatement | TSESTree.YieldExpression)[];
|
|
131
137
|
/**
|
|
132
138
|
* Collect every write target of an assignment or loop target, expanding
|
|
133
139
|
* destructuring patterns such as `[local, globalValue] = source` or
|
|
@@ -187,4 +193,4 @@ declare function findEnclosingTryBlock(node: TSESTree.Node): TSESTree.TryStateme
|
|
|
187
193
|
*/
|
|
188
194
|
declare function hasEnclosingTryBlock(node: TSESTree.Node): boolean;
|
|
189
195
|
//#endregion
|
|
190
|
-
export { check_d_exports as Check, compare_d_exports as Compare, extract_d_exports as Extract, type TSESTreeClass, type TSESTreeDirective, type TSESTreeFunction, type TSESTreeJSX, type TSESTreeJSXAttributeLike, type TSESTreeJSXElementLike, type TSESTreeMethodOrPropertyDefinition, type TSESTreeTypeExpression, type
|
|
196
|
+
export { check_d_exports as Check, compare_d_exports as Compare, extract_d_exports as Extract, type TSESTreeClass, type TSESTreeDirective, type TSESTreeFunction, type TSESTreeFunctionOrClass, type TSESTreeJSX, type TSESTreeJSXAttributeLike, type TSESTreeJSXElementLike, type TSESTreeMethodOrPropertyDefinition, type TSESTreeTypeExpression, type TSESTreeTypeOrChainExpression, traverse_d_exports as Traverse };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var check_exports = /* @__PURE__ */ __exportAll({
|
|
|
10
10
|
isDirective: () => isDirective,
|
|
11
11
|
isExpression: () => isExpression,
|
|
12
12
|
isFunction: () => isFunction$1,
|
|
13
|
+
isFunctionOrClass: () => isFunctionOrClass,
|
|
13
14
|
isIdentifier: () => isIdentifier,
|
|
14
15
|
isJSX: () => isJSX,
|
|
15
16
|
isJSXElement: () => isJSXElement,
|
|
@@ -25,19 +26,57 @@ var check_exports = /* @__PURE__ */ __exportAll({
|
|
|
25
26
|
isPropertyOrMethod: () => isPropertyOrMethod,
|
|
26
27
|
isReturnStatement: () => isReturnStatement,
|
|
27
28
|
isTypeAssertionExpression: () => isTypeAssertionExpression,
|
|
28
|
-
isTypeExpression: () => isTypeExpression
|
|
29
|
+
isTypeExpression: () => isTypeExpression,
|
|
30
|
+
isTypeOrChainExpression: () => isTypeOrChainExpression
|
|
29
31
|
});
|
|
30
32
|
const is = ASTUtils.isNodeOfType;
|
|
31
33
|
const isOneOf = ASTUtils.isNodeOfTypes;
|
|
32
|
-
function isDirective(node, name) {
|
|
33
|
-
return node.type === AST_NODE_TYPES.ExpressionStatement && (name == null || node.directive === name);
|
|
34
|
-
}
|
|
35
34
|
function isIdentifier(node, name) {
|
|
36
35
|
return node.type === AST_NODE_TYPES.Identifier && (name == null || node.name === name);
|
|
37
36
|
}
|
|
37
|
+
function isDirective(node, name) {
|
|
38
|
+
return node.type === AST_NODE_TYPES.ExpressionStatement && (name == null || node.directive === name);
|
|
39
|
+
}
|
|
38
40
|
const isCallExpression = is(AST_NODE_TYPES.CallExpression);
|
|
39
41
|
const isMemberExpression = is(AST_NODE_TYPES.MemberExpression);
|
|
40
42
|
const isObjectExpression = is(AST_NODE_TYPES.ObjectExpression);
|
|
43
|
+
const isExpression = isOneOf([
|
|
44
|
+
AST_NODE_TYPES.ArrayExpression,
|
|
45
|
+
AST_NODE_TYPES.ArrayPattern,
|
|
46
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
47
|
+
AST_NODE_TYPES.AssignmentExpression,
|
|
48
|
+
AST_NODE_TYPES.AwaitExpression,
|
|
49
|
+
AST_NODE_TYPES.BinaryExpression,
|
|
50
|
+
AST_NODE_TYPES.CallExpression,
|
|
51
|
+
AST_NODE_TYPES.ChainExpression,
|
|
52
|
+
AST_NODE_TYPES.ClassExpression,
|
|
53
|
+
AST_NODE_TYPES.ConditionalExpression,
|
|
54
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
55
|
+
AST_NODE_TYPES.Identifier,
|
|
56
|
+
AST_NODE_TYPES.ImportExpression,
|
|
57
|
+
AST_NODE_TYPES.JSXElement,
|
|
58
|
+
AST_NODE_TYPES.JSXFragment,
|
|
59
|
+
AST_NODE_TYPES.Literal,
|
|
60
|
+
AST_NODE_TYPES.LogicalExpression,
|
|
61
|
+
AST_NODE_TYPES.MemberExpression,
|
|
62
|
+
AST_NODE_TYPES.MetaProperty,
|
|
63
|
+
AST_NODE_TYPES.NewExpression,
|
|
64
|
+
AST_NODE_TYPES.ObjectExpression,
|
|
65
|
+
AST_NODE_TYPES.ObjectPattern,
|
|
66
|
+
AST_NODE_TYPES.SequenceExpression,
|
|
67
|
+
AST_NODE_TYPES.Super,
|
|
68
|
+
AST_NODE_TYPES.TSAsExpression,
|
|
69
|
+
AST_NODE_TYPES.TSInstantiationExpression,
|
|
70
|
+
AST_NODE_TYPES.TSNonNullExpression,
|
|
71
|
+
AST_NODE_TYPES.TSSatisfiesExpression,
|
|
72
|
+
AST_NODE_TYPES.TSTypeAssertion,
|
|
73
|
+
AST_NODE_TYPES.TaggedTemplateExpression,
|
|
74
|
+
AST_NODE_TYPES.TemplateLiteral,
|
|
75
|
+
AST_NODE_TYPES.ThisExpression,
|
|
76
|
+
AST_NODE_TYPES.UnaryExpression,
|
|
77
|
+
AST_NODE_TYPES.UpdateExpression,
|
|
78
|
+
AST_NODE_TYPES.YieldExpression
|
|
79
|
+
]);
|
|
41
80
|
const isReturnStatement = is(AST_NODE_TYPES.ReturnStatement);
|
|
42
81
|
const isClass = isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]);
|
|
43
82
|
const isFunction$1 = isOneOf([
|
|
@@ -45,6 +84,13 @@ const isFunction$1 = isOneOf([
|
|
|
45
84
|
AST_NODE_TYPES.FunctionDeclaration,
|
|
46
85
|
AST_NODE_TYPES.FunctionExpression
|
|
47
86
|
]);
|
|
87
|
+
const isFunctionOrClass = isOneOf([
|
|
88
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
89
|
+
AST_NODE_TYPES.FunctionDeclaration,
|
|
90
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
91
|
+
AST_NODE_TYPES.ClassDeclaration,
|
|
92
|
+
AST_NODE_TYPES.ClassExpression
|
|
93
|
+
]);
|
|
48
94
|
const isProperty = isOneOf([
|
|
49
95
|
AST_NODE_TYPES.PropertyDefinition,
|
|
50
96
|
AST_NODE_TYPES.TSIndexSignature,
|
|
@@ -52,15 +98,16 @@ const isProperty = isOneOf([
|
|
|
52
98
|
AST_NODE_TYPES.TSPropertySignature
|
|
53
99
|
]);
|
|
54
100
|
const isPropertyOrMethod = isOneOf([AST_NODE_TYPES.PropertyDefinition, AST_NODE_TYPES.MethodDefinition]);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
AST_NODE_TYPES.
|
|
62
|
-
AST_NODE_TYPES.
|
|
63
|
-
AST_NODE_TYPES.
|
|
101
|
+
const isConditional = isOneOf([
|
|
102
|
+
AST_NODE_TYPES.DoWhileStatement,
|
|
103
|
+
AST_NODE_TYPES.ForInStatement,
|
|
104
|
+
AST_NODE_TYPES.ForOfStatement,
|
|
105
|
+
AST_NODE_TYPES.ForStatement,
|
|
106
|
+
AST_NODE_TYPES.WhileStatement,
|
|
107
|
+
AST_NODE_TYPES.IfStatement,
|
|
108
|
+
AST_NODE_TYPES.SwitchStatement,
|
|
109
|
+
AST_NODE_TYPES.LogicalExpression,
|
|
110
|
+
AST_NODE_TYPES.ConditionalExpression
|
|
64
111
|
]);
|
|
65
112
|
const isJSX = isOneOf([
|
|
66
113
|
AST_NODE_TYPES.JSXAttribute,
|
|
@@ -79,6 +126,16 @@ const isJSX = isOneOf([
|
|
|
79
126
|
AST_NODE_TYPES.JSXSpreadChild,
|
|
80
127
|
AST_NODE_TYPES.JSXText
|
|
81
128
|
]);
|
|
129
|
+
const isJSXElement = is(AST_NODE_TYPES.JSXElement);
|
|
130
|
+
const isJSXFragment = is(AST_NODE_TYPES.JSXFragment);
|
|
131
|
+
const isJSXElementOrFragment = isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment]);
|
|
132
|
+
const isJSXExpressionContainer = is(AST_NODE_TYPES.JSXExpressionContainer);
|
|
133
|
+
const isJSXSpreadAttribute = is(AST_NODE_TYPES.JSXSpreadAttribute);
|
|
134
|
+
const isJSXTagNameExpression = isOneOf([
|
|
135
|
+
AST_NODE_TYPES.JSXIdentifier,
|
|
136
|
+
AST_NODE_TYPES.JSXMemberExpression,
|
|
137
|
+
AST_NODE_TYPES.JSXNamespacedName
|
|
138
|
+
]);
|
|
82
139
|
const isTypeExpression = isOneOf([
|
|
83
140
|
AST_NODE_TYPES.TSAsExpression,
|
|
84
141
|
AST_NODE_TYPES.TSTypeAssertion,
|
|
@@ -92,53 +149,13 @@ const isTypeAssertionExpression = isOneOf([
|
|
|
92
149
|
AST_NODE_TYPES.TSNonNullExpression,
|
|
93
150
|
AST_NODE_TYPES.TSSatisfiesExpression
|
|
94
151
|
]);
|
|
95
|
-
const
|
|
96
|
-
AST_NODE_TYPES.ArrayExpression,
|
|
97
|
-
AST_NODE_TYPES.ArrayPattern,
|
|
98
|
-
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
99
|
-
AST_NODE_TYPES.AssignmentExpression,
|
|
100
|
-
AST_NODE_TYPES.AwaitExpression,
|
|
101
|
-
AST_NODE_TYPES.BinaryExpression,
|
|
102
|
-
AST_NODE_TYPES.CallExpression,
|
|
103
|
-
AST_NODE_TYPES.ChainExpression,
|
|
104
|
-
AST_NODE_TYPES.ClassExpression,
|
|
105
|
-
AST_NODE_TYPES.ConditionalExpression,
|
|
106
|
-
AST_NODE_TYPES.FunctionExpression,
|
|
107
|
-
AST_NODE_TYPES.Identifier,
|
|
108
|
-
AST_NODE_TYPES.ImportExpression,
|
|
109
|
-
AST_NODE_TYPES.JSXElement,
|
|
110
|
-
AST_NODE_TYPES.JSXFragment,
|
|
111
|
-
AST_NODE_TYPES.Literal,
|
|
112
|
-
AST_NODE_TYPES.LogicalExpression,
|
|
113
|
-
AST_NODE_TYPES.MemberExpression,
|
|
114
|
-
AST_NODE_TYPES.MetaProperty,
|
|
115
|
-
AST_NODE_TYPES.NewExpression,
|
|
116
|
-
AST_NODE_TYPES.ObjectExpression,
|
|
117
|
-
AST_NODE_TYPES.ObjectPattern,
|
|
118
|
-
AST_NODE_TYPES.SequenceExpression,
|
|
119
|
-
AST_NODE_TYPES.Super,
|
|
152
|
+
const isTypeOrChainExpression = isOneOf([
|
|
120
153
|
AST_NODE_TYPES.TSAsExpression,
|
|
121
|
-
AST_NODE_TYPES.
|
|
154
|
+
AST_NODE_TYPES.TSTypeAssertion,
|
|
122
155
|
AST_NODE_TYPES.TSNonNullExpression,
|
|
123
156
|
AST_NODE_TYPES.TSSatisfiesExpression,
|
|
124
|
-
AST_NODE_TYPES.
|
|
125
|
-
AST_NODE_TYPES.
|
|
126
|
-
AST_NODE_TYPES.TemplateLiteral,
|
|
127
|
-
AST_NODE_TYPES.ThisExpression,
|
|
128
|
-
AST_NODE_TYPES.UnaryExpression,
|
|
129
|
-
AST_NODE_TYPES.UpdateExpression,
|
|
130
|
-
AST_NODE_TYPES.YieldExpression
|
|
131
|
-
]);
|
|
132
|
-
const isConditional = isOneOf([
|
|
133
|
-
AST_NODE_TYPES.DoWhileStatement,
|
|
134
|
-
AST_NODE_TYPES.ForInStatement,
|
|
135
|
-
AST_NODE_TYPES.ForOfStatement,
|
|
136
|
-
AST_NODE_TYPES.ForStatement,
|
|
137
|
-
AST_NODE_TYPES.WhileStatement,
|
|
138
|
-
AST_NODE_TYPES.IfStatement,
|
|
139
|
-
AST_NODE_TYPES.SwitchStatement,
|
|
140
|
-
AST_NODE_TYPES.LogicalExpression,
|
|
141
|
-
AST_NODE_TYPES.ConditionalExpression
|
|
157
|
+
AST_NODE_TYPES.TSInstantiationExpression,
|
|
158
|
+
AST_NODE_TYPES.ChainExpression
|
|
142
159
|
]);
|
|
143
160
|
//#endregion
|
|
144
161
|
//#region ../../.pkgs/eff/dist/index.js
|
|
@@ -247,7 +264,7 @@ var extract_exports = /* @__PURE__ */ __exportAll({
|
|
|
247
264
|
unwrap: () => unwrap
|
|
248
265
|
});
|
|
249
266
|
function unwrap(node) {
|
|
250
|
-
if (
|
|
267
|
+
if (isTypeOrChainExpression(node)) return unwrap(node.expression);
|
|
251
268
|
return node;
|
|
252
269
|
}
|
|
253
270
|
function findProperty(properties, name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "5.27.
|
|
3
|
+
"version": "5.27.2",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"@local/configs": "0.0.0",
|
|
38
38
|
"@local/eff": "0.0.0",
|
|
39
39
|
"@local/testkit": "0.0.0",
|
|
40
|
+
"@tsconfig/node20": "^20.1.10",
|
|
41
|
+
"@types/node": "^20.19.43",
|
|
40
42
|
"eslint": "^10.12.0",
|
|
41
43
|
"tsdown": "^0.23.1",
|
|
42
44
|
"typescript": "6.0.3",
|