@eslint-react/core 1.43.0-next.0 → 1.43.1-next.0

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
@@ -1,8 +1,8 @@
1
- import { RuleContext } from '@eslint-react/kit';
2
1
  import { TSESTree } from '@typescript-eslint/types';
3
2
  import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
3
  import * as AST from '@eslint-react/ast';
5
4
  import { _ } from '@eslint-react/eff';
5
+ import { RuleContext } from '@eslint-react/kit';
6
6
  import * as birecord from 'birecord';
7
7
  import { Scope } from '@typescript-eslint/scope-manager';
8
8
 
@@ -163,8 +163,6 @@ declare function isUnsafeComponentWillUpdate(node: TSESTree.Node): node is AST.T
163
163
  declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
164
164
  declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
165
165
 
166
- declare const RE_COMPONENT_NAME: RegExp;
167
- declare const RE_COMPONENT_NAME_LOOSE: RegExp;
168
166
  declare function isComponentName(name: string): boolean;
169
167
  declare function isComponentNameLoose(name: string): boolean;
170
168
  declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
@@ -343,11 +341,6 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
343
341
  */
344
342
  declare function isPureComponent(node: TSESTree.Node): boolean;
345
343
 
346
- /**
347
- * The ESQuery selector for a component display name assignment expression
348
- */
349
- declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
350
-
351
344
  type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
352
345
 
353
346
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
@@ -372,9 +365,7 @@ declare function useHookCollector(): useHookCollector.ReturnType;
372
365
 
373
366
  type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
374
367
 
375
- declare const RE_HOOK_NAME: RegExp;
376
368
  declare function isReactHookName(name: string): boolean;
377
- declare function isReactHookNameLoose(name: string): boolean;
378
369
 
379
370
  declare function isReactHook(node: AST.TSESTreeFunction | _): boolean;
380
371
  /**
@@ -481,4 +472,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
481
472
  declare const isForwardRefCall: isCallFromReact.ReturnType;
482
473
  declare const isMemoCall: isCallFromReact.ReturnType;
483
474
 
484
- export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
475
+ export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, type EffectKind, type FunctionComponent, type Hook, type HookKind, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { RuleContext } from '@eslint-react/kit';
2
1
  import { TSESTree } from '@typescript-eslint/types';
3
2
  import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
3
  import * as AST from '@eslint-react/ast';
5
4
  import { _ } from '@eslint-react/eff';
5
+ import { RuleContext } from '@eslint-react/kit';
6
6
  import * as birecord from 'birecord';
7
7
  import { Scope } from '@typescript-eslint/scope-manager';
8
8
 
@@ -163,8 +163,6 @@ declare function isUnsafeComponentWillUpdate(node: TSESTree.Node): node is AST.T
163
163
  declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
164
164
  declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
165
165
 
166
- declare const RE_COMPONENT_NAME: RegExp;
167
- declare const RE_COMPONENT_NAME_LOOSE: RegExp;
168
166
  declare function isComponentName(name: string): boolean;
169
167
  declare function isComponentNameLoose(name: string): boolean;
170
168
  declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
@@ -343,11 +341,6 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
343
341
  */
344
342
  declare function isPureComponent(node: TSESTree.Node): boolean;
345
343
 
346
- /**
347
- * The ESQuery selector for a component display name assignment expression
348
- */
349
- declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
350
-
351
344
  type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
352
345
 
353
346
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
@@ -372,9 +365,7 @@ declare function useHookCollector(): useHookCollector.ReturnType;
372
365
 
373
366
  type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
374
367
 
375
- declare const RE_HOOK_NAME: RegExp;
376
368
  declare function isReactHookName(name: string): boolean;
377
- declare function isReactHookNameLoose(name: string): boolean;
378
369
 
379
370
  declare function isReactHook(node: AST.TSESTreeFunction | _): boolean;
380
371
  /**
@@ -481,4 +472,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
481
472
  declare const isForwardRefCall: isCallFromReact.ReturnType;
482
473
  declare const isMemoCall: isCallFromReact.ReturnType;
483
474
 
484
- export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
475
+ export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, type EffectKind, type FunctionComponent, type Hook, type HookKind, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -3,11 +3,11 @@
3
3
  var AST6 = require('@eslint-react/ast');
4
4
  var eff = require('@eslint-react/eff');
5
5
  var JSX3 = require('@eslint-react/jsx');
6
+ var kit = require('@eslint-react/kit');
6
7
  var shared = require('@eslint-react/shared');
7
8
  var types = require('@typescript-eslint/types');
8
9
  var VAR = require('@eslint-react/var');
9
10
  var tsPattern = require('ts-pattern');
10
- require('@eslint-react/kit');
11
11
  var birecord = require('birecord');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -37,15 +37,6 @@ var birecord__default = /*#__PURE__*/_interopDefault(birecord);
37
37
 
38
38
  // src/component/component-collector.ts
39
39
 
40
- // src/constants.ts
41
- var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
42
- "AssignmentExpression",
43
- "[type]",
44
- "[operator='=']",
45
- "[left.type='MemberExpression']",
46
- "[left.property.name='displayName']"
47
- ].join("");
48
-
49
40
  // ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
50
41
  var store;
51
42
  // @__NO_SIDE_EFFECTS__
@@ -653,11 +644,7 @@ var isForwardRefCall = isReactAPICall("forwardRef");
653
644
  var isMemoCall = isReactAPICall("memo");
654
645
 
655
646
  // src/hook/hook-name.ts
656
- var RE_HOOK_NAME = /^use[A-Z\d]/u;
657
647
  function isReactHookName(name) {
658
- return name === "use" || RE_HOOK_NAME.test(name);
659
- }
660
- function isReactHookNameLoose(name) {
661
648
  return name.startsWith("use");
662
649
  }
663
650
 
@@ -1062,13 +1049,11 @@ function getComponentFlagFromInitPath(initPath) {
1062
1049
  }
1063
1050
  return flag;
1064
1051
  }
1065
- var RE_COMPONENT_NAME = /^[A-Z]/u;
1066
- var RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
1067
1052
  function isComponentName(name) {
1068
- return RE_COMPONENT_NAME.test(name);
1053
+ return kit.RE.COMPONENT_NAME.test(name);
1069
1054
  }
1070
1055
  function isComponentNameLoose(name) {
1071
- return RE_COMPONENT_NAME_LOOSE.test(name);
1056
+ return kit.RE.COMPONENT_NAME_LOOSE.test(name);
1072
1057
  }
1073
1058
  function getComponentNameFromId(id) {
1074
1059
  if (id == null) return eff._;
@@ -1120,7 +1105,7 @@ function useComponentCollector(context, options = {}) {
1120
1105
  const listeners = {
1121
1106
  ":function[type]": onFunctionEnter,
1122
1107
  ":function[type]:exit": onFunctionExit,
1123
- "ArrowFunctionExpression[type][body.type!='BlockStatement']"() {
1108
+ "ArrowFunctionExpression[body.type!='BlockStatement']"() {
1124
1109
  const entry = getCurrentEntry();
1125
1110
  if (entry == null) return;
1126
1111
  const { body } = entry.node;
@@ -1144,7 +1129,7 @@ function useComponentCollector(context, options = {}) {
1144
1129
  });
1145
1130
  },
1146
1131
  ...collectDisplayName ? {
1147
- [DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
1132
+ [kit.SEL.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
1148
1133
  const { left, right } = node;
1149
1134
  if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
1150
1135
  const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
@@ -1275,10 +1260,6 @@ exports.ComponentDetectionHint = ComponentDetectionHint;
1275
1260
  exports.ComponentFlag = ComponentFlag;
1276
1261
  exports.ComponentPhaseRelevance = ComponentPhaseRelevance;
1277
1262
  exports.DEFAULT_COMPONENT_DETECTION_HINT = DEFAULT_COMPONENT_DETECTION_HINT;
1278
- exports.DISPLAY_NAME_ASSIGNMENT_SELECTOR = DISPLAY_NAME_ASSIGNMENT_SELECTOR;
1279
- exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
1280
- exports.RE_COMPONENT_NAME_LOOSE = RE_COMPONENT_NAME_LOOSE;
1281
- exports.RE_HOOK_NAME = RE_HOOK_NAME;
1282
1263
  exports.getComponentFlagFromInitPath = getComponentFlagFromInitPath;
1283
1264
  exports.getComponentNameFromId = getComponentNameFromId;
1284
1265
  exports.getFunctionComponentId = getFunctionComponentId;
@@ -1353,7 +1334,6 @@ exports.isReactHookCallWithName = isReactHookCallWithName;
1353
1334
  exports.isReactHookCallWithNameAlias = isReactHookCallWithNameAlias;
1354
1335
  exports.isReactHookCallWithNameLoose = isReactHookCallWithNameLoose;
1355
1336
  exports.isReactHookName = isReactHookName;
1356
- exports.isReactHookNameLoose = isReactHookNameLoose;
1357
1337
  exports.isRenderFunctionLoose = isRenderFunctionLoose;
1358
1338
  exports.isRenderLike = isRenderLike;
1359
1339
  exports.isRenderMethodLike = isRenderMethodLike;
package/dist/index.mjs CHANGED
@@ -1,24 +1,15 @@
1
1
  import * as AST6 from '@eslint-react/ast';
2
2
  import { flip, dual, constFalse, identity, _ } from '@eslint-react/eff';
3
3
  import * as JSX3 from '@eslint-react/jsx';
4
+ import { RE, SEL } from '@eslint-react/kit';
4
5
  import { DEFAULT_ESLINT_REACT_SETTINGS as DEFAULT_ESLINT_REACT_SETTINGS$1, unsafeDecodeSettings, getId } from '@eslint-react/shared';
5
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
6
7
  import * as VAR from '@eslint-react/var';
7
8
  import { isMatching, P, match } from 'ts-pattern';
8
- import '@eslint-react/kit';
9
9
  import birecord from 'birecord';
10
10
 
11
11
  // src/component/component-collector.ts
12
12
 
13
- // src/constants.ts
14
- var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
15
- "AssignmentExpression",
16
- "[type]",
17
- "[operator='=']",
18
- "[left.type='MemberExpression']",
19
- "[left.property.name='displayName']"
20
- ].join("");
21
-
22
13
  // ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
23
14
  var store;
24
15
  // @__NO_SIDE_EFFECTS__
@@ -626,11 +617,7 @@ var isForwardRefCall = isReactAPICall("forwardRef");
626
617
  var isMemoCall = isReactAPICall("memo");
627
618
 
628
619
  // src/hook/hook-name.ts
629
- var RE_HOOK_NAME = /^use[A-Z\d]/u;
630
620
  function isReactHookName(name) {
631
- return name === "use" || RE_HOOK_NAME.test(name);
632
- }
633
- function isReactHookNameLoose(name) {
634
621
  return name.startsWith("use");
635
622
  }
636
623
 
@@ -1035,13 +1022,11 @@ function getComponentFlagFromInitPath(initPath) {
1035
1022
  }
1036
1023
  return flag;
1037
1024
  }
1038
- var RE_COMPONENT_NAME = /^[A-Z]/u;
1039
- var RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
1040
1025
  function isComponentName(name) {
1041
- return RE_COMPONENT_NAME.test(name);
1026
+ return RE.COMPONENT_NAME.test(name);
1042
1027
  }
1043
1028
  function isComponentNameLoose(name) {
1044
- return RE_COMPONENT_NAME_LOOSE.test(name);
1029
+ return RE.COMPONENT_NAME_LOOSE.test(name);
1045
1030
  }
1046
1031
  function getComponentNameFromId(id) {
1047
1032
  if (id == null) return _;
@@ -1093,7 +1078,7 @@ function useComponentCollector(context, options = {}) {
1093
1078
  const listeners = {
1094
1079
  ":function[type]": onFunctionEnter,
1095
1080
  ":function[type]:exit": onFunctionExit,
1096
- "ArrowFunctionExpression[type][body.type!='BlockStatement']"() {
1081
+ "ArrowFunctionExpression[body.type!='BlockStatement']"() {
1097
1082
  const entry = getCurrentEntry();
1098
1083
  if (entry == null) return;
1099
1084
  const { body } = entry.node;
@@ -1117,7 +1102,7 @@ function useComponentCollector(context, options = {}) {
1117
1102
  });
1118
1103
  },
1119
1104
  ...collectDisplayName ? {
1120
- [DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
1105
+ [SEL.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
1121
1106
  const { left, right } = node;
1122
1107
  if (left.type !== AST_NODE_TYPES.MemberExpression) return;
1123
1108
  const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
@@ -1244,4 +1229,4 @@ function isAssignmentToThisState(node) {
1244
1229
  return left.type === AST_NODE_TYPES.MemberExpression && AST6.isThisExpression(left.object) && AST6.getPropertyName(left.property) === "state";
1245
1230
  }
1246
1231
 
1247
- export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
1232
+ export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.43.0-next.0",
3
+ "version": "1.43.1-next.0",
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": {
@@ -41,12 +41,12 @@
41
41
  "@typescript-eslint/utils": "^8.29.1",
42
42
  "birecord": "^0.1.1",
43
43
  "ts-pattern": "^5.7.0",
44
- "@eslint-react/ast": "1.43.0-next.0",
45
- "@eslint-react/eff": "1.43.0-next.0",
46
- "@eslint-react/kit": "1.43.0-next.0",
47
- "@eslint-react/jsx": "1.43.0-next.0",
48
- "@eslint-react/shared": "1.43.0-next.0",
49
- "@eslint-react/var": "1.43.0-next.0"
44
+ "@eslint-react/ast": "1.43.1-next.0",
45
+ "@eslint-react/kit": "1.43.1-next.0",
46
+ "@eslint-react/eff": "1.43.1-next.0",
47
+ "@eslint-react/jsx": "1.43.1-next.0",
48
+ "@eslint-react/shared": "1.43.1-next.0",
49
+ "@eslint-react/var": "1.43.1-next.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "tsup": "^8.4.0",