@eslint-react/core 2.0.1-next.3 → 2.0.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.js +9 -9
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as AST from "@eslint-react/ast";
|
|
|
3
3
|
import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
4
4
|
import { RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/kit";
|
|
5
5
|
import { getId } from "@eslint-react/shared";
|
|
6
|
-
import
|
|
6
|
+
import { findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
|
|
7
7
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
8
8
|
import { P, isMatching, match } from "ts-pattern";
|
|
9
9
|
import birecord from "birecord";
|
|
@@ -314,12 +314,12 @@ function getAttribute(context, attributes, initialScope) {
|
|
|
314
314
|
if (initialScope == null) return false;
|
|
315
315
|
switch (attr.argument.type) {
|
|
316
316
|
case AST_NODE_TYPES.Identifier: {
|
|
317
|
-
const variable =
|
|
318
|
-
const variableNode =
|
|
319
|
-
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return
|
|
317
|
+
const variable = findVariable(attr.argument.name, initialScope);
|
|
318
|
+
const variableNode = getVariableDefinitionNode(variable, 0);
|
|
319
|
+
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return findProperty(name, variableNode.properties, initialScope) != null;
|
|
320
320
|
return false;
|
|
321
321
|
}
|
|
322
|
-
case AST_NODE_TYPES.ObjectExpression: return
|
|
322
|
+
case AST_NODE_TYPES.ObjectExpression: return findProperty(name, attr.argument.properties, initialScope) != null;
|
|
323
323
|
}
|
|
324
324
|
return false;
|
|
325
325
|
});
|
|
@@ -536,8 +536,8 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
536
536
|
const { name } = node;
|
|
537
537
|
if (name === "undefined") return !(hint & JSXDetectionHint.SkipUndefined);
|
|
538
538
|
if (AST.isJSXTagNameExpression(node)) return true;
|
|
539
|
-
const variable =
|
|
540
|
-
const variableNode = variable &&
|
|
539
|
+
const variable = findVariable(name, code.getScope(node));
|
|
540
|
+
const variableNode = variable && getVariableDefinitionNode(variable, 0);
|
|
541
541
|
return !!variableNode && isJsxLike(code, variableNode, hint);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
@@ -831,7 +831,7 @@ function getRequireExpressionArguments(node) {
|
|
|
831
831
|
*/
|
|
832
832
|
function isInitializedFromReact(name, importSource, initialScope) {
|
|
833
833
|
if (name.toLowerCase() === "react") return true;
|
|
834
|
-
const latestDef =
|
|
834
|
+
const latestDef = findVariable(name, initialScope)?.defs.at(-1);
|
|
835
835
|
if (latestDef == null) return false;
|
|
836
836
|
const { node, parent } = latestDef;
|
|
837
837
|
if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
|
|
@@ -849,7 +849,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
849
849
|
//#region src/utils/is-instance-id-equal.ts
|
|
850
850
|
/** @internal */
|
|
851
851
|
function isInstanceIdEqual(context, a, b) {
|
|
852
|
-
return AST.isNodeEqual(a, b) ||
|
|
852
|
+
return AST.isNodeEqual(a, b) || isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
|
|
853
853
|
}
|
|
854
854
|
|
|
855
855
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.0.1
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"birecord": "^0.1.1",
|
|
35
35
|
"ts-api-utils": "^2.1.0",
|
|
36
36
|
"ts-pattern": "^5.8.0",
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/
|
|
37
|
+
"@eslint-react/eff": "2.0.1",
|
|
38
|
+
"@eslint-react/ast": "2.0.1",
|
|
39
|
+
"@eslint-react/shared": "2.0.1",
|
|
40
|
+
"@eslint-react/var": "2.0.1",
|
|
41
|
+
"@eslint-react/kit": "2.0.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.15.4",
|