@eslint-react/var 5.10.3 → 5.11.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.js +11 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Check, Compare, Extract, Traverse, isOneOf } from "@eslint-react/ast";
|
|
|
2
2
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
3
3
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
4
4
|
import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
5
|
+
import { P, isMatching } from "ts-pattern";
|
|
5
6
|
|
|
6
7
|
//#region src/resolve.ts
|
|
7
8
|
/**
|
|
@@ -127,18 +128,18 @@ function computeObjectType(context, node) {
|
|
|
127
128
|
case AST_NODE_TYPES.CallExpression: {
|
|
128
129
|
const callee = Extract.unwrap(node.callee);
|
|
129
130
|
switch (true) {
|
|
130
|
-
case Check.isIdentifier("Boolean")
|
|
131
|
-
case Check.isIdentifier("String")
|
|
132
|
-
case Check.isIdentifier("Number")
|
|
133
|
-
case Check.isIdentifier("Object")
|
|
131
|
+
case Check.isIdentifier(callee, "Boolean"): return null;
|
|
132
|
+
case Check.isIdentifier(callee, "String"): return null;
|
|
133
|
+
case Check.isIdentifier(callee, "Number"): return null;
|
|
134
|
+
case Check.isIdentifier(callee, "Object"): return {
|
|
134
135
|
kind: "plain",
|
|
135
136
|
node
|
|
136
137
|
};
|
|
137
|
-
case Check.isIdentifier("Array")
|
|
138
|
+
case Check.isIdentifier(callee, "Array"): return {
|
|
138
139
|
kind: "array",
|
|
139
140
|
node
|
|
140
141
|
};
|
|
141
|
-
case Check.isIdentifier("RegExp")
|
|
142
|
+
case Check.isIdentifier(callee, "RegExp"): return {
|
|
142
143
|
kind: "regexp",
|
|
143
144
|
node
|
|
144
145
|
};
|
|
@@ -287,7 +288,10 @@ function resolveImportSource(name, initialScope, visited = /* @__PURE__ */ new S
|
|
|
287
288
|
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return resolveImportSource(init.object.name, initialScope, visited);
|
|
288
289
|
if (init.type === AST_NODE_TYPES.Identifier) return resolveImportSource(init.name, initialScope, visited);
|
|
289
290
|
const arg0 = getRequireExpressionArguments(init)?.[0];
|
|
290
|
-
if (arg0 == null || !
|
|
291
|
+
if (arg0 == null || !isMatching({
|
|
292
|
+
type: AST_NODE_TYPES.Literal,
|
|
293
|
+
value: P.string
|
|
294
|
+
}, arg0)) return null;
|
|
291
295
|
return arg0.value;
|
|
292
296
|
}
|
|
293
297
|
if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
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": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@typescript-eslint/types": "^8.62.1",
|
|
34
34
|
"@typescript-eslint/utils": "^8.62.1",
|
|
35
35
|
"ts-pattern": "^5.9.0",
|
|
36
|
-
"@eslint-react/ast": "5.
|
|
37
|
-
"@eslint-react/eslint": "5.
|
|
36
|
+
"@eslint-react/ast": "5.11.0",
|
|
37
|
+
"@eslint-react/eslint": "5.11.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@typescript-eslint/parser": "^8.62.1",
|