@eslint-react/core 1.23.3-next.1 → 1.23.3-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
@@ -110,22 +110,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
110
110
  };
111
111
  };
112
112
 
113
- /**
114
- * Check if a node is a React class component
115
- * @param node The AST node to check
116
- * @returns `true` if the node is a class component, `false` otherwise
117
- */
118
- declare function isClassComponent(node: TSESTree$1.Node): node is AST.TSESTreeClass;
119
- /**
120
- * Check if a node is a React PureComponent
121
- * @param node The AST node to check
122
- * @returns `true` if the node is a pure component, `false` otherwise
123
- */
124
- declare function isPureComponent(node: TSESTree$1.Node): boolean;
125
- declare function isComponentDidMount(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
126
- declare function isComponentWillUnmount(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
127
- declare function isComponentDidMountFunction(node: TSESTree$1.Node): boolean;
128
- declare function isComponentWillUnmountFunction(node: TSESTree$1.Node): boolean;
129
113
  declare function useComponentCollectorLegacy(): {
130
114
  readonly ctx: {
131
115
  readonly getAllComponents: (_: TSESTree$1.Program) => Map<string, ERClassComponent>;
@@ -147,6 +131,7 @@ declare const RE_COMPONENT_NAME: RegExp;
147
131
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[]): string;
148
132
  declare function isComponentName(name: string): boolean;
149
133
 
134
+ declare function isRenderMethodLike(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
150
135
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
151
136
  /**
152
137
  * Check whether given node is declared inside class component's render block
@@ -165,6 +150,19 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
165
150
  */
166
151
  declare function isInsideRenderMethod(node: TSESTree$1.Node): boolean;
167
152
 
153
+ /**
154
+ * Check if a node is a React class component
155
+ * @param node The AST node to check
156
+ * @returns `true` if the node is a class component, `false` otherwise
157
+ */
158
+ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClass;
159
+ /**
160
+ * Check if a node is a React PureComponent
161
+ * @param node The AST node to check
162
+ * @returns `true` if the node is a pure component, `false` otherwise
163
+ */
164
+ declare function isPureComponent(node: TSESTree.Node): boolean;
165
+
168
166
  declare function hasNoneOrValidComponentName(node: AST.TSESTreeFunction, context: RuleContext): boolean;
169
167
 
170
168
  type EREffectKind = "effect" | "insertionEffect" | "layoutEffect";
@@ -242,6 +240,11 @@ declare const isUseStateCall: (node: TSESTree.CallExpression, context: Readonly<
242
240
  declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
243
241
  declare const isUseTransitionCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
244
242
 
243
+ declare function isComponentDidMount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
244
+ declare function isComponentWillUnmount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
245
+ declare function isComponentDidMountFunction(node: TSESTree.Node): boolean;
246
+ declare function isComponentWillUnmountFunction(node: TSESTree.Node): boolean;
247
+
245
248
  declare const ERPhaseRelevance: _eslint_react_types.BiRecord<{
246
249
  readonly mount: "unmount";
247
250
  readonly setup: "cleanup";
@@ -2570,4 +2573,4 @@ declare const isMemoCall: {
2570
2573
  (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2571
2574
  };
2572
2575
 
2573
- 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, getId, 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 };
2576
+ 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, getId, 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, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -110,22 +110,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
110
110
  };
111
111
  };
112
112
 
113
- /**
114
- * Check if a node is a React class component
115
- * @param node The AST node to check
116
- * @returns `true` if the node is a class component, `false` otherwise
117
- */
118
- declare function isClassComponent(node: TSESTree$1.Node): node is AST.TSESTreeClass;
119
- /**
120
- * Check if a node is a React PureComponent
121
- * @param node The AST node to check
122
- * @returns `true` if the node is a pure component, `false` otherwise
123
- */
124
- declare function isPureComponent(node: TSESTree$1.Node): boolean;
125
- declare function isComponentDidMount(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
126
- declare function isComponentWillUnmount(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
127
- declare function isComponentDidMountFunction(node: TSESTree$1.Node): boolean;
128
- declare function isComponentWillUnmountFunction(node: TSESTree$1.Node): boolean;
129
113
  declare function useComponentCollectorLegacy(): {
130
114
  readonly ctx: {
131
115
  readonly getAllComponents: (_: TSESTree$1.Program) => Map<string, ERClassComponent>;
@@ -147,6 +131,7 @@ declare const RE_COMPONENT_NAME: RegExp;
147
131
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[]): string;
148
132
  declare function isComponentName(name: string): boolean;
149
133
 
134
+ declare function isRenderMethodLike(node: TSESTree$1.Node): node is TSESTree$1.MethodDefinition | TSESTree$1.PropertyDefinition;
150
135
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
151
136
  /**
152
137
  * Check whether given node is declared inside class component's render block
@@ -165,6 +150,19 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
165
150
  */
166
151
  declare function isInsideRenderMethod(node: TSESTree$1.Node): boolean;
167
152
 
153
+ /**
154
+ * Check if a node is a React class component
155
+ * @param node The AST node to check
156
+ * @returns `true` if the node is a class component, `false` otherwise
157
+ */
158
+ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClass;
159
+ /**
160
+ * Check if a node is a React PureComponent
161
+ * @param node The AST node to check
162
+ * @returns `true` if the node is a pure component, `false` otherwise
163
+ */
164
+ declare function isPureComponent(node: TSESTree.Node): boolean;
165
+
168
166
  declare function hasNoneOrValidComponentName(node: AST.TSESTreeFunction, context: RuleContext): boolean;
169
167
 
170
168
  type EREffectKind = "effect" | "insertionEffect" | "layoutEffect";
@@ -242,6 +240,11 @@ declare const isUseStateCall: (node: TSESTree.CallExpression, context: Readonly<
242
240
  declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
243
241
  declare const isUseTransitionCall: (node: TSESTree.CallExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
244
242
 
243
+ declare function isComponentDidMount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
244
+ declare function isComponentWillUnmount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
245
+ declare function isComponentDidMountFunction(node: TSESTree.Node): boolean;
246
+ declare function isComponentWillUnmountFunction(node: TSESTree.Node): boolean;
247
+
245
248
  declare const ERPhaseRelevance: _eslint_react_types.BiRecord<{
246
249
  readonly mount: "unmount";
247
250
  readonly setup: "cleanup";
@@ -2570,4 +2573,4 @@ declare const isMemoCall: {
2570
2573
  (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2571
2574
  };
2572
2575
 
2573
- 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, getId, 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 };
2576
+ 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, getId, 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, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var AST9 = require('@eslint-react/ast');
3
+ var AST8 = require('@eslint-react/ast');
4
4
  var eff = require('@eslint-react/eff');
5
5
  var JSX4 = require('@eslint-react/jsx');
6
- var types = require('@typescript-eslint/types');
6
+ var types$1 = require('@typescript-eslint/types');
7
7
  var tsPattern = require('ts-pattern');
8
8
  var shared = require('@eslint-react/shared');
9
9
  var VAR = require('@eslint-react/var');
10
- var types$1 = require('@eslint-react/types');
10
+ var types = require('@eslint-react/types');
11
11
 
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var AST9__namespace = /*#__PURE__*/_interopNamespace(AST9);
30
+ var AST8__namespace = /*#__PURE__*/_interopNamespace(AST8);
31
31
  var JSX4__namespace = /*#__PURE__*/_interopNamespace(JSX4);
32
32
  var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
33
33
 
@@ -67,14 +67,14 @@ function isFromReact(name) {
67
67
  return (node, context) => {
68
68
  const settings = shared.unsafeDecodeSettings(context.settings);
69
69
  if (!settings.strictImportCheck) {
70
- if (node.type === types.AST_NODE_TYPES.MemberExpression) {
71
- return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name;
70
+ if (node.type === types$1.AST_NODE_TYPES.MemberExpression) {
71
+ return node.object.type === types$1.AST_NODE_TYPES.Identifier && node.property.type === types$1.AST_NODE_TYPES.Identifier && node.property.name === name;
72
72
  }
73
73
  return node.name === name;
74
74
  }
75
75
  const initialScope = context.sourceCode.getScope(node);
76
- if (node.type === types.AST_NODE_TYPES.MemberExpression) {
77
- return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, initialScope, settings.importSource);
76
+ if (node.type === types$1.AST_NODE_TYPES.MemberExpression) {
77
+ return node.object.type === types$1.AST_NODE_TYPES.Identifier && node.property.type === types$1.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, initialScope, settings.importSource);
78
78
  }
79
79
  if (node.name === name) {
80
80
  return isInitializedFromReact(name, initialScope, settings.importSource);
@@ -86,25 +86,25 @@ function isFromReactMember(memberName, name) {
86
86
  return (node, context) => {
87
87
  const settings = shared.unsafeDecodeSettings(context.settings);
88
88
  if (!settings.strictImportCheck) {
89
- if (node.property.type !== types.AST_NODE_TYPES.Identifier || node.property.name !== name) {
89
+ if (node.property.type !== types$1.AST_NODE_TYPES.Identifier || node.property.name !== name) {
90
90
  return false;
91
91
  }
92
- if (node.object.type === types.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
92
+ if (node.object.type === types$1.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
93
93
  return true;
94
94
  }
95
- if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
95
+ if (node.object.type === types$1.AST_NODE_TYPES.MemberExpression && node.object.object.type === types$1.AST_NODE_TYPES.Identifier && node.object.property.type === types$1.AST_NODE_TYPES.Identifier) {
96
96
  return node.object.property.name === memberName;
97
97
  }
98
98
  return false;
99
99
  }
100
100
  const initialScope = context.sourceCode.getScope(node);
101
- if (node.property.type !== types.AST_NODE_TYPES.Identifier || node.property.name !== name) {
101
+ if (node.property.type !== types$1.AST_NODE_TYPES.Identifier || node.property.name !== name) {
102
102
  return false;
103
103
  }
104
- if (node.object.type === types.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
104
+ if (node.object.type === types$1.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
105
105
  return isInitializedFromReact(node.object.name, initialScope, settings.importSource);
106
106
  }
107
- if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, initialScope, settings.importSource) && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
107
+ if (node.object.type === types$1.AST_NODE_TYPES.MemberExpression && node.object.object.type === types$1.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, initialScope, settings.importSource) && node.object.property.type === types$1.AST_NODE_TYPES.Identifier) {
108
108
  return node.object.property.name === memberName;
109
109
  }
110
110
  return false;
@@ -112,10 +112,10 @@ function isFromReactMember(memberName, name) {
112
112
  }
113
113
  function isCallFromReact(name) {
114
114
  return eff.F.dual(2, (node, context) => {
115
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
115
+ if (node.type !== types$1.AST_NODE_TYPES.CallExpression) {
116
116
  return false;
117
117
  }
118
- if (!AST9__namespace.isOneOf([types.AST_NODE_TYPES.Identifier, types.AST_NODE_TYPES.MemberExpression])(node.callee)) {
118
+ if (!AST8__namespace.isOneOf([types$1.AST_NODE_TYPES.Identifier, types$1.AST_NODE_TYPES.MemberExpression])(node.callee)) {
119
119
  return false;
120
120
  }
121
121
  return isFromReact(name)(node.callee, context);
@@ -123,10 +123,10 @@ function isCallFromReact(name) {
123
123
  }
124
124
  function isCallFromReactMember(pragmaMemberName, name) {
125
125
  return eff.F.dual(2, (node, context) => {
126
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
126
+ if (node.type !== types$1.AST_NODE_TYPES.CallExpression) {
127
127
  return false;
128
128
  }
129
- if (!AST9__namespace.is(types.AST_NODE_TYPES.MemberExpression)(node.callee)) {
129
+ if (!AST8__namespace.is(types$1.AST_NODE_TYPES.MemberExpression)(node.callee)) {
130
130
  return false;
131
131
  }
132
132
  return isFromReactMember(pragmaMemberName, name)(node.callee, context);
@@ -167,8 +167,8 @@ var isMemoCall = isReactAPICallWithName("memo");
167
167
  function isInsideCreateElementProps(node, context) {
168
168
  return eff.F.pipe(
169
169
  eff.O.Do,
170
- eff.O.bind("call", () => AST9__namespace.findParentNodeGuard(node, isCreateElementCall(context))),
171
- eff.O.bind("prop", () => AST9__namespace.findParentNodeGuard(node, AST9__namespace.is(types.AST_NODE_TYPES.ObjectExpression))),
170
+ eff.O.bind("call", () => AST8__namespace.findParentNodeGuard(node, isCreateElementCall(context))),
171
+ eff.O.bind("prop", () => AST8__namespace.findParentNodeGuard(node, AST8__namespace.is(types$1.AST_NODE_TYPES.ObjectExpression))),
172
172
  eff.O.bind("arg1", ({ call }) => eff.O.fromNullable(call.arguments[1])),
173
173
  eff.O.exists(({ arg1, prop }) => prop === arg1)
174
174
  );
@@ -176,7 +176,7 @@ function isInsideCreateElementProps(node, context) {
176
176
  function isChildrenOfCreateElement(node, context) {
177
177
  return eff.F.pipe(
178
178
  eff.O.fromNullable(node.parent),
179
- eff.O.filter(AST9__namespace.is(types.AST_NODE_TYPES.CallExpression)),
179
+ eff.O.filter(AST8__namespace.is(types$1.AST_NODE_TYPES.CallExpression)),
180
180
  eff.O.filter(isCreateElementCall(context)),
181
181
  eff.O.exists(
182
182
  (n) => n.arguments.slice(2).some((arg) => arg === node)
@@ -193,20 +193,20 @@ function isReactHookName(name) {
193
193
  // src/hook/is.ts
194
194
  function isReactHook(node) {
195
195
  return eff.F.pipe(
196
- AST9__namespace.getFunctionIdentifier(node),
196
+ AST8__namespace.getFunctionIdentifier(node),
197
197
  eff.O.flatMapNullable((id2) => id2.name),
198
198
  eff.O.exists(isReactHookName)
199
199
  );
200
200
  }
201
201
  function isReactHookCall(node) {
202
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
202
+ if (node.type !== types$1.AST_NODE_TYPES.CallExpression) {
203
203
  return false;
204
204
  }
205
- if (node.callee.type === types.AST_NODE_TYPES.Identifier) {
205
+ if (node.callee.type === types$1.AST_NODE_TYPES.Identifier) {
206
206
  return isReactHookName(node.callee.name);
207
207
  }
208
- if (node.callee.type === types.AST_NODE_TYPES.MemberExpression) {
209
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
208
+ if (node.callee.type === types$1.AST_NODE_TYPES.MemberExpression) {
209
+ return node.callee.property.type === types$1.AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
210
210
  }
211
211
  return false;
212
212
  }
@@ -215,9 +215,9 @@ function isReactHookCallWithName(node, context) {
215
215
  return (name) => {
216
216
  const initialScope = context.sourceCode.getScope(node);
217
217
  switch (true) {
218
- case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
218
+ case (node.callee.type === types$1.AST_NODE_TYPES.Identifier && node.callee.name === name):
219
219
  return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
220
- case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
220
+ case (node.callee.type === types$1.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types$1.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
221
221
  return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
222
222
  default:
223
223
  return false;
@@ -227,10 +227,10 @@ function isReactHookCallWithName(node, context) {
227
227
  function isReactHookCallWithNameLoose(node) {
228
228
  return (name) => {
229
229
  switch (node.callee.type) {
230
- case types.AST_NODE_TYPES.Identifier:
230
+ case types$1.AST_NODE_TYPES.Identifier:
231
231
  return node.callee.name === name;
232
- case types.AST_NODE_TYPES.MemberExpression:
233
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name;
232
+ case types$1.AST_NODE_TYPES.MemberExpression:
233
+ return node.callee.property.type === types$1.AST_NODE_TYPES.Identifier && node.callee.property.name === name;
234
234
  default:
235
235
  return false;
236
236
  }
@@ -241,9 +241,9 @@ function isReactHookCallWithNameAlias(name, context, alias) {
241
241
  return (node) => {
242
242
  const initialScope = context.sourceCode.getScope(node);
243
243
  switch (true) {
244
- case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
244
+ case (node.callee.type === types$1.AST_NODE_TYPES.Identifier && node.callee.name === name):
245
245
  return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
246
- case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
246
+ case (node.callee.type === types$1.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types$1.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
247
247
  return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
248
248
  default:
249
249
  return alias.some(isReactHookCallWithNameLoose(node));
@@ -251,14 +251,14 @@ function isReactHookCallWithNameAlias(name, context, alias) {
251
251
  };
252
252
  }
253
253
  function isUseEffectCallLoose(node) {
254
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
254
+ if (node.type !== types$1.AST_NODE_TYPES.CallExpression) {
255
255
  return false;
256
256
  }
257
257
  switch (node.callee.type) {
258
- case types.AST_NODE_TYPES.Identifier:
258
+ case types$1.AST_NODE_TYPES.Identifier:
259
259
  return /^use\w*Effect$/u.test(node.callee.name);
260
- case types.AST_NODE_TYPES.MemberExpression:
261
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
260
+ case types$1.AST_NODE_TYPES.MemberExpression:
261
+ return node.callee.property.type === types$1.AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
262
262
  default:
263
263
  return false;
264
264
  }
@@ -281,13 +281,13 @@ var isUseTransitionCall = eff.F.flip(isReactHookCallWithName)("useTransition");
281
281
 
282
282
  // src/hook/hierarchy.ts
283
283
  function isInsideReactHook(node) {
284
- return eff.O.exists(AST9__namespace.findParentNodeGuard(node, AST9__namespace.isFunction), isReactHook);
284
+ return eff.O.exists(AST8__namespace.findParentNodeGuard(node, AST8__namespace.isFunction), isReactHook);
285
285
  }
286
286
  function useHookCollector() {
287
287
  const hooks = /* @__PURE__ */ new Map();
288
288
  const fStack = [];
289
289
  const onFunctionEnter = (node) => {
290
- const id2 = AST9__namespace.getFunctionIdentifier(node);
290
+ const id2 = AST8__namespace.getFunctionIdentifier(node);
291
291
  const name = eff.O.flatMapNullable(id2, (id3) => id3.name);
292
292
  if (eff.O.isSome(id2) && eff.O.isSome(name) && isReactHookName(name.value)) {
293
293
  const key = getId();
@@ -383,21 +383,21 @@ var ERFunctionComponentFlag = {
383
383
  // Async: 1n << 4n,
384
384
  };
385
385
  function isComponentWrapperCall(node, context) {
386
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
386
+ if (node.type !== types$1.AST_NODE_TYPES.CallExpression) {
387
387
  return false;
388
388
  }
389
389
  return isMemoCall(node, context) || isForwardRefCall(node, context) || isReactHookCallWithNameLoose(node)("useCallback");
390
390
  }
391
391
  function getFunctionComponentIdentifier(node, context) {
392
- const functionId = AST9__namespace.getFunctionIdentifier(node);
392
+ const functionId = AST8__namespace.getFunctionIdentifier(node);
393
393
  if (eff.O.isSome(functionId)) {
394
394
  return functionId;
395
395
  }
396
396
  const { parent } = node;
397
- if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
397
+ if (parent.type === types$1.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === types$1.AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === types$1.AST_NODE_TYPES.Identifier) {
398
398
  return eff.O.some(parent.parent.id);
399
399
  }
400
- if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent.parent, context) && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
400
+ if (parent.type === types$1.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === types$1.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent.parent, context) && parent.parent.parent.type === types$1.AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === types$1.AST_NODE_TYPES.Identifier) {
401
401
  return eff.O.some(parent.parent.parent.id);
402
402
  }
403
403
  return eff.O.none();
@@ -412,94 +412,34 @@ function isComponentName(name) {
412
412
  return !!name && RE_COMPONENT_NAME.test(name);
413
413
  }
414
414
  function isClassComponent(node) {
415
- if (!("superClass" in node && node.superClass)) {
416
- return false;
415
+ if ("superClass" in node && node.superClass) {
416
+ const re = /^(?:Pure)?Component$/u;
417
+ switch (true) {
418
+ case node.superClass.type === types$1.AST_NODE_TYPES.Identifier:
419
+ return re.test(node.superClass.name);
420
+ case (node.superClass.type === types$1.AST_NODE_TYPES.MemberExpression && node.superClass.property.type === types$1.AST_NODE_TYPES.Identifier):
421
+ return re.test(node.superClass.property.name);
422
+ }
417
423
  }
418
- const { superClass } = node;
419
- return tsPattern.match(superClass).with({
420
- type: types.AST_NODE_TYPES.Identifier,
421
- name: tsPattern.P.string
422
- }, ({ name }) => /^(?:Pure)?Component$/u.test(name)).with({
423
- type: types.AST_NODE_TYPES.MemberExpression,
424
- property: { name: tsPattern.P.string }
425
- }, ({ property }) => /^(?:Pure)?Component$/u.test(property.name)).otherwise(() => false);
424
+ return false;
426
425
  }
427
426
  function isPureComponent(node) {
428
427
  if ("superClass" in node && node.superClass) {
429
- return tsPattern.match(node.superClass).with({
430
- type: types.AST_NODE_TYPES.Identifier,
431
- name: tsPattern.P.string
432
- }, ({ name }) => /^PureComponent$/u.test(name)).with({
433
- type: types.AST_NODE_TYPES.MemberExpression,
434
- property: { name: tsPattern.P.string }
435
- }, ({ property }) => /^PureComponent$/u.test(property.name)).otherwise(() => false);
428
+ const re = /^PureComponent$/u;
429
+ switch (true) {
430
+ case node.superClass.type === types$1.AST_NODE_TYPES.Identifier:
431
+ return re.test(node.superClass.name);
432
+ case (node.superClass.type === types$1.AST_NODE_TYPES.MemberExpression && node.superClass.property.type === types$1.AST_NODE_TYPES.Identifier):
433
+ return re.test(node.superClass.property.name);
434
+ }
436
435
  }
437
436
  return false;
438
437
  }
439
- function isComponentDidMount(node) {
440
- return AST9__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
441
- }
442
- function isComponentWillUnmount(node) {
443
- return AST9__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
444
- }
445
- function isComponentDidMountFunction(node) {
446
- return AST9__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
447
- }
448
- function isComponentWillUnmountFunction(node) {
449
- return AST9__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
450
- }
451
- function useComponentCollectorLegacy() {
452
- const components = /* @__PURE__ */ new Map();
453
- const ctx = {
454
- getAllComponents(_) {
455
- return components;
456
- }
457
- };
458
- const collect = (node) => {
459
- if (!isClassComponent(node)) {
460
- return;
461
- }
462
- const id2 = AST9__namespace.getClassIdentifier(node);
463
- const key = getId();
464
- const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
465
- components.set(
466
- key,
467
- {
468
- _: key,
469
- id: id2,
470
- kind: "class",
471
- name: eff.O.flatMapNullable(id2, (n) => n.name),
472
- node,
473
- // TODO: Get displayName of class component
474
- displayName: eff.O.none(),
475
- flag,
476
- hint: 0n,
477
- // TODO: Get methods of class component
478
- methods: []
479
- }
480
- );
481
- };
482
- const listeners = {
483
- "ClassDeclaration[type]": collect,
484
- "ClassExpression[type]": collect
485
- };
486
- return { ctx, listeners };
487
- }
488
438
 
489
439
  // src/component/component-render-method.ts
490
- var isRenderMethodLike = tsPattern.isMatching({
491
- key: {
492
- type: types.AST_NODE_TYPES.Identifier,
493
- name: "render"
494
- },
495
- type: tsPattern.P.union(types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition),
496
- parent: {
497
- type: types.AST_NODE_TYPES.ClassBody,
498
- parent: {
499
- type: types.AST_NODE_TYPES.ClassDeclaration
500
- }
501
- }
502
- });
440
+ function isRenderMethodLike(node) {
441
+ return (node.type === types$1.AST_NODE_TYPES.MethodDefinition || node.type === types$1.AST_NODE_TYPES.PropertyDefinition) && node.key.type === types$1.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types$1.AST_NODE_TYPES.ClassDeclaration;
442
+ }
503
443
  function isFunctionOfRenderMethod(node) {
504
444
  if (!isRenderMethodLike(node.parent)) {
505
445
  return false;
@@ -507,9 +447,7 @@ function isFunctionOfRenderMethod(node) {
507
447
  return isClassComponent(node.parent.parent.parent);
508
448
  }
509
449
  function isInsideRenderMethod(node) {
510
- return eff.O.isSome(AST9__namespace.findParentNode(node, (node2) => {
511
- return isRenderMethodLike(node2) && isClassComponent(node2.parent.parent);
512
- }));
450
+ return eff.O.isSome(AST8__namespace.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)));
513
451
  }
514
452
  function hasNoneOrValidComponentName(node, context) {
515
453
  const mbIdentifier = getFunctionComponentIdentifier(node, context);
@@ -526,38 +464,38 @@ function hasValidHierarchy(node, context, hint) {
526
464
  if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
527
465
  return false;
528
466
  }
529
- if (hint & ERComponentHint.SkipMapCallback && AST9__namespace.isMapCallLoose(node.parent)) {
467
+ if (hint & ERComponentHint.SkipMapCallback && AST8__namespace.isMapCallLoose(node.parent)) {
530
468
  return false;
531
469
  }
532
- if (hint & ERComponentHint.SkipObjectMethod && AST9__namespace.isFunctionOfObjectMethod(node.parent)) {
470
+ if (hint & ERComponentHint.SkipObjectMethod && AST8__namespace.isFunctionOfObjectMethod(node.parent)) {
533
471
  return false;
534
472
  }
535
- if (hint & ERComponentHint.SkipClassMethod && AST9__namespace.isFunctionOfClassMethod(node.parent)) {
473
+ if (hint & ERComponentHint.SkipClassMethod && AST8__namespace.isFunctionOfClassMethod(node.parent)) {
536
474
  return false;
537
475
  }
538
- if (hint & ERComponentHint.SkipClassProperty && AST9__namespace.isFunctionOfClassProperty(node.parent)) {
476
+ if (hint & ERComponentHint.SkipClassProperty && AST8__namespace.isFunctionOfClassProperty(node.parent)) {
539
477
  return false;
540
478
  }
541
479
  return !eff.O.exists(
542
- AST9__namespace.findParentNode(
480
+ AST8__namespace.findParentNode(
543
481
  node,
544
- AST9__namespace.isOneOf([
545
- types.AST_NODE_TYPES.JSXExpressionContainer,
546
- types.AST_NODE_TYPES.ArrowFunctionExpression,
547
- types.AST_NODE_TYPES.FunctionExpression,
548
- types.AST_NODE_TYPES.Property,
549
- types.AST_NODE_TYPES.ClassBody
482
+ AST8__namespace.isOneOf([
483
+ types$1.AST_NODE_TYPES.JSXExpressionContainer,
484
+ types$1.AST_NODE_TYPES.ArrowFunctionExpression,
485
+ types$1.AST_NODE_TYPES.FunctionExpression,
486
+ types$1.AST_NODE_TYPES.Property,
487
+ types$1.AST_NODE_TYPES.ClassBody
550
488
  ])
551
489
  ),
552
- AST9__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)
490
+ AST8__namespace.is(types$1.AST_NODE_TYPES.JSXExpressionContainer)
553
491
  );
554
492
  }
555
493
  function getComponentFlag(initPath) {
556
494
  let flag = ERFunctionComponentFlag.None;
557
- if (AST9__namespace.hasCallInFunctionInitPath("memo")(initPath)) {
495
+ if (AST8__namespace.hasCallInFunctionInitPath("memo")(initPath)) {
558
496
  flag |= ERFunctionComponentFlag.Memo;
559
497
  }
560
- if (AST9__namespace.hasCallInFunctionInitPath("forwardRef")(initPath)) {
498
+ if (AST8__namespace.hasCallInFunctionInitPath("forwardRef")(initPath)) {
561
499
  flag |= ERFunctionComponentFlag.ForwardRef;
562
500
  }
563
501
  return flag;
@@ -576,7 +514,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
576
514
  if (!key || !node || !isComponent) {
577
515
  return functionEntries.pop();
578
516
  }
579
- const shouldDrop = AST9__namespace.getNestedReturnStatements(node.body).slice().reverse().some((r) => {
517
+ const shouldDrop = AST8__namespace.getNestedReturnStatements(node.body).slice().reverse().some((r) => {
580
518
  return context.sourceCode.getScope(r).block === node && r.argument !== null && !JSX4__namespace.isJSXValue(r.argument, jsxCtx, hint);
581
519
  });
582
520
  if (shouldDrop) {
@@ -607,7 +545,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
607
545
  if (!isComponent) {
608
546
  return;
609
547
  }
610
- const initPath = AST9__namespace.getFunctionInitPath(entry.node);
548
+ const initPath = AST8__namespace.getFunctionInitPath(entry.node);
611
549
  const id2 = getFunctionComponentIdentifier(entry.node, context);
612
550
  const name = eff.O.flatMapNullable(id2, getComponentNameFromIdentifier);
613
551
  const key = getId();
@@ -626,7 +564,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
626
564
  },
627
565
  "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']"(node) {
628
566
  const { left, right } = node;
629
- const mbComponentName = tsPattern.match(left.object).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => eff.O.some(n.name)).otherwise(eff.O.none);
567
+ const mbComponentName = tsPattern.match(left.object).with({ type: types$1.AST_NODE_TYPES.Identifier }, (n) => eff.O.some(n.name)).otherwise(eff.O.none);
630
568
  if (eff.O.isNone(mbComponentName)) {
631
569
  return;
632
570
  }
@@ -664,7 +602,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
664
602
  }
665
603
  functionEntries.pop();
666
604
  functionEntries.push({ ...entry, isComponent });
667
- const initPath = AST9__namespace.getFunctionInitPath(entry.node);
605
+ const initPath = AST8__namespace.getFunctionInitPath(entry.node);
668
606
  const id2 = getFunctionComponentIdentifier(entry.node, context);
669
607
  const name = eff.O.flatMapNullable(id2, getComponentNameFromIdentifier);
670
608
  components.set(entry.key, {
@@ -683,22 +621,71 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
683
621
  };
684
622
  return { ctx, listeners };
685
623
  }
624
+ function useComponentCollectorLegacy() {
625
+ const components = /* @__PURE__ */ new Map();
626
+ const ctx = {
627
+ getAllComponents(_) {
628
+ return components;
629
+ }
630
+ };
631
+ const collect = (node) => {
632
+ if (!isClassComponent(node)) {
633
+ return;
634
+ }
635
+ const id2 = AST8__namespace.getClassIdentifier(node);
636
+ const key = getId();
637
+ const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
638
+ components.set(
639
+ key,
640
+ {
641
+ _: key,
642
+ id: id2,
643
+ kind: "class",
644
+ name: eff.O.flatMapNullable(id2, (n) => n.name),
645
+ node,
646
+ // TODO: Get displayName of class component
647
+ displayName: eff.O.none(),
648
+ flag,
649
+ hint: 0n,
650
+ // TODO: Get methods of class component
651
+ methods: []
652
+ }
653
+ );
654
+ };
655
+ const listeners = {
656
+ "ClassDeclaration[type]": collect,
657
+ "ClassExpression[type]": collect
658
+ };
659
+ return { ctx, listeners };
660
+ }
686
661
  function isSetupFunction(node) {
687
- return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
662
+ return node.parent?.type === types$1.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types$1.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
688
663
  }
689
664
  function isCleanupFunction(node) {
690
- const nearestRet = eff.O.getOrNull(AST9__namespace.findParentNodeGuard(node, AST9__namespace.is(types.AST_NODE_TYPES.ReturnStatement)));
665
+ const nearestRet = eff.O.getOrNull(AST8__namespace.findParentNodeGuard(node, AST8__namespace.is(types$1.AST_NODE_TYPES.ReturnStatement)));
691
666
  if (!nearestRet) {
692
667
  return false;
693
668
  }
694
- const nearestFunction = eff.O.getOrNull(AST9__namespace.findParentNodeGuard(node, AST9__namespace.isFunction));
695
- const nearestFunctionOfRet = eff.O.getOrNull(AST9__namespace.findParentNodeGuard(nearestRet, AST9__namespace.isFunction));
669
+ const nearestFunction = eff.O.getOrNull(AST8__namespace.findParentNodeGuard(node, AST8__namespace.isFunction));
670
+ const nearestFunctionOfRet = eff.O.getOrNull(AST8__namespace.findParentNodeGuard(nearestRet, AST8__namespace.isFunction));
696
671
  if (!nearestFunction || !nearestFunctionOfRet) {
697
672
  return false;
698
673
  }
699
674
  return nearestFunction === nearestFunctionOfRet && isSetupFunction(nearestFunction);
700
675
  }
701
- var ERPhaseRelevance = types$1.birecord({
676
+ function isComponentDidMount(node) {
677
+ return AST8__namespace.isOneOf([types$1.AST_NODE_TYPES.MethodDefinition, types$1.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types$1.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
678
+ }
679
+ function isComponentWillUnmount(node) {
680
+ return AST8__namespace.isOneOf([types$1.AST_NODE_TYPES.MethodDefinition, types$1.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types$1.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
681
+ }
682
+ function isComponentDidMountFunction(node) {
683
+ return AST8__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
684
+ }
685
+ function isComponentWillUnmountFunction(node) {
686
+ return AST8__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
687
+ }
688
+ var ERPhaseRelevance = types.birecord({
702
689
  mount: "unmount",
703
690
  setup: "cleanup"
704
691
  });
@@ -706,10 +693,10 @@ var isInversePhase = eff.F.dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
706
693
  function isDirectValueOfRenderPropertyLoose(node) {
707
694
  const matching = tsPattern.isMatching({
708
695
  key: {
709
- type: types.AST_NODE_TYPES.Identifier,
696
+ type: types$1.AST_NODE_TYPES.Identifier,
710
697
  name: tsPattern.P.string.startsWith("render")
711
698
  },
712
- type: types.AST_NODE_TYPES.Property
699
+ type: types$1.AST_NODE_TYPES.Property
713
700
  });
714
701
  return matching(node) || matching(node.parent);
715
702
  }
@@ -718,20 +705,20 @@ function isDeclaredInRenderPropLoose(node) {
718
705
  return true;
719
706
  }
720
707
  return eff.F.pipe(
721
- AST9__namespace.findParentNodeGuard(node, AST9__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)),
708
+ AST8__namespace.findParentNodeGuard(node, AST8__namespace.is(types$1.AST_NODE_TYPES.JSXExpressionContainer)),
722
709
  eff.O.flatMapNullable((c) => c.parent),
723
- eff.O.filter(AST9__namespace.is(types.AST_NODE_TYPES.JSXAttribute)),
710
+ eff.O.filter(AST8__namespace.is(types$1.AST_NODE_TYPES.JSXAttribute)),
724
711
  eff.O.flatMapNullable((a) => a.name),
725
712
  eff.O.exists(tsPattern.isMatching({
726
- type: types.AST_NODE_TYPES.JSXIdentifier,
713
+ type: types$1.AST_NODE_TYPES.JSXIdentifier,
727
714
  name: tsPattern.P.string.startsWith("render")
728
715
  }))
729
716
  );
730
717
  }
731
718
  function isRenderFunctionLoose(node, context) {
732
719
  const { body, parent } = node;
733
- if (eff.O.exists(AST9__namespace.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
734
- 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");
720
+ if (eff.O.exists(AST8__namespace.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
721
+ return parent.type === types$1.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types$1.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types$1.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
735
722
  }
736
723
  return JSX4__namespace.isJSXValue(
737
724
  body,
@@ -742,14 +729,14 @@ function isRenderFunctionLoose(node, context) {
742
729
  );
743
730
  }
744
731
  function isRenderPropLoose(node, context) {
745
- if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier) {
732
+ if (node.name.type !== types$1.AST_NODE_TYPES.JSXIdentifier) {
746
733
  return false;
747
734
  }
748
- return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST9__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
735
+ return node.name.name.startsWith("render") && node.value?.type === types$1.AST_NODE_TYPES.JSXExpressionContainer && AST8__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
749
736
  }
750
737
  function isThisSetState(node) {
751
738
  const { callee } = node;
752
- return callee.type === types.AST_NODE_TYPES.MemberExpression && AST9__namespace.isThisExpression(callee.object) && callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "setState";
739
+ return callee.type === types$1.AST_NODE_TYPES.MemberExpression && AST8__namespace.isThisExpression(callee.object) && callee.property.type === types$1.AST_NODE_TYPES.Identifier && callee.property.name === "setState";
753
740
  }
754
741
 
755
742
  exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
@@ -816,6 +803,7 @@ exports.isReactHookCallWithNameAlias = isReactHookCallWithNameAlias;
816
803
  exports.isReactHookCallWithNameLoose = isReactHookCallWithNameLoose;
817
804
  exports.isReactHookName = isReactHookName;
818
805
  exports.isRenderFunctionLoose = isRenderFunctionLoose;
806
+ exports.isRenderMethodLike = isRenderMethodLike;
819
807
  exports.isRenderPropLoose = isRenderPropLoose;
820
808
  exports.isSetupFunction = isSetupFunction;
821
809
  exports.isThisSetState = isThisSetState;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import * as AST9 from '@eslint-react/ast';
1
+ import * as AST8 from '@eslint-react/ast';
2
2
  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';
@@ -91,7 +91,7 @@ function isCallFromReact(name) {
91
91
  if (node.type !== AST_NODE_TYPES.CallExpression) {
92
92
  return false;
93
93
  }
94
- if (!AST9.isOneOf([AST_NODE_TYPES.Identifier, AST_NODE_TYPES.MemberExpression])(node.callee)) {
94
+ if (!AST8.isOneOf([AST_NODE_TYPES.Identifier, AST_NODE_TYPES.MemberExpression])(node.callee)) {
95
95
  return false;
96
96
  }
97
97
  return isFromReact(name)(node.callee, context);
@@ -102,7 +102,7 @@ function isCallFromReactMember(pragmaMemberName, name) {
102
102
  if (node.type !== AST_NODE_TYPES.CallExpression) {
103
103
  return false;
104
104
  }
105
- if (!AST9.is(AST_NODE_TYPES.MemberExpression)(node.callee)) {
105
+ if (!AST8.is(AST_NODE_TYPES.MemberExpression)(node.callee)) {
106
106
  return false;
107
107
  }
108
108
  return isFromReactMember(pragmaMemberName, name)(node.callee, context);
@@ -143,8 +143,8 @@ var isMemoCall = isReactAPICallWithName("memo");
143
143
  function isInsideCreateElementProps(node, context) {
144
144
  return F.pipe(
145
145
  O.Do,
146
- O.bind("call", () => AST9.findParentNodeGuard(node, isCreateElementCall(context))),
147
- O.bind("prop", () => AST9.findParentNodeGuard(node, AST9.is(AST_NODE_TYPES.ObjectExpression))),
146
+ O.bind("call", () => AST8.findParentNodeGuard(node, isCreateElementCall(context))),
147
+ O.bind("prop", () => AST8.findParentNodeGuard(node, AST8.is(AST_NODE_TYPES.ObjectExpression))),
148
148
  O.bind("arg1", ({ call }) => O.fromNullable(call.arguments[1])),
149
149
  O.exists(({ arg1, prop }) => prop === arg1)
150
150
  );
@@ -152,7 +152,7 @@ function isInsideCreateElementProps(node, context) {
152
152
  function isChildrenOfCreateElement(node, context) {
153
153
  return F.pipe(
154
154
  O.fromNullable(node.parent),
155
- O.filter(AST9.is(AST_NODE_TYPES.CallExpression)),
155
+ O.filter(AST8.is(AST_NODE_TYPES.CallExpression)),
156
156
  O.filter(isCreateElementCall(context)),
157
157
  O.exists(
158
158
  (n) => n.arguments.slice(2).some((arg) => arg === node)
@@ -169,7 +169,7 @@ function isReactHookName(name) {
169
169
  // src/hook/is.ts
170
170
  function isReactHook(node) {
171
171
  return F.pipe(
172
- AST9.getFunctionIdentifier(node),
172
+ AST8.getFunctionIdentifier(node),
173
173
  O.flatMapNullable((id2) => id2.name),
174
174
  O.exists(isReactHookName)
175
175
  );
@@ -257,13 +257,13 @@ var isUseTransitionCall = F.flip(isReactHookCallWithName)("useTransition");
257
257
 
258
258
  // src/hook/hierarchy.ts
259
259
  function isInsideReactHook(node) {
260
- return O.exists(AST9.findParentNodeGuard(node, AST9.isFunction), isReactHook);
260
+ return O.exists(AST8.findParentNodeGuard(node, AST8.isFunction), isReactHook);
261
261
  }
262
262
  function useHookCollector() {
263
263
  const hooks = /* @__PURE__ */ new Map();
264
264
  const fStack = [];
265
265
  const onFunctionEnter = (node) => {
266
- const id2 = AST9.getFunctionIdentifier(node);
266
+ const id2 = AST8.getFunctionIdentifier(node);
267
267
  const name = O.flatMapNullable(id2, (id3) => id3.name);
268
268
  if (O.isSome(id2) && O.isSome(name) && isReactHookName(name.value)) {
269
269
  const key = getId();
@@ -365,7 +365,7 @@ function isComponentWrapperCall(node, context) {
365
365
  return isMemoCall(node, context) || isForwardRefCall(node, context) || isReactHookCallWithNameLoose(node)("useCallback");
366
366
  }
367
367
  function getFunctionComponentIdentifier(node, context) {
368
- const functionId = AST9.getFunctionIdentifier(node);
368
+ const functionId = AST8.getFunctionIdentifier(node);
369
369
  if (O.isSome(functionId)) {
370
370
  return functionId;
371
371
  }
@@ -388,94 +388,34 @@ function isComponentName(name) {
388
388
  return !!name && RE_COMPONENT_NAME.test(name);
389
389
  }
390
390
  function isClassComponent(node) {
391
- if (!("superClass" in node && node.superClass)) {
392
- return false;
391
+ if ("superClass" in node && node.superClass) {
392
+ const re = /^(?:Pure)?Component$/u;
393
+ switch (true) {
394
+ case node.superClass.type === AST_NODE_TYPES.Identifier:
395
+ return re.test(node.superClass.name);
396
+ case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
397
+ return re.test(node.superClass.property.name);
398
+ }
393
399
  }
394
- const { superClass } = node;
395
- return match(superClass).with({
396
- type: AST_NODE_TYPES.Identifier,
397
- name: P.string
398
- }, ({ name }) => /^(?:Pure)?Component$/u.test(name)).with({
399
- type: AST_NODE_TYPES.MemberExpression,
400
- property: { name: P.string }
401
- }, ({ property }) => /^(?:Pure)?Component$/u.test(property.name)).otherwise(() => false);
400
+ return false;
402
401
  }
403
402
  function isPureComponent(node) {
404
403
  if ("superClass" in node && node.superClass) {
405
- return match(node.superClass).with({
406
- type: AST_NODE_TYPES.Identifier,
407
- name: P.string
408
- }, ({ name }) => /^PureComponent$/u.test(name)).with({
409
- type: AST_NODE_TYPES.MemberExpression,
410
- property: { name: P.string }
411
- }, ({ property }) => /^PureComponent$/u.test(property.name)).otherwise(() => false);
404
+ const re = /^PureComponent$/u;
405
+ switch (true) {
406
+ case node.superClass.type === AST_NODE_TYPES.Identifier:
407
+ return re.test(node.superClass.name);
408
+ case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
409
+ return re.test(node.superClass.property.name);
410
+ }
412
411
  }
413
412
  return false;
414
413
  }
415
- function isComponentDidMount(node) {
416
- return AST9.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
417
- }
418
- function isComponentWillUnmount(node) {
419
- return AST9.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
420
- }
421
- function isComponentDidMountFunction(node) {
422
- return AST9.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
423
- }
424
- function isComponentWillUnmountFunction(node) {
425
- return AST9.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
426
- }
427
- function useComponentCollectorLegacy() {
428
- const components = /* @__PURE__ */ new Map();
429
- const ctx = {
430
- getAllComponents(_) {
431
- return components;
432
- }
433
- };
434
- const collect = (node) => {
435
- if (!isClassComponent(node)) {
436
- return;
437
- }
438
- const id2 = AST9.getClassIdentifier(node);
439
- const key = getId();
440
- const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
441
- components.set(
442
- key,
443
- {
444
- _: key,
445
- id: id2,
446
- kind: "class",
447
- name: O.flatMapNullable(id2, (n) => n.name),
448
- node,
449
- // TODO: Get displayName of class component
450
- displayName: O.none(),
451
- flag,
452
- hint: 0n,
453
- // TODO: Get methods of class component
454
- methods: []
455
- }
456
- );
457
- };
458
- const listeners = {
459
- "ClassDeclaration[type]": collect,
460
- "ClassExpression[type]": collect
461
- };
462
- return { ctx, listeners };
463
- }
464
414
 
465
415
  // src/component/component-render-method.ts
466
- var isRenderMethodLike = isMatching({
467
- key: {
468
- type: AST_NODE_TYPES.Identifier,
469
- name: "render"
470
- },
471
- type: P.union(AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition),
472
- parent: {
473
- type: AST_NODE_TYPES.ClassBody,
474
- parent: {
475
- type: AST_NODE_TYPES.ClassDeclaration
476
- }
477
- }
478
- });
416
+ function isRenderMethodLike(node) {
417
+ return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
418
+ }
479
419
  function isFunctionOfRenderMethod(node) {
480
420
  if (!isRenderMethodLike(node.parent)) {
481
421
  return false;
@@ -483,9 +423,7 @@ function isFunctionOfRenderMethod(node) {
483
423
  return isClassComponent(node.parent.parent.parent);
484
424
  }
485
425
  function isInsideRenderMethod(node) {
486
- return O.isSome(AST9.findParentNode(node, (node2) => {
487
- return isRenderMethodLike(node2) && isClassComponent(node2.parent.parent);
488
- }));
426
+ return O.isSome(AST8.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)));
489
427
  }
490
428
  function hasNoneOrValidComponentName(node, context) {
491
429
  const mbIdentifier = getFunctionComponentIdentifier(node, context);
@@ -502,22 +440,22 @@ function hasValidHierarchy(node, context, hint) {
502
440
  if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
503
441
  return false;
504
442
  }
505
- if (hint & ERComponentHint.SkipMapCallback && AST9.isMapCallLoose(node.parent)) {
443
+ if (hint & ERComponentHint.SkipMapCallback && AST8.isMapCallLoose(node.parent)) {
506
444
  return false;
507
445
  }
508
- if (hint & ERComponentHint.SkipObjectMethod && AST9.isFunctionOfObjectMethod(node.parent)) {
446
+ if (hint & ERComponentHint.SkipObjectMethod && AST8.isFunctionOfObjectMethod(node.parent)) {
509
447
  return false;
510
448
  }
511
- if (hint & ERComponentHint.SkipClassMethod && AST9.isFunctionOfClassMethod(node.parent)) {
449
+ if (hint & ERComponentHint.SkipClassMethod && AST8.isFunctionOfClassMethod(node.parent)) {
512
450
  return false;
513
451
  }
514
- if (hint & ERComponentHint.SkipClassProperty && AST9.isFunctionOfClassProperty(node.parent)) {
452
+ if (hint & ERComponentHint.SkipClassProperty && AST8.isFunctionOfClassProperty(node.parent)) {
515
453
  return false;
516
454
  }
517
455
  return !O.exists(
518
- AST9.findParentNode(
456
+ AST8.findParentNode(
519
457
  node,
520
- AST9.isOneOf([
458
+ AST8.isOneOf([
521
459
  AST_NODE_TYPES.JSXExpressionContainer,
522
460
  AST_NODE_TYPES.ArrowFunctionExpression,
523
461
  AST_NODE_TYPES.FunctionExpression,
@@ -525,15 +463,15 @@ function hasValidHierarchy(node, context, hint) {
525
463
  AST_NODE_TYPES.ClassBody
526
464
  ])
527
465
  ),
528
- AST9.is(AST_NODE_TYPES.JSXExpressionContainer)
466
+ AST8.is(AST_NODE_TYPES.JSXExpressionContainer)
529
467
  );
530
468
  }
531
469
  function getComponentFlag(initPath) {
532
470
  let flag = ERFunctionComponentFlag.None;
533
- if (AST9.hasCallInFunctionInitPath("memo")(initPath)) {
471
+ if (AST8.hasCallInFunctionInitPath("memo")(initPath)) {
534
472
  flag |= ERFunctionComponentFlag.Memo;
535
473
  }
536
- if (AST9.hasCallInFunctionInitPath("forwardRef")(initPath)) {
474
+ if (AST8.hasCallInFunctionInitPath("forwardRef")(initPath)) {
537
475
  flag |= ERFunctionComponentFlag.ForwardRef;
538
476
  }
539
477
  return flag;
@@ -552,7 +490,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
552
490
  if (!key || !node || !isComponent) {
553
491
  return functionEntries.pop();
554
492
  }
555
- const shouldDrop = AST9.getNestedReturnStatements(node.body).slice().reverse().some((r) => {
493
+ const shouldDrop = AST8.getNestedReturnStatements(node.body).slice().reverse().some((r) => {
556
494
  return context.sourceCode.getScope(r).block === node && r.argument !== null && !JSX4.isJSXValue(r.argument, jsxCtx, hint);
557
495
  });
558
496
  if (shouldDrop) {
@@ -583,7 +521,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
583
521
  if (!isComponent) {
584
522
  return;
585
523
  }
586
- const initPath = AST9.getFunctionInitPath(entry.node);
524
+ const initPath = AST8.getFunctionInitPath(entry.node);
587
525
  const id2 = getFunctionComponentIdentifier(entry.node, context);
588
526
  const name = O.flatMapNullable(id2, getComponentNameFromIdentifier);
589
527
  const key = getId();
@@ -640,7 +578,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
640
578
  }
641
579
  functionEntries.pop();
642
580
  functionEntries.push({ ...entry, isComponent });
643
- const initPath = AST9.getFunctionInitPath(entry.node);
581
+ const initPath = AST8.getFunctionInitPath(entry.node);
644
582
  const id2 = getFunctionComponentIdentifier(entry.node, context);
645
583
  const name = O.flatMapNullable(id2, getComponentNameFromIdentifier);
646
584
  components.set(entry.key, {
@@ -659,21 +597,70 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
659
597
  };
660
598
  return { ctx, listeners };
661
599
  }
600
+ function useComponentCollectorLegacy() {
601
+ const components = /* @__PURE__ */ new Map();
602
+ const ctx = {
603
+ getAllComponents(_) {
604
+ return components;
605
+ }
606
+ };
607
+ const collect = (node) => {
608
+ if (!isClassComponent(node)) {
609
+ return;
610
+ }
611
+ const id2 = AST8.getClassIdentifier(node);
612
+ const key = getId();
613
+ const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
614
+ components.set(
615
+ key,
616
+ {
617
+ _: key,
618
+ id: id2,
619
+ kind: "class",
620
+ name: O.flatMapNullable(id2, (n) => n.name),
621
+ node,
622
+ // TODO: Get displayName of class component
623
+ displayName: O.none(),
624
+ flag,
625
+ hint: 0n,
626
+ // TODO: Get methods of class component
627
+ methods: []
628
+ }
629
+ );
630
+ };
631
+ const listeners = {
632
+ "ClassDeclaration[type]": collect,
633
+ "ClassExpression[type]": collect
634
+ };
635
+ return { ctx, listeners };
636
+ }
662
637
  function isSetupFunction(node) {
663
638
  return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
664
639
  }
665
640
  function isCleanupFunction(node) {
666
- const nearestRet = O.getOrNull(AST9.findParentNodeGuard(node, AST9.is(AST_NODE_TYPES.ReturnStatement)));
641
+ const nearestRet = O.getOrNull(AST8.findParentNodeGuard(node, AST8.is(AST_NODE_TYPES.ReturnStatement)));
667
642
  if (!nearestRet) {
668
643
  return false;
669
644
  }
670
- const nearestFunction = O.getOrNull(AST9.findParentNodeGuard(node, AST9.isFunction));
671
- const nearestFunctionOfRet = O.getOrNull(AST9.findParentNodeGuard(nearestRet, AST9.isFunction));
645
+ const nearestFunction = O.getOrNull(AST8.findParentNodeGuard(node, AST8.isFunction));
646
+ const nearestFunctionOfRet = O.getOrNull(AST8.findParentNodeGuard(nearestRet, AST8.isFunction));
672
647
  if (!nearestFunction || !nearestFunctionOfRet) {
673
648
  return false;
674
649
  }
675
650
  return nearestFunction === nearestFunctionOfRet && isSetupFunction(nearestFunction);
676
651
  }
652
+ function isComponentDidMount(node) {
653
+ return AST8.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
654
+ }
655
+ function isComponentWillUnmount(node) {
656
+ return AST8.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
657
+ }
658
+ function isComponentDidMountFunction(node) {
659
+ return AST8.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
660
+ }
661
+ function isComponentWillUnmountFunction(node) {
662
+ return AST8.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
663
+ }
677
664
  var ERPhaseRelevance = birecord({
678
665
  mount: "unmount",
679
666
  setup: "cleanup"
@@ -694,9 +681,9 @@ function isDeclaredInRenderPropLoose(node) {
694
681
  return true;
695
682
  }
696
683
  return F.pipe(
697
- AST9.findParentNodeGuard(node, AST9.is(AST_NODE_TYPES.JSXExpressionContainer)),
684
+ AST8.findParentNodeGuard(node, AST8.is(AST_NODE_TYPES.JSXExpressionContainer)),
698
685
  O.flatMapNullable((c) => c.parent),
699
- O.filter(AST9.is(AST_NODE_TYPES.JSXAttribute)),
686
+ O.filter(AST8.is(AST_NODE_TYPES.JSXAttribute)),
700
687
  O.flatMapNullable((a) => a.name),
701
688
  O.exists(isMatching({
702
689
  type: AST_NODE_TYPES.JSXIdentifier,
@@ -706,7 +693,7 @@ function isDeclaredInRenderPropLoose(node) {
706
693
  }
707
694
  function isRenderFunctionLoose(node, context) {
708
695
  const { body, parent } = node;
709
- if (O.exists(AST9.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
696
+ if (O.exists(AST8.getFunctionIdentifier(node), (id2) => id2.name.startsWith("render"))) {
710
697
  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");
711
698
  }
712
699
  return JSX4.isJSXValue(
@@ -721,11 +708,11 @@ function isRenderPropLoose(node, context) {
721
708
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
722
709
  return false;
723
710
  }
724
- return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST9.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
711
+ return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST8.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
725
712
  }
726
713
  function isThisSetState(node) {
727
714
  const { callee } = node;
728
- return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
715
+ return callee.type === AST_NODE_TYPES.MemberExpression && AST8.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
729
716
  }
730
717
 
731
- export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, getId, 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 };
718
+ export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, getId, 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, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.23.3-next.1",
3
+ "version": "1.23.3-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": {
@@ -40,12 +40,12 @@
40
40
  "@typescript-eslint/types": "^8.19.1",
41
41
  "@typescript-eslint/utils": "^8.19.1",
42
42
  "ts-pattern": "^5.6.0",
43
- "@eslint-react/ast": "1.23.3-next.1",
44
- "@eslint-react/jsx": "1.23.3-next.1",
45
- "@eslint-react/shared": "1.23.3-next.1",
46
- "@eslint-react/types": "1.23.3-next.1",
47
- "@eslint-react/var": "1.23.3-next.1",
48
- "@eslint-react/eff": "1.23.3-next.1"
43
+ "@eslint-react/ast": "1.23.3-next.2",
44
+ "@eslint-react/eff": "1.23.3-next.2",
45
+ "@eslint-react/jsx": "1.23.3-next.2",
46
+ "@eslint-react/shared": "1.23.3-next.2",
47
+ "@eslint-react/types": "1.23.3-next.2",
48
+ "@eslint-react/var": "1.23.3-next.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.3.5",