@eslint-react/core 5.2.3-next.2 → 5.2.4-beta.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 +12 -12
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Check, Extract, Traverse, is, isOneOf } from "@eslint-react/ast";
|
|
|
2
2
|
import { resolveImportSource } from "@eslint-react/var";
|
|
3
3
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
4
4
|
import "@eslint-react/eslint";
|
|
5
|
-
import {
|
|
5
|
+
import { randomBytes } from "node:crypto";
|
|
6
6
|
import { JsxDetectionHint, isJsxLike } from "@eslint-react/jsx";
|
|
7
7
|
import { RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
|
|
8
8
|
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils";
|
|
@@ -145,7 +145,7 @@ function isAPI(api) {
|
|
|
145
145
|
const func = (context, node) => {
|
|
146
146
|
if (node == null) return false;
|
|
147
147
|
const getText = (n) => context.sourceCode.getText(n);
|
|
148
|
-
const name = Extract.
|
|
148
|
+
const name = Extract.getFullyQualifiedName(node, getText);
|
|
149
149
|
if (name === api) return true;
|
|
150
150
|
if (name.endsWith(`.${api}`)) return true;
|
|
151
151
|
return false;
|
|
@@ -161,7 +161,7 @@ function isAPICall(api) {
|
|
|
161
161
|
const func = (context, node) => {
|
|
162
162
|
if (node == null) return false;
|
|
163
163
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
164
|
-
return isAPI(api)(context, Extract.
|
|
164
|
+
return isAPI(api)(context, Extract.unwrap(node.callee));
|
|
165
165
|
};
|
|
166
166
|
return dual(2, func);
|
|
167
167
|
}
|
|
@@ -375,7 +375,7 @@ function isThisSetStateCall(node) {
|
|
|
375
375
|
*/
|
|
376
376
|
function isAssignmentToThisState(node) {
|
|
377
377
|
const { left } = node;
|
|
378
|
-
return left.type === AST_NODE_TYPES.MemberExpression && left.object.type === AST_NODE_TYPES.ThisExpression && Extract.
|
|
378
|
+
return left.type === AST_NODE_TYPES.MemberExpression && left.object.type === AST_NODE_TYPES.ThisExpression && Extract.getPropertyName(left.property) === "state";
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
//#endregion
|
|
@@ -393,8 +393,8 @@ function getClassComponentCollector(context) {
|
|
|
393
393
|
const collect = (node) => {
|
|
394
394
|
if (!isClassComponent(node)) return;
|
|
395
395
|
const id = getClassId(node);
|
|
396
|
-
const key =
|
|
397
|
-
const name = id == null ? null : Extract.
|
|
396
|
+
const key = randomBytes(8).toString("hex");
|
|
397
|
+
const name = id == null ? null : Extract.getFullyQualifiedName(id, getText);
|
|
398
398
|
components.set(key, {
|
|
399
399
|
id,
|
|
400
400
|
key,
|
|
@@ -811,7 +811,7 @@ function isUseStateLikeCall(node, additionalStateHooks = { test: constFalse }) {
|
|
|
811
811
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
812
812
|
switch (true) {
|
|
813
813
|
case node.callee.type === AST_NODE_TYPES.Identifier: return node.callee.name === "useState" || additionalStateHooks.test(node.callee.name);
|
|
814
|
-
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier: return Extract.
|
|
814
|
+
case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier: return Extract.getPropertyName(node.callee.property) === "useState" || additionalStateHooks.test(node.callee.property.name);
|
|
815
815
|
}
|
|
816
816
|
return false;
|
|
817
817
|
}
|
|
@@ -850,12 +850,12 @@ function getFunctionComponentCollector(context, options = {}) {
|
|
|
850
850
|
const getText = (n) => context.sourceCode.getText(n);
|
|
851
851
|
const getCurrentEntry = () => functionEntries.at(-1) ?? null;
|
|
852
852
|
const onFunctionEnter = (node) => {
|
|
853
|
-
const key =
|
|
853
|
+
const key = randomBytes(8).toString("hex");
|
|
854
854
|
const exp = Traverse.findParent(node, (n) => n.type === AST_NODE_TYPES.ExportDefaultDeclaration);
|
|
855
855
|
const isExportDefault = exp != null;
|
|
856
|
-
const isExportDefaultDeclaration = exp != null && Extract.
|
|
856
|
+
const isExportDefaultDeclaration = exp != null && Extract.unwrap(exp.declaration) === node;
|
|
857
857
|
const id = getFunctionComponentId(context, node);
|
|
858
|
-
const name = id == null ? null : Extract.
|
|
858
|
+
const name = id == null ? null : Extract.getFullyQualifiedName(id, getText);
|
|
859
859
|
const initPath = getFunctionInitPath(node);
|
|
860
860
|
const directives = getFunctionDirectives(node);
|
|
861
861
|
const entry = {
|
|
@@ -942,12 +942,12 @@ function getHookCollector(context) {
|
|
|
942
942
|
const getCurrentEntry = () => functionEntries.at(-1) ?? null;
|
|
943
943
|
const onFunctionEnter = (node) => {
|
|
944
944
|
const id = getFunctionId(node);
|
|
945
|
-
const key =
|
|
945
|
+
const key = randomBytes(8).toString("hex");
|
|
946
946
|
const entry = {
|
|
947
947
|
id,
|
|
948
948
|
key,
|
|
949
949
|
kind: "hook",
|
|
950
|
-
name: id == null ? null : Extract.
|
|
950
|
+
name: id == null ? null : Extract.getFullyQualifiedName(id, getText),
|
|
951
951
|
directives: [],
|
|
952
952
|
flag: 0n,
|
|
953
953
|
hint: 0n,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4-beta.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,12 +34,11 @@
|
|
|
34
34
|
"@typescript-eslint/types": "^8.58.2",
|
|
35
35
|
"@typescript-eslint/utils": "^8.58.2",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
|
-
"
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/shared": "5.2.
|
|
42
|
-
"@eslint-react/var": "5.2.3-next.2"
|
|
37
|
+
"@eslint-react/ast": "5.2.4-beta.1",
|
|
38
|
+
"@eslint-react/jsx": "5.2.4-beta.1",
|
|
39
|
+
"@eslint-react/eslint": "5.2.4-beta.1",
|
|
40
|
+
"@eslint-react/var": "5.2.4-beta.1",
|
|
41
|
+
"@eslint-react/shared": "5.2.4-beta.1"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@typescript-eslint/typescript-estree": "^8.58.2",
|