@eslint-react/core 2.3.2-next.2 → 2.3.2-next.5

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -5
  2. package/package.json +8 -8
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, getId } from "@eslint-react/shared";
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 = getId();
202
+ const key = idGen$2.next();
202
203
  const name = id?.name;
203
204
  if (name != null && isReactHookName(name)) {
204
205
  functionEntries.push({
@@ -895,6 +896,7 @@ function hasNoneOrLooseComponentName(context, fn) {
895
896
 
896
897
  //#endregion
897
898
  //#region src/component/component-collector.ts
899
+ const idGen$1 = new IdGenerator("function_component_");
898
900
  /**
899
901
  * Get a ctx and listeners for the rule to collect function components
900
902
  * @param context The ESLint rule context
@@ -907,7 +909,7 @@ function useComponentCollector(context, options = {}) {
907
909
  const functionEntries = [];
908
910
  const getCurrentEntry = () => functionEntries.at(-1);
909
911
  const onFunctionEnter = (node) => {
910
- const key = getId();
912
+ const key = idGen$1.next();
911
913
  functionEntries.push({
912
914
  key,
913
915
  node,
@@ -950,8 +952,8 @@ function useComponentCollector(context, options = {}) {
950
952
  if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isComponentDefinition(context, entry.node, hint))) return;
951
953
  const initPath = AST.getFunctionInitPath(entry.node);
952
954
  const id = getFunctionComponentId(context, entry.node);
955
+ const key = entry.key;
953
956
  const name = getComponentNameFromId(id);
954
- const key = getId();
955
957
  components.set(key, {
956
958
  id,
957
959
  key,
@@ -1006,6 +1008,7 @@ function useComponentCollector(context, options = {}) {
1006
1008
 
1007
1009
  //#endregion
1008
1010
  //#region src/component/component-collector-legacy.ts
1011
+ const idGen = new IdGenerator("class_component_");
1009
1012
  /**
1010
1013
  * Get a ctx and listeners object for the rule to collect class components
1011
1014
  * @returns The context and listeners for the rule
@@ -1018,7 +1021,7 @@ function useComponentCollectorLegacy() {
1018
1021
  const collect = (node) => {
1019
1022
  if (!isClassComponent(node)) return;
1020
1023
  const id = AST.getClassId(node);
1021
- const key = getId();
1024
+ const key = idGen.next();
1022
1025
  const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
1023
1026
  components.set(key, {
1024
1027
  id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.3.2-next.2",
3
+ "version": "2.3.2-next.5",
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,15 +30,15 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/scope-manager": "^8.46.2",
34
- "@typescript-eslint/types": "^8.46.2",
35
- "@typescript-eslint/utils": "^8.46.2",
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.2",
39
- "@eslint-react/shared": "2.3.2-next.2",
40
- "@eslint-react/var": "2.3.2-next.2",
41
- "@eslint-react/eff": "2.3.2-next.2"
38
+ "@eslint-react/ast": "2.3.2-next.5",
39
+ "@eslint-react/eff": "2.3.2-next.5",
40
+ "@eslint-react/var": "2.3.2-next.5",
41
+ "@eslint-react/shared": "2.3.2-next.5"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsdown": "^0.15.12",