@eslint-react/ast 5.20.1 → 5.20.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.ts +6 -13
- package/dist/index.js +14 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ declare const isEqual: {
|
|
|
85
85
|
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
86
86
|
};
|
|
87
87
|
declare namespace extract_d_exports {
|
|
88
|
-
export { findProperty, getCalleeName, getFullyQualifiedName,
|
|
88
|
+
export { findProperty, getCalleeName, getFullyQualifiedName, getMemberChain, getPropertyName, unwrap };
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Recursively unwrap TypeScript type expressions and chain expressions to get the underlying expression.
|
|
@@ -107,12 +107,12 @@ declare function findProperty(properties: TSESTree.ObjectLiteralElement[], name:
|
|
|
107
107
|
*/
|
|
108
108
|
declare function getCalleeName(node: TSESTree.CallExpression): string | null;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
* Type expressions and chain expressions
|
|
112
|
-
* @param node The
|
|
113
|
-
* @returns The
|
|
110
|
+
* Get the member chain of an expression (ex: `[a, b, c]` for `a.b.c`), starting from the base object.
|
|
111
|
+
* Type expressions and chain expressions are unwrapped along the way.
|
|
112
|
+
* @param node The expression to inspect.
|
|
113
|
+
* @returns The base node followed by each member property in access order.
|
|
114
114
|
*/
|
|
115
|
-
declare function
|
|
115
|
+
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.ChainExpression | 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)[];
|
|
116
116
|
/**
|
|
117
117
|
* Get the static name of an object property's key.
|
|
118
118
|
* @param property The property to inspect.
|
|
@@ -127,13 +127,6 @@ declare function getPropertyName(property: TSESTree.Property, effort?: "min" | "
|
|
|
127
127
|
* @returns The fully qualified name.
|
|
128
128
|
*/
|
|
129
129
|
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
130
|
-
/**
|
|
131
|
-
* Get the identifier at a given position in a member expression chain (ex: position `0` in `a.b.c` is `a`).
|
|
132
|
-
* @param node The expression to walk.
|
|
133
|
-
* @param position The position of the identifier to return.
|
|
134
|
-
* @returns The identifier at the given position, or `null` when there is none.
|
|
135
|
-
*/
|
|
136
|
-
declare function getIdentifierAt(node: TSESTree.Expression | TSESTree.PrivateIdentifier, position: number): TSESTree.Identifier | null;
|
|
137
130
|
declare namespace traverse_d_exports {
|
|
138
131
|
export { findEnclosingTryBlock, findParent };
|
|
139
132
|
}
|
package/dist/index.js
CHANGED
|
@@ -637,8 +637,7 @@ var extract_exports = /* @__PURE__ */ __exportAll({
|
|
|
637
637
|
findProperty: () => findProperty,
|
|
638
638
|
getCalleeName: () => getCalleeName,
|
|
639
639
|
getFullyQualifiedName: () => getFullyQualifiedName,
|
|
640
|
-
|
|
641
|
-
getInnermostCall: () => getInnermostCall,
|
|
640
|
+
getMemberChain: () => getMemberChain,
|
|
642
641
|
getPropertyName: () => getPropertyName,
|
|
643
642
|
unwrap: () => unwrap
|
|
644
643
|
});
|
|
@@ -679,19 +678,21 @@ function getCalleeName(node) {
|
|
|
679
678
|
return null;
|
|
680
679
|
}
|
|
681
680
|
/**
|
|
682
|
-
*
|
|
683
|
-
* Type expressions and chain expressions
|
|
684
|
-
* @param node The
|
|
685
|
-
* @returns The
|
|
681
|
+
* Get the member chain of an expression (ex: `[a, b, c]` for `a.b.c`), starting from the base object.
|
|
682
|
+
* Type expressions and chain expressions are unwrapped along the way.
|
|
683
|
+
* @param node The expression to inspect.
|
|
684
|
+
* @returns The base node followed by each member property in access order.
|
|
686
685
|
*/
|
|
687
|
-
function
|
|
688
|
-
|
|
689
|
-
let
|
|
690
|
-
while (
|
|
691
|
-
|
|
692
|
-
|
|
686
|
+
function getMemberChain(node) {
|
|
687
|
+
const members = [];
|
|
688
|
+
let current = unwrap(node);
|
|
689
|
+
while (current.type === AST_NODE_TYPES.MemberExpression) {
|
|
690
|
+
const property = unwrap(current.property);
|
|
691
|
+
members.unshift(property);
|
|
692
|
+
current = unwrap(current.object);
|
|
693
693
|
}
|
|
694
|
-
|
|
694
|
+
members.unshift(current);
|
|
695
|
+
return members;
|
|
695
696
|
}
|
|
696
697
|
/**
|
|
697
698
|
* Get the static name of an object property's key.
|
|
@@ -729,23 +730,6 @@ function getFullyQualifiedName(node, getText) {
|
|
|
729
730
|
default: return getText(expr);
|
|
730
731
|
}
|
|
731
732
|
}
|
|
732
|
-
/**
|
|
733
|
-
* Get the identifier at a given position in a member expression chain (ex: position `0` in `a.b.c` is `a`).
|
|
734
|
-
* @param node The expression to walk.
|
|
735
|
-
* @param position The position of the identifier to return.
|
|
736
|
-
* @returns The identifier at the given position, or `null` when there is none.
|
|
737
|
-
*/
|
|
738
|
-
function getIdentifierAt(node, position) {
|
|
739
|
-
const identifiers = [];
|
|
740
|
-
let current = unwrap(node);
|
|
741
|
-
while (current.type === AST_NODE_TYPES.MemberExpression) {
|
|
742
|
-
const property = unwrap(current.property);
|
|
743
|
-
identifiers.unshift(isIdentifier(property) ? property : null);
|
|
744
|
-
current = unwrap(current.object);
|
|
745
|
-
}
|
|
746
|
-
identifiers.unshift(isIdentifier(current) ? current : null);
|
|
747
|
-
return identifiers.at(position) ?? null;
|
|
748
|
-
}
|
|
749
733
|
|
|
750
734
|
//#endregion
|
|
751
735
|
//#region src/compare.ts
|