@eslint-react/ast 1.24.0-next.0 → 1.24.0-next.1
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 +1 -10
- package/dist/index.d.ts +1 -10
- package/dist/index.js +7 -19
- package/dist/index.mjs +8 -19
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -26,15 +26,6 @@ declare const findParentNodeGuard: {
|
|
|
26
26
|
<T extends TSESTree.Node>(predicate: (node: TSESTree.Node) => node is T): (node: TSESTree.Node | _) => T | _;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Find the first parent node that satisfies the test and stops at the stop node
|
|
31
|
-
* @param node The node to start searching
|
|
32
|
-
* @param stopNode The node to stop searching
|
|
33
|
-
* @param predicate The test function
|
|
34
|
-
* @returns The first parent node that satisfies the test or undefined if not found
|
|
35
|
-
*/
|
|
36
|
-
declare function findParentNodeStop(node: TSESTree.Node | _, stopNode: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): TSESTree.Node | _;
|
|
37
|
-
|
|
38
29
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
39
30
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
40
31
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -2445,4 +2436,4 @@ type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
|
|
|
2445
2436
|
|
|
2446
2437
|
declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
|
|
2447
2438
|
|
|
2448
|
-
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard,
|
|
2439
|
+
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,15 +26,6 @@ declare const findParentNodeGuard: {
|
|
|
26
26
|
<T extends TSESTree.Node>(predicate: (node: TSESTree.Node) => node is T): (node: TSESTree.Node | _) => T | _;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Find the first parent node that satisfies the test and stops at the stop node
|
|
31
|
-
* @param node The node to start searching
|
|
32
|
-
* @param stopNode The node to stop searching
|
|
33
|
-
* @param predicate The test function
|
|
34
|
-
* @returns The first parent node that satisfies the test or undefined if not found
|
|
35
|
-
*/
|
|
36
|
-
declare function findParentNodeStop(node: TSESTree.Node | _, stopNode: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): TSESTree.Node | _;
|
|
37
|
-
|
|
38
29
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
39
30
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
40
31
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -2445,4 +2436,4 @@ type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
|
|
|
2445
2436
|
|
|
2446
2437
|
declare function unwrapTypeExpression(node: TSESTree.Node): TSESTree.Node;
|
|
2447
2438
|
|
|
2448
|
-
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard,
|
|
2439
|
+
export { type FunctionInitPath, type ReadableNodeType, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeProperty, type TSESTreeTypeDeclaration, findParentNode, findParentNodeGuard, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, isThisExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType, unwrapTypeExpression };
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,9 @@ var stringTs = require('string-ts');
|
|
|
9
9
|
|
|
10
10
|
// src/find-parent-node.ts
|
|
11
11
|
var findParentNode = eff.dual(2, (node, test) => {
|
|
12
|
-
if (node
|
|
12
|
+
if (node == null) return eff._;
|
|
13
13
|
let parent = node.parent;
|
|
14
|
-
while (parent && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
14
|
+
while (parent != null && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
15
15
|
if (test(parent)) {
|
|
16
16
|
return parent;
|
|
17
17
|
}
|
|
@@ -20,9 +20,9 @@ var findParentNode = eff.dual(2, (node, test) => {
|
|
|
20
20
|
return eff._;
|
|
21
21
|
});
|
|
22
22
|
var findParentNodeGuard = eff.dual(2, (node, predicate) => {
|
|
23
|
-
if (node
|
|
23
|
+
if (node == null) return eff._;
|
|
24
24
|
let parent = node.parent;
|
|
25
|
-
while (parent) {
|
|
25
|
+
while (parent != null) {
|
|
26
26
|
if (predicate(parent)) {
|
|
27
27
|
return parent;
|
|
28
28
|
}
|
|
@@ -30,17 +30,6 @@ var findParentNodeGuard = eff.dual(2, (node, predicate) => {
|
|
|
30
30
|
}
|
|
31
31
|
return eff._;
|
|
32
32
|
});
|
|
33
|
-
function findParentNodeStop(node, stopNode, predicate) {
|
|
34
|
-
if (node === eff._) return eff._;
|
|
35
|
-
let parent = node.parent;
|
|
36
|
-
while (parent && parent !== stopNode && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
37
|
-
if (predicate(parent)) {
|
|
38
|
-
return parent;
|
|
39
|
-
}
|
|
40
|
-
parent = parent.parent;
|
|
41
|
-
}
|
|
42
|
-
return eff._;
|
|
43
|
-
}
|
|
44
33
|
function getFunctionInitPath(node) {
|
|
45
34
|
const { parent } = node;
|
|
46
35
|
if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) {
|
|
@@ -115,7 +104,7 @@ function hasCallInFunctionInitPath(callName) {
|
|
|
115
104
|
};
|
|
116
105
|
}
|
|
117
106
|
function getClassIdentifier(node) {
|
|
118
|
-
if (node.id) return node.id;
|
|
107
|
+
if (node.id != null) return node.id;
|
|
119
108
|
if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
|
|
120
109
|
return node.parent.id;
|
|
121
110
|
}
|
|
@@ -331,7 +320,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
331
320
|
const chunk = boundGetNestedExpressionsOfType(node.right);
|
|
332
321
|
expressions.push(...chunk);
|
|
333
322
|
}
|
|
334
|
-
if ("test" in node && node.test) {
|
|
323
|
+
if ("test" in node && node.test != null) {
|
|
335
324
|
const chunk = boundGetNestedExpressionsOfType(node.test);
|
|
336
325
|
expressions.push(...chunk);
|
|
337
326
|
}
|
|
@@ -339,7 +328,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
339
328
|
const chunk = Array.isArray(node.consequent) ? node.consequent.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.consequent);
|
|
340
329
|
expressions.push(...chunk);
|
|
341
330
|
}
|
|
342
|
-
if ("alternate" in node && node.alternate) {
|
|
331
|
+
if ("alternate" in node && node.alternate != null) {
|
|
343
332
|
const chunk = Array.isArray(node.alternate) ? node.alternate.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.alternate);
|
|
344
333
|
expressions.push(...chunk);
|
|
345
334
|
}
|
|
@@ -628,7 +617,6 @@ function unwrapTypeExpression(node) {
|
|
|
628
617
|
|
|
629
618
|
exports.findParentNode = findParentNode;
|
|
630
619
|
exports.findParentNodeGuard = findParentNodeGuard;
|
|
631
|
-
exports.findParentNodeStop = findParentNodeStop;
|
|
632
620
|
exports.getClassIdentifier = getClassIdentifier;
|
|
633
621
|
exports.getFunctionIdentifier = getFunctionIdentifier;
|
|
634
622
|
exports.getFunctionInitPath = getFunctionInitPath;
|
package/dist/index.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import { toLowerCase, delimiterCase, replace } from 'string-ts';
|
|
|
7
7
|
|
|
8
8
|
// src/find-parent-node.ts
|
|
9
9
|
var findParentNode = dual(2, (node, test) => {
|
|
10
|
-
if (node
|
|
10
|
+
if (node == null) return _;
|
|
11
11
|
let parent = node.parent;
|
|
12
|
-
while (parent && parent.type !== AST_NODE_TYPES.Program) {
|
|
12
|
+
while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
|
|
13
13
|
if (test(parent)) {
|
|
14
14
|
return parent;
|
|
15
15
|
}
|
|
@@ -18,9 +18,9 @@ var findParentNode = dual(2, (node, test) => {
|
|
|
18
18
|
return _;
|
|
19
19
|
});
|
|
20
20
|
var findParentNodeGuard = dual(2, (node, predicate) => {
|
|
21
|
-
if (node
|
|
21
|
+
if (node == null) return _;
|
|
22
22
|
let parent = node.parent;
|
|
23
|
-
while (parent) {
|
|
23
|
+
while (parent != null) {
|
|
24
24
|
if (predicate(parent)) {
|
|
25
25
|
return parent;
|
|
26
26
|
}
|
|
@@ -28,17 +28,6 @@ var findParentNodeGuard = dual(2, (node, predicate) => {
|
|
|
28
28
|
}
|
|
29
29
|
return _;
|
|
30
30
|
});
|
|
31
|
-
function findParentNodeStop(node, stopNode, predicate) {
|
|
32
|
-
if (node === _) return _;
|
|
33
|
-
let parent = node.parent;
|
|
34
|
-
while (parent && parent !== stopNode && parent.type !== AST_NODE_TYPES.Program) {
|
|
35
|
-
if (predicate(parent)) {
|
|
36
|
-
return parent;
|
|
37
|
-
}
|
|
38
|
-
parent = parent.parent;
|
|
39
|
-
}
|
|
40
|
-
return _;
|
|
41
|
-
}
|
|
42
31
|
function getFunctionInitPath(node) {
|
|
43
32
|
const { parent } = node;
|
|
44
33
|
if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
|
|
@@ -113,7 +102,7 @@ function hasCallInFunctionInitPath(callName) {
|
|
|
113
102
|
};
|
|
114
103
|
}
|
|
115
104
|
function getClassIdentifier(node) {
|
|
116
|
-
if (node.id) return node.id;
|
|
105
|
+
if (node.id != null) return node.id;
|
|
117
106
|
if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
118
107
|
return node.parent.id;
|
|
119
108
|
}
|
|
@@ -329,7 +318,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
329
318
|
const chunk = boundGetNestedExpressionsOfType(node.right);
|
|
330
319
|
expressions.push(...chunk);
|
|
331
320
|
}
|
|
332
|
-
if ("test" in node && node.test) {
|
|
321
|
+
if ("test" in node && node.test != null) {
|
|
333
322
|
const chunk = boundGetNestedExpressionsOfType(node.test);
|
|
334
323
|
expressions.push(...chunk);
|
|
335
324
|
}
|
|
@@ -337,7 +326,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
337
326
|
const chunk = Array.isArray(node.consequent) ? node.consequent.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.consequent);
|
|
338
327
|
expressions.push(...chunk);
|
|
339
328
|
}
|
|
340
|
-
if ("alternate" in node && node.alternate) {
|
|
329
|
+
if ("alternate" in node && node.alternate != null) {
|
|
341
330
|
const chunk = Array.isArray(node.alternate) ? node.alternate.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.alternate);
|
|
342
331
|
expressions.push(...chunk);
|
|
343
332
|
}
|
|
@@ -624,4 +613,4 @@ function unwrapTypeExpression(node) {
|
|
|
624
613
|
return node;
|
|
625
614
|
}
|
|
626
615
|
|
|
627
|
-
export { findParentNode, findParentNodeGuard,
|
|
616
|
+
export { findParentNode, findParentNodeGuard, getClassIdentifier, getFunctionIdentifier, getFunctionInitPath, getIdentifiersFromBinaryExpression, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionOfClassMethod, isFunctionOfClassProperty, isFunctionOfImmediatelyInvoked, isFunctionOfObjectMethod, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKeyLiteralLike, isLeftHandSideExpression, isLeftHandSideExpressionType, isLoop, isMapCallLoose, isMultiLine, isNodeEqual, isOneOf, isProperty, isRegExpLiteral, isStringLiteral, 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.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.1",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@typescript-eslint/utils": "^8.19.1",
|
|
39
39
|
"string-ts": "^2.2.0",
|
|
40
40
|
"ts-pattern": "^5.6.0",
|
|
41
|
-
"@eslint-react/eff": "1.24.0-next.
|
|
42
|
-
"@eslint-react/types": "1.24.0-next.
|
|
41
|
+
"@eslint-react/eff": "1.24.0-next.1",
|
|
42
|
+
"@eslint-react/types": "1.24.0-next.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsup": "^8.3.5",
|