@eslint-react/var 3.0.0-next.71 → 3.0.0-next.76
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 +4 -4
- package/dist/index.js +25 -6
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ type ObjectType = {
|
|
|
10
10
|
node: TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
11
11
|
} | {
|
|
12
12
|
kind: "array";
|
|
13
|
-
node: TSESTree.ArrayExpression;
|
|
13
|
+
node: TSESTree.ArrayExpression | TSESTree.CallExpression;
|
|
14
14
|
} | {
|
|
15
15
|
kind: "plain";
|
|
16
|
-
node: TSESTree.ObjectExpression;
|
|
16
|
+
node: TSESTree.ObjectExpression | TSESTree.CallExpression;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "class";
|
|
19
19
|
node: TSESTree.ClassExpression;
|
|
@@ -25,11 +25,11 @@ type ObjectType = {
|
|
|
25
25
|
node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression;
|
|
26
26
|
} | {
|
|
27
27
|
kind: "regexp";
|
|
28
|
-
node: TSESTree.RegExpLiteral;
|
|
28
|
+
node: TSESTree.RegExpLiteral | TSESTree.CallExpression;
|
|
29
29
|
} | {
|
|
30
30
|
kind: "unknown";
|
|
31
31
|
node: TSESTree.Node;
|
|
32
|
-
reason
|
|
32
|
+
reason?: string;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Detect the ObjectType of a given node
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as ast from "@eslint-react/ast";
|
|
2
|
+
import { isIdentifier } from "@eslint-react/ast";
|
|
1
3
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
2
4
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
|
-
import * as ast from "@eslint-react/ast";
|
|
4
5
|
import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
5
6
|
|
|
6
7
|
//#region src/resolve.ts
|
|
@@ -128,11 +129,29 @@ function computeObjectType(context, node) {
|
|
|
128
129
|
case AST_NODE_TYPES.SequenceExpression:
|
|
129
130
|
if (node.expressions.length === 0) return null;
|
|
130
131
|
return computeObjectType(context, node.expressions[node.expressions.length - 1] ?? null);
|
|
131
|
-
case AST_NODE_TYPES.CallExpression:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
case AST_NODE_TYPES.CallExpression:
|
|
133
|
+
switch (true) {
|
|
134
|
+
case isIdentifier(node.callee, "Boolean"): return null;
|
|
135
|
+
case isIdentifier(node.callee, "String"): return null;
|
|
136
|
+
case isIdentifier(node.callee, "Number"): return null;
|
|
137
|
+
case isIdentifier(node.callee, "Object"): return {
|
|
138
|
+
kind: "plain",
|
|
139
|
+
node
|
|
140
|
+
};
|
|
141
|
+
case isIdentifier(node.callee, "Array"): return {
|
|
142
|
+
kind: "array",
|
|
143
|
+
node
|
|
144
|
+
};
|
|
145
|
+
case isIdentifier(node.callee, "RegExp"): return {
|
|
146
|
+
kind: "regexp",
|
|
147
|
+
node
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
kind: "unknown",
|
|
152
|
+
node,
|
|
153
|
+
reason: "call-expression"
|
|
154
|
+
};
|
|
136
155
|
default:
|
|
137
156
|
if (!("expression" in node) || typeof node.expression !== "object") return null;
|
|
138
157
|
return computeObjectType(context, node.expression);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.76",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module for static analysis of variables.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@typescript-eslint/types": "canary",
|
|
35
35
|
"@typescript-eslint/utils": "canary",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@
|
|
39
|
-
"@eslint-react/
|
|
37
|
+
"@eslint-react/shared": "3.0.0-next.76",
|
|
38
|
+
"@local/eff": "3.0.0-beta.72",
|
|
39
|
+
"@eslint-react/ast": "3.0.0-next.76"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@typescript-eslint/typescript-estree": "canary",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@local/configs": "0.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"typescript": "
|
|
47
|
+
"eslint": "^10.0.0",
|
|
48
|
+
"typescript": "*"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=22.0.0"
|