@eslint-react/core 2.3.2-next.2 → 2.3.2-next.6
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 -5
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
2
2
|
import * as AST from "@eslint-react/ast";
|
|
3
3
|
import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
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
|
|
4
|
+
import { IdGenerator, 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/shared";
|
|
5
5
|
import { findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
|
|
6
6
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
7
7
|
import { P, isMatching, match } from "ts-pattern";
|
|
@@ -193,12 +193,13 @@ const isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
|
193
193
|
|
|
194
194
|
//#endregion
|
|
195
195
|
//#region src/hook/hook-collector.ts
|
|
196
|
+
const idGen$2 = new IdGenerator("hook_");
|
|
196
197
|
function useHookCollector() {
|
|
197
198
|
const hooks = /* @__PURE__ */ new Map();
|
|
198
199
|
const functionEntries = [];
|
|
199
200
|
const onFunctionEnter = (node) => {
|
|
200
201
|
const id = AST.getFunctionId(node);
|
|
201
|
-
const key =
|
|
202
|
+
const key = idGen$2.next();
|
|
202
203
|
const name = id?.name;
|
|
203
204
|
if (name != null && isReactHookName(name)) {
|
|
204
205
|
functionEntries.push({
|
|
@@ -752,6 +753,7 @@ function isComponentDefinition(context, node, hint) {
|
|
|
752
753
|
|
|
753
754
|
//#endregion
|
|
754
755
|
//#region src/utils/get-instance-id.ts
|
|
756
|
+
/** eslint-disable jsdoc/require-param */
|
|
755
757
|
/**
|
|
756
758
|
* Gets the identifier node of an instance based on AST node relationships.
|
|
757
759
|
* Used for tracking where hooks or components are being assigned in the code.
|
|
@@ -895,6 +897,7 @@ function hasNoneOrLooseComponentName(context, fn) {
|
|
|
895
897
|
|
|
896
898
|
//#endregion
|
|
897
899
|
//#region src/component/component-collector.ts
|
|
900
|
+
const idGen$1 = new IdGenerator("function_component_");
|
|
898
901
|
/**
|
|
899
902
|
* Get a ctx and listeners for the rule to collect function components
|
|
900
903
|
* @param context The ESLint rule context
|
|
@@ -907,7 +910,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
907
910
|
const functionEntries = [];
|
|
908
911
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
909
912
|
const onFunctionEnter = (node) => {
|
|
910
|
-
const key =
|
|
913
|
+
const key = idGen$1.next();
|
|
911
914
|
functionEntries.push({
|
|
912
915
|
key,
|
|
913
916
|
node,
|
|
@@ -950,8 +953,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
950
953
|
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isComponentDefinition(context, entry.node, hint))) return;
|
|
951
954
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
952
955
|
const id = getFunctionComponentId(context, entry.node);
|
|
956
|
+
const key = entry.key;
|
|
953
957
|
const name = getComponentNameFromId(id);
|
|
954
|
-
const key = getId();
|
|
955
958
|
components.set(key, {
|
|
956
959
|
id,
|
|
957
960
|
key,
|
|
@@ -1006,6 +1009,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1006
1009
|
|
|
1007
1010
|
//#endregion
|
|
1008
1011
|
//#region src/component/component-collector-legacy.ts
|
|
1012
|
+
const idGen = new IdGenerator("class_component_");
|
|
1009
1013
|
/**
|
|
1010
1014
|
* Get a ctx and listeners object for the rule to collect class components
|
|
1011
1015
|
* @returns The context and listeners for the rule
|
|
@@ -1018,7 +1022,7 @@ function useComponentCollectorLegacy() {
|
|
|
1018
1022
|
const collect = (node) => {
|
|
1019
1023
|
if (!isClassComponent(node)) return;
|
|
1020
1024
|
const id = AST.getClassId(node);
|
|
1021
|
-
const key =
|
|
1025
|
+
const key = idGen.next();
|
|
1022
1026
|
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
1023
1027
|
components.set(key, {
|
|
1024
1028
|
id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.3.2-next.
|
|
3
|
+
"version": "2.3.2-next.6",
|
|
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": {
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"./package.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@typescript-eslint/scope-manager": "^8.46.
|
|
34
|
-
"@typescript-eslint/types": "^8.46.
|
|
35
|
-
"@typescript-eslint/utils": "^8.46.
|
|
33
|
+
"@typescript-eslint/scope-manager": "^8.46.3",
|
|
34
|
+
"@typescript-eslint/types": "^8.46.3",
|
|
35
|
+
"@typescript-eslint/utils": "^8.46.3",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.3.2-next.
|
|
39
|
-
"@eslint-react/shared": "2.3.2-next.
|
|
40
|
-
"@eslint-react/var": "2.3.2-next.
|
|
41
|
-
"@eslint-react/eff": "2.3.2-next.
|
|
38
|
+
"@eslint-react/ast": "2.3.2-next.6",
|
|
39
|
+
"@eslint-react/shared": "2.3.2-next.6",
|
|
40
|
+
"@eslint-react/var": "2.3.2-next.6",
|
|
41
|
+
"@eslint-react/eff": "2.3.2-next.6"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"tsdown": "^0.
|
|
44
|
+
"tsdown": "^0.16.0",
|
|
45
45
|
"@local/configs": "0.0.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|