@eslint-react/ast 1.23.3-next.5 → 1.23.3-next.7
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.js +10 -10
- package/dist/index.mjs +10 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var stringTs = require('string-ts');
|
|
|
11
11
|
// src/find-parent-node.ts
|
|
12
12
|
var findParentNode = eff.F.dual(2, (node, test) => {
|
|
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 eff.O.some(parent);
|
|
17
17
|
}
|
|
@@ -21,7 +21,7 @@ var findParentNode = eff.F.dual(2, (node, test) => {
|
|
|
21
21
|
});
|
|
22
22
|
var findParentNodeGuard = eff.F.dual(2, (node, predicate) => {
|
|
23
23
|
let parent = node.parent;
|
|
24
|
-
while (parent) {
|
|
24
|
+
while (parent != null) {
|
|
25
25
|
if (predicate(parent)) {
|
|
26
26
|
return eff.O.some(parent);
|
|
27
27
|
}
|
|
@@ -31,7 +31,7 @@ var findParentNodeGuard = eff.F.dual(2, (node, predicate) => {
|
|
|
31
31
|
});
|
|
32
32
|
function findParentNodeStop(node, stopNode, predicate) {
|
|
33
33
|
let parent = node.parent;
|
|
34
|
-
while (parent && parent !== stopNode && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
34
|
+
while (parent != null && parent !== stopNode && parent.type !== types.AST_NODE_TYPES.Program) {
|
|
35
35
|
if (predicate(parent)) {
|
|
36
36
|
return eff.O.some(parent);
|
|
37
37
|
}
|
|
@@ -117,7 +117,7 @@ function hasCallInFunctionInitPath(callName) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
function getClassIdentifier(node) {
|
|
120
|
-
if (node.id) {
|
|
120
|
+
if (node.id != null) {
|
|
121
121
|
return eff.O.fromNullable(node.id);
|
|
122
122
|
}
|
|
123
123
|
if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
|
|
@@ -263,7 +263,7 @@ var isTypeExpression = isOneOf([
|
|
|
263
263
|
function getFunctionIdentifier(node) {
|
|
264
264
|
switch (true) {
|
|
265
265
|
// function MaybeComponent() {}
|
|
266
|
-
case ("id" in node &&
|
|
266
|
+
case ("id" in node && node.id != null):
|
|
267
267
|
return eff.O.some(node.id);
|
|
268
268
|
// const whatever = function MaybeComponent() {};
|
|
269
269
|
case (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.init === node && node.parent.id.type === types.AST_NODE_TYPES.Identifier):
|
|
@@ -332,7 +332,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
332
332
|
const chunk = boundGetNestedExpressionsOfType(node.right);
|
|
333
333
|
expressions.push(...chunk);
|
|
334
334
|
}
|
|
335
|
-
if ("test" in node && node.test
|
|
335
|
+
if ("test" in node && node.test != null) {
|
|
336
336
|
const chunk = boundGetNestedExpressionsOfType(node.test);
|
|
337
337
|
expressions.push(...chunk);
|
|
338
338
|
}
|
|
@@ -340,12 +340,12 @@ function getNestedExpressionsOfType(type) {
|
|
|
340
340
|
const chunk = Array.isArray(node.consequent) ? node.consequent.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.consequent);
|
|
341
341
|
expressions.push(...chunk);
|
|
342
342
|
}
|
|
343
|
-
if ("alternate" in node && node.alternate
|
|
343
|
+
if ("alternate" in node && node.alternate != null) {
|
|
344
344
|
const chunk = Array.isArray(node.alternate) ? node.alternate.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.alternate);
|
|
345
345
|
expressions.push(...chunk);
|
|
346
346
|
}
|
|
347
347
|
if ("elements" in node) {
|
|
348
|
-
const chunk = node.elements.filter((x) => x
|
|
348
|
+
const chunk = node.elements.filter((x) => x != null).map(getNestedExpressionsOfType(type)).flat(1);
|
|
349
349
|
expressions.push(...chunk);
|
|
350
350
|
}
|
|
351
351
|
if ("properties" in node) {
|
|
@@ -404,7 +404,7 @@ function getNestedIdentifiers(node) {
|
|
|
404
404
|
identifiers.push(...chunk);
|
|
405
405
|
}
|
|
406
406
|
if ("elements" in node) {
|
|
407
|
-
const chunk = node.elements.filter((x) => x
|
|
407
|
+
const chunk = node.elements.filter((x) => x != null).map(getNestedIdentifiers).flat(1);
|
|
408
408
|
identifiers.push(...chunk);
|
|
409
409
|
}
|
|
410
410
|
if ("properties" in node) {
|
|
@@ -552,7 +552,7 @@ var isNodeEqual = eff.F.dual(2, (a, b) => {
|
|
|
552
552
|
if (a.name.name !== b.name.name) {
|
|
553
553
|
return false;
|
|
554
554
|
}
|
|
555
|
-
if (a.value
|
|
555
|
+
if (a.value == null || b.value == null) {
|
|
556
556
|
return a.value === b.value;
|
|
557
557
|
}
|
|
558
558
|
return isNodeEqual(a.value, b.value);
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { toLowerCase, delimiterCase, replace } from 'string-ts';
|
|
|
9
9
|
// src/find-parent-node.ts
|
|
10
10
|
var findParentNode = F.dual(2, (node, test) => {
|
|
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 O.some(parent);
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ var findParentNode = F.dual(2, (node, test) => {
|
|
|
19
19
|
});
|
|
20
20
|
var findParentNodeGuard = F.dual(2, (node, predicate) => {
|
|
21
21
|
let parent = node.parent;
|
|
22
|
-
while (parent) {
|
|
22
|
+
while (parent != null) {
|
|
23
23
|
if (predicate(parent)) {
|
|
24
24
|
return O.some(parent);
|
|
25
25
|
}
|
|
@@ -29,7 +29,7 @@ var findParentNodeGuard = F.dual(2, (node, predicate) => {
|
|
|
29
29
|
});
|
|
30
30
|
function findParentNodeStop(node, stopNode, predicate) {
|
|
31
31
|
let parent = node.parent;
|
|
32
|
-
while (parent && parent !== stopNode && parent.type !== AST_NODE_TYPES.Program) {
|
|
32
|
+
while (parent != null && parent !== stopNode && parent.type !== AST_NODE_TYPES.Program) {
|
|
33
33
|
if (predicate(parent)) {
|
|
34
34
|
return O.some(parent);
|
|
35
35
|
}
|
|
@@ -115,7 +115,7 @@ function hasCallInFunctionInitPath(callName) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
function getClassIdentifier(node) {
|
|
118
|
-
if (node.id) {
|
|
118
|
+
if (node.id != null) {
|
|
119
119
|
return O.fromNullable(node.id);
|
|
120
120
|
}
|
|
121
121
|
if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
@@ -261,7 +261,7 @@ var isTypeExpression = isOneOf([
|
|
|
261
261
|
function getFunctionIdentifier(node) {
|
|
262
262
|
switch (true) {
|
|
263
263
|
// function MaybeComponent() {}
|
|
264
|
-
case ("id" in node &&
|
|
264
|
+
case ("id" in node && node.id != null):
|
|
265
265
|
return O.some(node.id);
|
|
266
266
|
// const whatever = function MaybeComponent() {};
|
|
267
267
|
case (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.init === node && node.parent.id.type === AST_NODE_TYPES.Identifier):
|
|
@@ -330,7 +330,7 @@ function getNestedExpressionsOfType(type) {
|
|
|
330
330
|
const chunk = boundGetNestedExpressionsOfType(node.right);
|
|
331
331
|
expressions.push(...chunk);
|
|
332
332
|
}
|
|
333
|
-
if ("test" in node && node.test
|
|
333
|
+
if ("test" in node && node.test != null) {
|
|
334
334
|
const chunk = boundGetNestedExpressionsOfType(node.test);
|
|
335
335
|
expressions.push(...chunk);
|
|
336
336
|
}
|
|
@@ -338,12 +338,12 @@ function getNestedExpressionsOfType(type) {
|
|
|
338
338
|
const chunk = Array.isArray(node.consequent) ? node.consequent.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.consequent);
|
|
339
339
|
expressions.push(...chunk);
|
|
340
340
|
}
|
|
341
|
-
if ("alternate" in node && node.alternate
|
|
341
|
+
if ("alternate" in node && node.alternate != null) {
|
|
342
342
|
const chunk = Array.isArray(node.alternate) ? node.alternate.map(boundGetNestedExpressionsOfType).flat(1) : boundGetNestedExpressionsOfType(node.alternate);
|
|
343
343
|
expressions.push(...chunk);
|
|
344
344
|
}
|
|
345
345
|
if ("elements" in node) {
|
|
346
|
-
const chunk = node.elements.filter((x) => x
|
|
346
|
+
const chunk = node.elements.filter((x) => x != null).map(getNestedExpressionsOfType(type)).flat(1);
|
|
347
347
|
expressions.push(...chunk);
|
|
348
348
|
}
|
|
349
349
|
if ("properties" in node) {
|
|
@@ -402,7 +402,7 @@ function getNestedIdentifiers(node) {
|
|
|
402
402
|
identifiers.push(...chunk);
|
|
403
403
|
}
|
|
404
404
|
if ("elements" in node) {
|
|
405
|
-
const chunk = node.elements.filter((x) => x
|
|
405
|
+
const chunk = node.elements.filter((x) => x != null).map(getNestedIdentifiers).flat(1);
|
|
406
406
|
identifiers.push(...chunk);
|
|
407
407
|
}
|
|
408
408
|
if ("properties" in node) {
|
|
@@ -550,7 +550,7 @@ var isNodeEqual = F.dual(2, (a, b) => {
|
|
|
550
550
|
if (a.name.name !== b.name.name) {
|
|
551
551
|
return false;
|
|
552
552
|
}
|
|
553
|
-
if (a.value
|
|
553
|
+
if (a.value == null || b.value == null) {
|
|
554
554
|
return a.value === b.value;
|
|
555
555
|
}
|
|
556
556
|
return isNodeEqual(a.value, b.value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "1.23.3-next.
|
|
3
|
+
"version": "1.23.3-next.7",
|
|
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/types": "1.23.3-next.
|
|
42
|
-
"@eslint-react/eff": "1.23.3-next.
|
|
41
|
+
"@eslint-react/types": "1.23.3-next.7",
|
|
42
|
+
"@eslint-react/eff": "1.23.3-next.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsup": "^8.3.5",
|