@eslint-react/core 1.23.1-next.1 → 1.23.1-next.2

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.d.mts CHANGED
@@ -85,7 +85,7 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
85
85
  readonly getCurrentFunctionStack: () => [key: string, node: AST.TSESTreeFunction, isComponent: boolean, hookCalls: TSESTree.CallExpression[]][];
86
86
  };
87
87
  readonly listeners: {
88
- readonly ":function[type]": (node: AST.TSESTreeFunction) => number;
88
+ readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
89
89
  readonly ":function[type]:exit": () => [key: string, node: AST.TSESTreeFunction, isComponent: boolean, hookCalls: TSESTree.CallExpression[]] | undefined;
90
90
  readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
91
91
  readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']": (node: TSESTree.Node) => void;
@@ -2560,4 +2560,11 @@ declare const isMemoCall: {
2560
2560
  (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2561
2561
  };
2562
2562
 
2563
- export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2563
+ declare function next(): number;
2564
+
2565
+ declare const uid_next: typeof next;
2566
+ declare namespace uid {
2567
+ export { uid_next as next };
2568
+ }
2569
+
2570
+ export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, uid, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -85,7 +85,7 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
85
85
  readonly getCurrentFunctionStack: () => [key: string, node: AST.TSESTreeFunction, isComponent: boolean, hookCalls: TSESTree.CallExpression[]][];
86
86
  };
87
87
  readonly listeners: {
88
- readonly ":function[type]": (node: AST.TSESTreeFunction) => number;
88
+ readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
89
89
  readonly ":function[type]:exit": () => [key: string, node: AST.TSESTreeFunction, isComponent: boolean, hookCalls: TSESTree.CallExpression[]] | undefined;
90
90
  readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
91
91
  readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']": (node: TSESTree.Node) => void;
@@ -2560,4 +2560,11 @@ declare const isMemoCall: {
2560
2560
  (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2561
2561
  };
2562
2562
 
2563
- export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2563
+ declare function next(): number;
2564
+
2565
+ declare const uid_next: typeof next;
2566
+ declare namespace uid {
2567
+ export { uid_next as next };
2568
+ }
2569
+
2570
+ export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, uid, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ var eff = require('@eslint-react/eff');
5
5
  var JSX4 = require('@eslint-react/jsx');
6
6
  var types = require('@typescript-eslint/types');
7
7
  var tsPattern = require('ts-pattern');
8
- var uid = require('uid');
9
8
  var shared = require('@eslint-react/shared');
10
9
  var VAR = require('@eslint-react/var');
11
10
  var types$1 = require('@eslint-react/types');
@@ -32,7 +31,11 @@ var AST9__namespace = /*#__PURE__*/_interopNamespace(AST9);
32
31
  var JSX4__namespace = /*#__PURE__*/_interopNamespace(JSX4);
33
32
  var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
34
33
 
35
- // src/component/component-collector.ts
34
+ var __defProp = Object.defineProperty;
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
36
39
  function getElementRepresentName(node, context) {
37
40
  const rawElementName = JSX4__namespace.getElementName(node);
38
41
  if (rawElementName === rawElementName.toLowerCase()) return rawElementName;
@@ -125,6 +128,16 @@ var isCreateRefCall = isReactAPICallWithName("createRef");
125
128
  var isForwardRefCall = isReactAPICallWithName("forwardRef");
126
129
  var isMemoCall = isReactAPICallWithName("memo");
127
130
 
131
+ // src/utils/uid.ts
132
+ var uid_exports = {};
133
+ __export(uid_exports, {
134
+ next: () => next
135
+ });
136
+ var id = 0;
137
+ function next() {
138
+ return id++;
139
+ }
140
+
128
141
  // src/element/hierarchy.ts
129
142
  function isInsideCreateElementProps(node, context) {
130
143
  return eff.F.pipe(
@@ -156,7 +169,7 @@ function isReactHookName(name) {
156
169
  function isReactHook(node) {
157
170
  return eff.F.pipe(
158
171
  AST9__namespace.getFunctionIdentifier(node),
159
- eff.O.flatMapNullable((id) => id.name),
172
+ eff.O.flatMapNullable((id2) => id2.name),
160
173
  eff.O.exists(isReactHookName)
161
174
  );
162
175
  }
@@ -243,14 +256,14 @@ function useHookCollector() {
243
256
  const hooks = /* @__PURE__ */ new Map();
244
257
  const fStack = [];
245
258
  const onFunctionEnter = (node) => {
246
- const id = AST9__namespace.getFunctionIdentifier(node);
247
- const name = eff.O.flatMapNullable(id, (id2) => id2.name);
248
- if (eff.O.isSome(id) && eff.O.isSome(name) && isReactHookName(name.value)) {
249
- const key = uid.uid(10);
259
+ const id2 = AST9__namespace.getFunctionIdentifier(node);
260
+ const name = eff.O.flatMapNullable(id2, (id3) => id3.name);
261
+ if (eff.O.isSome(id2) && eff.O.isSome(name) && isReactHookName(name.value)) {
262
+ const key = uid_exports.next().toString();
250
263
  fStack.push([node, eff.O.some(key)]);
251
264
  hooks.set(key, {
252
265
  _: key,
253
- id,
266
+ id: id2,
254
267
  kind: "function",
255
268
  name,
256
269
  node,
@@ -283,9 +296,9 @@ function useHookCollector() {
283
296
  eff.F.pipe(
284
297
  eff.O.Do,
285
298
  eff.O.bind("id", () => hookId),
286
- eff.O.bind("hook", ({ id }) => eff.O.fromNullable(hooks.get(id))),
287
- eff.O.map(({ id, hook }) => {
288
- hooks.set(id, {
299
+ eff.O.bind("hook", ({ id: id2 }) => eff.O.fromNullable(hooks.get(id2))),
300
+ eff.O.map(({ id: id2, hook }) => {
301
+ hooks.set(id2, {
289
302
  ...hook,
290
303
  hookCalls: [
291
304
  ...hook.hookCalls,
@@ -406,16 +419,16 @@ function useComponentCollectorLegacy() {
406
419
  };
407
420
  const collect = (node) => {
408
421
  if (!isClassComponent(node)) return;
409
- const id = AST9__namespace.getClassIdentifier(node);
410
- const key = uid.uid(10);
422
+ const id2 = AST9__namespace.getClassIdentifier(node);
423
+ const key = uid_exports.next().toString();
411
424
  const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
412
425
  components.set(
413
426
  key,
414
427
  {
415
428
  _: key,
416
- id,
429
+ id: id2,
417
430
  kind: "class",
418
- name: eff.O.flatMapNullable(id, (n) => n.name),
431
+ name: eff.O.flatMapNullable(id2, (n) => n.name),
419
432
  node,
420
433
  // TODO: Get displayName of class component
421
434
  displayName: eff.O.none(),
@@ -461,8 +474,8 @@ function hasNoneOrValidComponentName(node, context) {
461
474
  getFunctionComponentIdentifier(node, context),
462
475
  {
463
476
  onNone: eff.F.constTrue,
464
- onSome: (id) => {
465
- const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
477
+ onSome: (id2) => {
478
+ const name = Array.isArray(id2) ? id2.at(-1)?.name : id2.name;
466
479
  return !!name && isComponentName(name);
467
480
  }
468
481
  }
@@ -515,7 +528,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
515
528
  const components = /* @__PURE__ */ new Map();
516
529
  const functionStack = [];
517
530
  const getCurrentFunction = () => eff.O.fromNullable(functionStack.at(-1));
518
- const onFunctionEnter = (node) => functionStack.push([uid.uid(10), node, false, []]);
531
+ const onFunctionEnter = (node) => {
532
+ const key = uid_exports.next().toString();
533
+ functionStack.push([key, node, false, []]);
534
+ };
519
535
  const onFunctionExit = () => {
520
536
  const [key, fn, isComponent] = functionStack.at(-1) ?? [];
521
537
  if (!key || !fn || !isComponent) return functionStack.pop();
@@ -548,12 +564,12 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
548
564
  const isComponent = hasNoneOrValidComponentName(currentFn, context) && JSX4__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(currentFn, context, hint);
549
565
  if (!isComponent) return;
550
566
  const initPath = AST9__namespace.getFunctionInitPath(currentFn);
551
- const id = getFunctionComponentIdentifier(currentFn, context);
552
- const name = eff.O.flatMapNullable(id, getComponentNameFromIdentifier);
553
- const key = uid.uid(10);
567
+ const id2 = getFunctionComponentIdentifier(currentFn, context);
568
+ const name = eff.O.flatMapNullable(id2, getComponentNameFromIdentifier);
569
+ const key = uid_exports.next().toString();
554
570
  components.set(key, {
555
571
  _: key,
556
- id,
572
+ id: id2,
557
573
  kind: "function",
558
574
  name,
559
575
  node: currentFn,
@@ -595,11 +611,11 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
595
611
  functionStack.pop();
596
612
  functionStack.push([key, currentFn, true, []]);
597
613
  const initPath = AST9__namespace.getFunctionInitPath(currentFn);
598
- const id = getFunctionComponentIdentifier(currentFn, context);
599
- const name = eff.O.flatMapNullable(id, getComponentNameFromIdentifier);
614
+ const id2 = getFunctionComponentIdentifier(currentFn, context);
615
+ const name = eff.O.flatMapNullable(id2, getComponentNameFromIdentifier);
600
616
  components.set(key, {
601
617
  _: key,
602
- id,
618
+ id: id2,
603
619
  kind: "function",
604
620
  name,
605
621
  node: currentFn,
@@ -656,7 +672,7 @@ function isDeclaredInRenderPropLoose(node) {
656
672
  }
657
673
  function isRenderFunctionLoose(node, context) {
658
674
  const { body, parent } = node;
659
- if (eff.O.exists(AST9__namespace.getFunctionIdentifier(node), (id) => id.name.startsWith("render"))) {
675
+ if (eff.O.exists(AST9__namespace.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
660
676
  return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
661
677
  }
662
678
  return JSX4__namespace.isJSXValue(
@@ -758,6 +774,7 @@ exports.isUseRefCall = isUseRefCall;
758
774
  exports.isUseStateCall = isUseStateCall;
759
775
  exports.isUseSyncExternalStoreCall = isUseSyncExternalStoreCall;
760
776
  exports.isUseTransitionCall = isUseTransitionCall;
777
+ exports.uid = uid_exports;
761
778
  exports.useComponentCollector = useComponentCollector;
762
779
  exports.useComponentCollectorLegacy = useComponentCollectorLegacy;
763
780
  exports.useHookCollector = useHookCollector;
package/dist/index.mjs CHANGED
@@ -3,12 +3,15 @@ import { F, isString, O } from '@eslint-react/eff';
3
3
  import * as JSX4 from '@eslint-react/jsx';
4
4
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
5
5
  import { isMatching, P, match } from 'ts-pattern';
6
- import { uid } from 'uid';
7
6
  import { normalizeSettings, decodeSettings, unsafeReadSettings } from '@eslint-react/shared';
8
7
  import * as VAR from '@eslint-react/var';
9
8
  import { birecord } from '@eslint-react/types';
10
9
 
11
- // src/component/component-collector.ts
10
+ var __defProp = Object.defineProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
12
15
  function getElementRepresentName(node, context) {
13
16
  const rawElementName = JSX4.getElementName(node);
14
17
  if (rawElementName === rawElementName.toLowerCase()) return rawElementName;
@@ -101,6 +104,16 @@ var isCreateRefCall = isReactAPICallWithName("createRef");
101
104
  var isForwardRefCall = isReactAPICallWithName("forwardRef");
102
105
  var isMemoCall = isReactAPICallWithName("memo");
103
106
 
107
+ // src/utils/uid.ts
108
+ var uid_exports = {};
109
+ __export(uid_exports, {
110
+ next: () => next
111
+ });
112
+ var id = 0;
113
+ function next() {
114
+ return id++;
115
+ }
116
+
104
117
  // src/element/hierarchy.ts
105
118
  function isInsideCreateElementProps(node, context) {
106
119
  return F.pipe(
@@ -132,7 +145,7 @@ function isReactHookName(name) {
132
145
  function isReactHook(node) {
133
146
  return F.pipe(
134
147
  AST9.getFunctionIdentifier(node),
135
- O.flatMapNullable((id) => id.name),
148
+ O.flatMapNullable((id2) => id2.name),
136
149
  O.exists(isReactHookName)
137
150
  );
138
151
  }
@@ -219,14 +232,14 @@ function useHookCollector() {
219
232
  const hooks = /* @__PURE__ */ new Map();
220
233
  const fStack = [];
221
234
  const onFunctionEnter = (node) => {
222
- const id = AST9.getFunctionIdentifier(node);
223
- const name = O.flatMapNullable(id, (id2) => id2.name);
224
- if (O.isSome(id) && O.isSome(name) && isReactHookName(name.value)) {
225
- const key = uid(10);
235
+ const id2 = AST9.getFunctionIdentifier(node);
236
+ const name = O.flatMapNullable(id2, (id3) => id3.name);
237
+ if (O.isSome(id2) && O.isSome(name) && isReactHookName(name.value)) {
238
+ const key = uid_exports.next().toString();
226
239
  fStack.push([node, O.some(key)]);
227
240
  hooks.set(key, {
228
241
  _: key,
229
- id,
242
+ id: id2,
230
243
  kind: "function",
231
244
  name,
232
245
  node,
@@ -259,9 +272,9 @@ function useHookCollector() {
259
272
  F.pipe(
260
273
  O.Do,
261
274
  O.bind("id", () => hookId),
262
- O.bind("hook", ({ id }) => O.fromNullable(hooks.get(id))),
263
- O.map(({ id, hook }) => {
264
- hooks.set(id, {
275
+ O.bind("hook", ({ id: id2 }) => O.fromNullable(hooks.get(id2))),
276
+ O.map(({ id: id2, hook }) => {
277
+ hooks.set(id2, {
265
278
  ...hook,
266
279
  hookCalls: [
267
280
  ...hook.hookCalls,
@@ -382,16 +395,16 @@ function useComponentCollectorLegacy() {
382
395
  };
383
396
  const collect = (node) => {
384
397
  if (!isClassComponent(node)) return;
385
- const id = AST9.getClassIdentifier(node);
386
- const key = uid(10);
398
+ const id2 = AST9.getClassIdentifier(node);
399
+ const key = uid_exports.next().toString();
387
400
  const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
388
401
  components.set(
389
402
  key,
390
403
  {
391
404
  _: key,
392
- id,
405
+ id: id2,
393
406
  kind: "class",
394
- name: O.flatMapNullable(id, (n) => n.name),
407
+ name: O.flatMapNullable(id2, (n) => n.name),
395
408
  node,
396
409
  // TODO: Get displayName of class component
397
410
  displayName: O.none(),
@@ -437,8 +450,8 @@ function hasNoneOrValidComponentName(node, context) {
437
450
  getFunctionComponentIdentifier(node, context),
438
451
  {
439
452
  onNone: F.constTrue,
440
- onSome: (id) => {
441
- const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
453
+ onSome: (id2) => {
454
+ const name = Array.isArray(id2) ? id2.at(-1)?.name : id2.name;
442
455
  return !!name && isComponentName(name);
443
456
  }
444
457
  }
@@ -491,7 +504,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
491
504
  const components = /* @__PURE__ */ new Map();
492
505
  const functionStack = [];
493
506
  const getCurrentFunction = () => O.fromNullable(functionStack.at(-1));
494
- const onFunctionEnter = (node) => functionStack.push([uid(10), node, false, []]);
507
+ const onFunctionEnter = (node) => {
508
+ const key = uid_exports.next().toString();
509
+ functionStack.push([key, node, false, []]);
510
+ };
495
511
  const onFunctionExit = () => {
496
512
  const [key, fn, isComponent] = functionStack.at(-1) ?? [];
497
513
  if (!key || !fn || !isComponent) return functionStack.pop();
@@ -524,12 +540,12 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
524
540
  const isComponent = hasNoneOrValidComponentName(currentFn, context) && JSX4.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(currentFn, context, hint);
525
541
  if (!isComponent) return;
526
542
  const initPath = AST9.getFunctionInitPath(currentFn);
527
- const id = getFunctionComponentIdentifier(currentFn, context);
528
- const name = O.flatMapNullable(id, getComponentNameFromIdentifier);
529
- const key = uid(10);
543
+ const id2 = getFunctionComponentIdentifier(currentFn, context);
544
+ const name = O.flatMapNullable(id2, getComponentNameFromIdentifier);
545
+ const key = uid_exports.next().toString();
530
546
  components.set(key, {
531
547
  _: key,
532
- id,
548
+ id: id2,
533
549
  kind: "function",
534
550
  name,
535
551
  node: currentFn,
@@ -571,11 +587,11 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
571
587
  functionStack.pop();
572
588
  functionStack.push([key, currentFn, true, []]);
573
589
  const initPath = AST9.getFunctionInitPath(currentFn);
574
- const id = getFunctionComponentIdentifier(currentFn, context);
575
- const name = O.flatMapNullable(id, getComponentNameFromIdentifier);
590
+ const id2 = getFunctionComponentIdentifier(currentFn, context);
591
+ const name = O.flatMapNullable(id2, getComponentNameFromIdentifier);
576
592
  components.set(key, {
577
593
  _: key,
578
- id,
594
+ id: id2,
579
595
  kind: "function",
580
596
  name,
581
597
  node: currentFn,
@@ -632,7 +648,7 @@ function isDeclaredInRenderPropLoose(node) {
632
648
  }
633
649
  function isRenderFunctionLoose(node, context) {
634
650
  const { body, parent } = node;
635
- if (O.exists(AST9.getFunctionIdentifier(node), (id) => id.name.startsWith("render"))) {
651
+ if (O.exists(AST9.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
636
652
  return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
637
653
  }
638
654
  return JSX4.isJSXValue(
@@ -652,4 +668,4 @@ function isThisSetState(node) {
652
668
  return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
653
669
  }
654
670
 
655
- export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
671
+ export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, uid_exports as uid, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.23.1-next.1",
3
+ "version": "1.23.1-next.2",
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": {
@@ -38,13 +38,12 @@
38
38
  "@typescript-eslint/types": "^8.19.0",
39
39
  "@typescript-eslint/utils": "^8.19.0",
40
40
  "ts-pattern": "^5.6.0",
41
- "uid": "^2.0.2",
42
- "@eslint-react/eff": "1.23.1-next.1",
43
- "@eslint-react/ast": "1.23.1-next.1",
44
- "@eslint-react/shared": "1.23.1-next.1",
45
- "@eslint-react/jsx": "1.23.1-next.1",
46
- "@eslint-react/types": "1.23.1-next.1",
47
- "@eslint-react/var": "1.23.1-next.1"
41
+ "@eslint-react/ast": "1.23.1-next.2",
42
+ "@eslint-react/eff": "1.23.1-next.2",
43
+ "@eslint-react/jsx": "1.23.1-next.2",
44
+ "@eslint-react/shared": "1.23.1-next.2",
45
+ "@eslint-react/var": "1.23.1-next.2",
46
+ "@eslint-react/types": "1.23.1-next.2"
48
47
  },
49
48
  "devDependencies": {
50
49
  "tsup": "^8.3.5",