@eslint-react/ast 5.2.3-next.1 → 5.2.4-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 +20 -21
- package/dist/index.js +67 -70
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type TSESTreeDirective = TSESTree.ExpressionStatement & {
|
|
|
13
13
|
};
|
|
14
14
|
type TSESTreeTypeExpression = TSESTree.TSAsExpression | TSESTree.TSTypeAssertion | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSInstantiationExpression;
|
|
15
15
|
declare namespace check_d_exports {
|
|
16
|
-
export {
|
|
16
|
+
export { is, isClass, isDirective, isFunction, isIdentifier, isJSX, isJSXElement, isJSXFragment, isJSXLike, isJSXTagNameExpression, isLiteral, isMethodOrProperty, isOneOf, isProperty, isTypeAssertionExpression, isTypeExpression };
|
|
17
17
|
}
|
|
18
18
|
declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
19
19
|
type: NodeType;
|
|
@@ -21,14 +21,14 @@ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node
|
|
|
21
21
|
declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
22
22
|
type: NodeTypes[number];
|
|
23
23
|
}>;
|
|
24
|
-
declare function
|
|
25
|
-
declare function
|
|
26
|
-
declare function
|
|
27
|
-
declare function
|
|
28
|
-
declare function
|
|
29
|
-
declare function
|
|
30
|
-
declare function
|
|
31
|
-
declare function
|
|
24
|
+
declare function isLiteral(): (node: TSESTree.Node) => node is TSESTree.Literal;
|
|
25
|
+
declare function isLiteral(kind: "boolean"): (node: TSESTree.Node) => node is TSESTree.BooleanLiteral;
|
|
26
|
+
declare function isLiteral(kind: "null"): (node: TSESTree.Node) => node is TSESTree.NullLiteral;
|
|
27
|
+
declare function isLiteral(kind: "number"): (node: TSESTree.Node) => node is TSESTree.NumberLiteral;
|
|
28
|
+
declare function isLiteral(kind: "regexp"): (node: TSESTree.Node) => node is TSESTree.RegExpLiteral;
|
|
29
|
+
declare function isLiteral(kind: "string"): (node: TSESTree.Node) => node is TSESTree.StringLiteral;
|
|
30
|
+
declare function isDirective(name: string): (node: TSESTree.Node) => node is TSESTreeDirective;
|
|
31
|
+
declare function isIdentifier(name: string): (node: TSESTree.Node) => node is TSESTree.Identifier;
|
|
32
32
|
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
33
33
|
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
|
|
34
34
|
declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
|
|
@@ -40,9 +40,8 @@ declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) =
|
|
|
40
40
|
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;
|
|
41
41
|
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
42
42
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
43
|
-
declare function directive(node: TSESTree.Node): node is TSESTreeDirective;
|
|
44
43
|
declare namespace compare_d_exports {
|
|
45
|
-
export {
|
|
44
|
+
export { isEqual };
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* Check if two nodes are equal
|
|
@@ -51,24 +50,24 @@ declare namespace compare_d_exports {
|
|
|
51
50
|
* @returns `true` if node equal
|
|
52
51
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
53
52
|
*/
|
|
54
|
-
declare const
|
|
53
|
+
declare const isEqual: {
|
|
55
54
|
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
56
55
|
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
57
56
|
};
|
|
58
57
|
declare namespace extract_d_exports {
|
|
59
|
-
export {
|
|
58
|
+
export { getFullyQualifiedName, getHumanReadableKind, getPropertyName, getRootIdentifier, unwrap };
|
|
60
59
|
}
|
|
61
|
-
declare function
|
|
62
|
-
declare function
|
|
63
|
-
declare function
|
|
64
|
-
declare function
|
|
65
|
-
declare function
|
|
60
|
+
declare function unwrap(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
61
|
+
declare function getRootIdentifier(node: TSESTree.Expression | TSESTree.PrivateIdentifier): TSESTree.Identifier | null;
|
|
62
|
+
declare function getPropertyName(node: TSESTree.Node): string | null;
|
|
63
|
+
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
64
|
+
declare function getHumanReadableKind(node: TSESTree.Node): "regexp literal" | "null literal" | "string literal" | "number literal" | "bigint literal" | "boolean literal" | "symbol literal" | "undefined literal" | "object literal" | "function literal" | "decorator" | "identifier" | "program" | "property" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "jsx attribute" | "jsx closing element" | "jsx closing fragment" | "jsx element" | "jsx empty expression" | "jsx expression container" | "jsx fragment" | "jsx identifier" | "member expression" | "jsx member expression" | "jsx namespaced name" | "jsx opening element" | "jsx opening fragment" | "jsx spread attribute" | "jsx spread child" | "jsx text" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
|
|
66
65
|
declare namespace traverse_d_exports {
|
|
67
|
-
export {
|
|
66
|
+
export { findParent };
|
|
68
67
|
}
|
|
69
68
|
type Predicate<T extends TSESTree.Node> = (node: TSESTree.Node) => node is T;
|
|
70
69
|
type NodePredicate = (node: TSESTree.Node) => boolean;
|
|
71
|
-
declare function findParent<T extends TSESTree.Node>(
|
|
72
|
-
declare function findParent(
|
|
70
|
+
declare function findParent<T extends TSESTree.Node>(node: TSESTree.Node | null, test: Predicate<T>): T | null;
|
|
71
|
+
declare function findParent(node: TSESTree.Node | null, test: NodePredicate): TSESTree.Node | null;
|
|
73
72
|
//#endregion
|
|
74
73
|
export { check_d_exports as Check, compare_d_exports as Compare, extract_d_exports as Extract, TSESTreeClass, TSESTreeDirective, TSESTreeFunction, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeJSXElementLike, TSESTreeMethodOrPropertyDefinition, TSESTreeTypeExpression, traverse_d_exports as Traverse, is, isOneOf };
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-BYypO7fO.js";
|
|
2
2
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
3
|
import { ASTUtils } from "@typescript-eslint/utils";
|
|
4
|
-
import { delimiterCase,
|
|
4
|
+
import { delimiterCase, toLowerCase } from "string-ts";
|
|
5
5
|
|
|
6
6
|
//#region src/check.ts
|
|
7
7
|
var check_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
directive: () => directive,
|
|
9
|
-
identifier: () => identifier,
|
|
10
8
|
is: () => is,
|
|
11
9
|
isClass: () => isClass,
|
|
10
|
+
isDirective: () => isDirective,
|
|
12
11
|
isFunction: () => isFunction,
|
|
12
|
+
isIdentifier: () => isIdentifier,
|
|
13
13
|
isJSX: () => isJSX,
|
|
14
14
|
isJSXElement: () => isJSXElement,
|
|
15
15
|
isJSXFragment: () => isJSXFragment,
|
|
16
16
|
isJSXLike: () => isJSXLike,
|
|
17
17
|
isJSXTagNameExpression: () => isJSXTagNameExpression,
|
|
18
|
+
isLiteral: () => isLiteral,
|
|
18
19
|
isMethodOrProperty: () => isMethodOrProperty,
|
|
19
20
|
isOneOf: () => isOneOf,
|
|
20
21
|
isProperty: () => isProperty,
|
|
21
22
|
isTypeAssertionExpression: () => isTypeAssertionExpression,
|
|
22
|
-
isTypeExpression: () => isTypeExpression
|
|
23
|
-
literal: () => literal,
|
|
24
|
-
thisExpression: () => thisExpression
|
|
23
|
+
isTypeExpression: () => isTypeExpression
|
|
25
24
|
});
|
|
26
25
|
const is = ASTUtils.isNodeOfType;
|
|
27
26
|
const isOneOf = ASTUtils.isNodeOfTypes;
|
|
28
|
-
function
|
|
29
|
-
return
|
|
27
|
+
function isLiteral(kind) {
|
|
28
|
+
return (node) => {
|
|
29
|
+
if (node.type !== AST_NODE_TYPES.Literal) return false;
|
|
30
|
+
if (kind == null) return true;
|
|
31
|
+
switch (kind) {
|
|
32
|
+
case "boolean": return typeof node.value === "boolean";
|
|
33
|
+
case "null": return node.value === null;
|
|
34
|
+
case "number": return typeof node.value === "number";
|
|
35
|
+
case "regexp": return "regex" in node;
|
|
36
|
+
case "string": return typeof node.value === "string";
|
|
37
|
+
default: return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
30
40
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
if (ofKind == null) return true;
|
|
34
|
-
switch (ofKind) {
|
|
35
|
-
case "boolean": return typeof node.value === "boolean";
|
|
36
|
-
case "null": return node.value === null;
|
|
37
|
-
case "number": return typeof node.value === "number";
|
|
38
|
-
case "regexp": return "regex" in node;
|
|
39
|
-
case "string": return typeof node.value === "string";
|
|
40
|
-
default: return false;
|
|
41
|
-
}
|
|
41
|
+
function isDirective(name) {
|
|
42
|
+
return (node) => node.type === AST_NODE_TYPES.ExpressionStatement && node.directive === name;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
44
|
+
function isIdentifier(name) {
|
|
45
|
+
return (node) => node.type === AST_NODE_TYPES.Identifier && node.name === name;
|
|
45
46
|
}
|
|
46
47
|
const isFunction = isOneOf([
|
|
47
48
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
@@ -94,9 +95,6 @@ const isTypeAssertionExpression = isOneOf([
|
|
|
94
95
|
AST_NODE_TYPES.TSNonNullExpression,
|
|
95
96
|
AST_NODE_TYPES.TSSatisfiesExpression
|
|
96
97
|
]);
|
|
97
|
-
function directive(node) {
|
|
98
|
-
return node.type === AST_NODE_TYPES.ExpressionStatement && node.directive != null;
|
|
99
|
-
}
|
|
100
98
|
|
|
101
99
|
//#endregion
|
|
102
100
|
//#region ../../.pkgs/eff/dist/index.js
|
|
@@ -219,55 +217,54 @@ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
|
219
217
|
//#endregion
|
|
220
218
|
//#region src/extract.ts
|
|
221
219
|
var extract_exports = /* @__PURE__ */ __exportAll({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
getFullyQualifiedName: () => getFullyQualifiedName,
|
|
221
|
+
getHumanReadableKind: () => getHumanReadableKind,
|
|
222
|
+
getPropertyName: () => getPropertyName,
|
|
223
|
+
getRootIdentifier: () => getRootIdentifier,
|
|
224
|
+
unwrap: () => unwrap
|
|
227
225
|
});
|
|
228
|
-
function
|
|
229
|
-
if (isTypeExpression(
|
|
230
|
-
return
|
|
226
|
+
function unwrap(node) {
|
|
227
|
+
if (isTypeExpression(node)) return unwrap(node.expression);
|
|
228
|
+
return node;
|
|
231
229
|
}
|
|
232
|
-
function
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
if (
|
|
230
|
+
function getRootIdentifier(node) {
|
|
231
|
+
const expr = unwrap(node);
|
|
232
|
+
if (expr.type === AST_NODE_TYPES.Identifier) return expr;
|
|
233
|
+
if (expr.type === AST_NODE_TYPES.MemberExpression) return getRootIdentifier(expr.object);
|
|
236
234
|
return null;
|
|
237
235
|
}
|
|
238
|
-
function
|
|
239
|
-
if (isTypeExpression(
|
|
240
|
-
if (
|
|
241
|
-
if (
|
|
242
|
-
if (
|
|
236
|
+
function getPropertyName(node) {
|
|
237
|
+
if (isTypeExpression(node)) return getPropertyName(unwrap(node));
|
|
238
|
+
if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) return node.name;
|
|
239
|
+
if (node.type === AST_NODE_TYPES.Literal) return String(node.value);
|
|
240
|
+
if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) return node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? null;
|
|
243
241
|
return null;
|
|
244
242
|
}
|
|
245
|
-
function
|
|
246
|
-
switch (
|
|
243
|
+
function getFullyQualifiedName(node, getText) {
|
|
244
|
+
switch (node.type) {
|
|
247
245
|
case AST_NODE_TYPES.Identifier:
|
|
248
246
|
case AST_NODE_TYPES.JSXIdentifier:
|
|
249
|
-
case AST_NODE_TYPES.PrivateIdentifier: return
|
|
247
|
+
case AST_NODE_TYPES.PrivateIdentifier: return node.name;
|
|
250
248
|
case AST_NODE_TYPES.MemberExpression:
|
|
251
|
-
case AST_NODE_TYPES.JSXMemberExpression: return `${
|
|
252
|
-
case AST_NODE_TYPES.JSXNamespacedName: return `${
|
|
253
|
-
case AST_NODE_TYPES.JSXText: return
|
|
254
|
-
case AST_NODE_TYPES.Literal: return
|
|
255
|
-
default: return
|
|
249
|
+
case AST_NODE_TYPES.JSXMemberExpression: return `${getFullyQualifiedName(node.object, getText)}.${getFullyQualifiedName(node.property, getText)}`;
|
|
250
|
+
case AST_NODE_TYPES.JSXNamespacedName: return `${node.namespace.name}:${node.name.name}`;
|
|
251
|
+
case AST_NODE_TYPES.JSXText: return node.value;
|
|
252
|
+
case AST_NODE_TYPES.Literal: return node.raw;
|
|
253
|
+
default: return getText(node);
|
|
256
254
|
}
|
|
257
255
|
}
|
|
258
|
-
function
|
|
259
|
-
if (
|
|
260
|
-
if ("regex" in
|
|
261
|
-
if (
|
|
262
|
-
return `${typeof
|
|
256
|
+
function getHumanReadableKind(node) {
|
|
257
|
+
if (node.type === AST_NODE_TYPES.Literal) {
|
|
258
|
+
if ("regex" in node) return "regexp literal";
|
|
259
|
+
if (node.value === null) return "null literal";
|
|
260
|
+
return `${typeof node.value} literal`;
|
|
263
261
|
}
|
|
264
|
-
|
|
265
|
-
return toLowerCase(delimiterCase(of.type, delimiter));
|
|
262
|
+
return toLowerCase(delimiterCase(node.type, " "));
|
|
266
263
|
}
|
|
267
264
|
|
|
268
265
|
//#endregion
|
|
269
266
|
//#region src/compare.ts
|
|
270
|
-
var compare_exports = /* @__PURE__ */ __exportAll({
|
|
267
|
+
var compare_exports = /* @__PURE__ */ __exportAll({ isEqual: () => isEqual });
|
|
271
268
|
/**
|
|
272
269
|
* Check if two nodes are equal
|
|
273
270
|
* @param a node to compare
|
|
@@ -275,9 +272,9 @@ var compare_exports = /* @__PURE__ */ __exportAll({ areEqual: () => areEqual });
|
|
|
275
272
|
* @returns `true` if node equal
|
|
276
273
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
277
274
|
*/
|
|
278
|
-
const
|
|
279
|
-
a = isTypeExpression(a) ?
|
|
280
|
-
b = isTypeExpression(b) ?
|
|
275
|
+
const isEqual = dual(2, (a, b) => {
|
|
276
|
+
a = isTypeExpression(a) ? unwrap(a) : a;
|
|
277
|
+
b = isTypeExpression(b) ? unwrap(b) : b;
|
|
281
278
|
switch (true) {
|
|
282
279
|
case a === b: return true;
|
|
283
280
|
case a.type !== b.type: return false;
|
|
@@ -291,20 +288,20 @@ const areEqual = dual(2, (a, b) => {
|
|
|
291
288
|
while (i--) {
|
|
292
289
|
const exprA = a.expressions[i];
|
|
293
290
|
const exprB = b.expressions[i];
|
|
294
|
-
if (!
|
|
291
|
+
if (!isEqual(exprA, exprB)) return false;
|
|
295
292
|
}
|
|
296
293
|
return true;
|
|
297
294
|
}
|
|
298
295
|
case a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier: return a.name === b.name;
|
|
299
296
|
case a.type === AST_NODE_TYPES.PrivateIdentifier && b.type === AST_NODE_TYPES.PrivateIdentifier: return a.name === b.name;
|
|
300
|
-
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return
|
|
297
|
+
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return isEqual(a.property, b.property) && isEqual(a.object, b.object);
|
|
301
298
|
case a.type === AST_NODE_TYPES.JSXIdentifier && b.type === AST_NODE_TYPES.JSXIdentifier: return a.name === b.name;
|
|
302
|
-
case a.type === AST_NODE_TYPES.JSXNamespacedName && b.type === AST_NODE_TYPES.JSXNamespacedName: return
|
|
303
|
-
case a.type === AST_NODE_TYPES.JSXMemberExpression && b.type === AST_NODE_TYPES.JSXMemberExpression: return
|
|
299
|
+
case a.type === AST_NODE_TYPES.JSXNamespacedName && b.type === AST_NODE_TYPES.JSXNamespacedName: return isEqual(a.namespace, b.namespace) && isEqual(a.name, b.name);
|
|
300
|
+
case a.type === AST_NODE_TYPES.JSXMemberExpression && b.type === AST_NODE_TYPES.JSXMemberExpression: return isEqual(a.object, b.object) && isEqual(a.property, b.property);
|
|
304
301
|
case a.type === AST_NODE_TYPES.JSXAttribute && b.type === AST_NODE_TYPES.JSXAttribute:
|
|
305
|
-
if (!
|
|
302
|
+
if (!isEqual(a.name, b.name)) return false;
|
|
306
303
|
if (a.value == null || b.value == null) return a.value === b.value;
|
|
307
|
-
return
|
|
304
|
+
return isEqual(a.value, b.value);
|
|
308
305
|
case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression: return true;
|
|
309
306
|
default: return false;
|
|
310
307
|
}
|
|
@@ -313,12 +310,12 @@ const areEqual = dual(2, (a, b) => {
|
|
|
313
310
|
//#endregion
|
|
314
311
|
//#region src/traverse.ts
|
|
315
312
|
var traverse_exports = /* @__PURE__ */ __exportAll({ findParent: () => findParent });
|
|
316
|
-
function findParent(
|
|
317
|
-
if (
|
|
318
|
-
let parent =
|
|
313
|
+
function findParent(node, test) {
|
|
314
|
+
if (node == null) return null;
|
|
315
|
+
let parent = node.parent;
|
|
319
316
|
while (parent?.type !== AST_NODE_TYPES.Program) {
|
|
320
317
|
if (parent == null) return null;
|
|
321
|
-
if (
|
|
318
|
+
if (test(parent)) return parent;
|
|
322
319
|
parent = parent.parent;
|
|
323
320
|
}
|
|
324
321
|
return null;
|