@eslint-react/core 1.28.0-next.2 → 1.28.0-next.4

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
@@ -137,7 +137,7 @@ declare namespace useComponentCollectorLegacy {
137
137
  */
138
138
  declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
139
139
 
140
- declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
140
+ declare function getFunctionComponentIdentifier(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
141
141
 
142
142
  type ERComponentKind = "classComponent" | "functionComponent";
143
143
 
@@ -170,7 +170,7 @@ declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
170
170
  declare const RE_COMPONENT_NAME: RegExp;
171
171
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
172
172
  declare function isComponentName(name: string): boolean;
173
- declare function hasNoneOrValidComponentName(node: AST.TSESTreeFunction, context: RuleContext): boolean;
173
+ declare function hasNoneOrValidComponentName(context: RuleContext, node: AST.TSESTreeFunction): boolean;
174
174
 
175
175
  type EREffectPhaseKind = "cleanup" | "setup";
176
176
  type ERLifecyclePhaseKind = "mount" | "unmount";
@@ -192,22 +192,22 @@ declare const isInversePhase: {
192
192
  * _ = <Component renderRow={() => <div />} />
193
193
  * ` ^^^^^^^^^^^^^ `
194
194
  * ```
195
- * @param node The AST node to check
196
195
  * @param context The rule context
196
+ * @param node The AST node to check
197
197
  * @returns `true` if node is a render function, `false` if not
198
198
  */
199
- declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
199
+ declare function isRenderFunctionLoose(context: RuleContext, node: AST.TSESTreeFunction): boolean;
200
200
  /**
201
201
  * Unsafe check whether given JSXAttribute is a render prop
202
202
  * ```jsx
203
203
  * _ = <Component renderRow={() => <div />} />
204
204
  * ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
205
205
  * ```
206
- * @param node The AST node to check
207
206
  * @param context The rule context
207
+ * @param node The AST node to check
208
208
  * @returns `true` if node is a render prop, `false` if not
209
209
  */
210
- declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
210
+ declare function isRenderPropLoose(context: RuleContext, node: TSESTree.JSXAttribute): boolean;
211
211
  /**
212
212
  * Unsafe check whether given node is declared directly inside a render property
213
213
  * ```jsx
@@ -238,7 +238,7 @@ type ERStateKind = "actionState" | "state";
238
238
  declare function isThisSetState(node: TSESTree.CallExpression): boolean;
239
239
 
240
240
  /** internal */
241
- declare function hasValidHierarchy(node: AST.TSESTreeFunction, context: RuleContext, hint: bigint): boolean;
241
+ declare function hasValidHierarchy(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
242
242
 
243
243
  /**
244
244
  * Check if a node is a React class component
@@ -260,18 +260,18 @@ declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | un
260
260
 
261
261
  /**
262
262
  * Determines whether inside `createElement`'s props.
263
- * @param node The AST node to check
264
263
  * @param context The rule context
264
+ * @param node The AST node to check
265
265
  * @returns `true` if the node is inside createElement's props
266
266
  */
267
- declare function isInsideCreateElementProps(node: TSESTree.Node, context: RuleContext): boolean;
267
+ declare function isInsideCreateElementProps(context: RuleContext, node: TSESTree.Node): boolean;
268
268
  /**
269
269
  * Determines whether inside `createElement`'s children.
270
- * @param node The AST node to check
271
270
  * @param context The rule context
271
+ * @param node The AST node to check
272
272
  * @returns `true` if the node is inside createElement's children
273
273
  */
274
- declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
274
+ declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
275
275
 
276
276
  declare function isInsideReactHook(node: TSESTree.Node): boolean | undefined;
277
277
 
@@ -304,25 +304,25 @@ declare function isReactHook(node: AST.TSESTreeFunction | _): boolean | undefine
304
304
  * @returns `true` if the node is a React Hook call, `false` otherwise.
305
305
  */
306
306
  declare function isReactHookCall(node: TSESTree.Node | _): boolean;
307
- declare function isReactHookCallWithName(node: TSESTree.CallExpression | _, context: RuleContext): (name: string) => boolean;
307
+ declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.CallExpression | _): (name: string) => boolean;
308
308
  declare function isReactHookCallWithNameLoose(node: TSESTree.CallExpression | _): (name: string) => boolean;
309
- declare function isReactHookCallWithNameAlias(name: string, context: RuleContext, alias: string[]): (node: TSESTree.CallExpression) => boolean;
309
+ declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias: string[]): (node: TSESTree.CallExpression) => boolean;
310
310
  declare function isUseEffectCallLoose(node: TSESTree.Node | _): boolean;
311
- declare const isUseCallbackCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
312
- declare const isUseContextCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
313
- declare const isUseDebugValueCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
314
- declare const isUseDeferredValueCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
315
- declare const isUseEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
316
- declare const isUseIdCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
317
- declare const isUseImperativeHandleCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
318
- declare const isUseInsertionEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
319
- declare const isUseLayoutEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
320
- declare const isUseMemoCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
321
- declare const isUseReducerCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
322
- declare const isUseRefCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
323
- declare const isUseStateCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
324
- declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
325
- declare const isUseTransitionCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
311
+ declare const isUseCallbackCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
312
+ declare const isUseContextCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
313
+ declare const isUseDebugValueCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
314
+ declare const isUseDeferredValueCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
315
+ declare const isUseEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
316
+ declare const isUseIdCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
317
+ declare const isUseImperativeHandleCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
318
+ declare const isUseInsertionEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
319
+ declare const isUseLayoutEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
320
+ declare const isUseMemoCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
321
+ declare const isUseReducerCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
322
+ declare const isUseRefCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
323
+ declare const isUseStateCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
324
+ declare const isUseSyncExternalStoreCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
325
+ declare const isUseTransitionCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
326
326
 
327
327
  interface ERSemanticEntry {
328
328
  node: TSESTree.Node;
@@ -332,7 +332,7 @@ interface ERSemanticEntry {
332
332
  declare namespace isCallFromReact {
333
333
  type ReturnType = {
334
334
  (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
335
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
335
+ (context: RuleContext, node: TSESTree.Node): node is TSESTree.CallExpression;
336
336
  };
337
337
  }
338
338
  declare function isCallFromReact(name: string): isCallFromReact.ReturnType;
@@ -341,7 +341,7 @@ declare namespace isCallFromReactMember {
341
341
  (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
342
342
  callee: TSESTree.MemberExpression;
343
343
  };
344
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
344
+ (context: RuleContext, node: TSESTree.Node): node is TSESTree.CallExpression & {
345
345
  callee: TSESTree.MemberExpression;
346
346
  };
347
347
  };
@@ -361,10 +361,10 @@ declare function isDisplayNameAssignment(node: TSESTree.Node | _): node is TSEST
361
361
 
362
362
  declare function isFromReactLoose(node: TSESTree.Identifier | TSESTree.MemberExpression, name: string): boolean;
363
363
  declare function isFromReactStrict(node: TSESTree.Identifier | TSESTree.MemberExpression, name: string, importSource: string, initialScope: Scope): boolean;
364
- declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTree.MemberExpression, context: RuleContext) => boolean;
364
+ declare function isFromReact(name: string): (context: RuleContext, node: TSESTree.Identifier | TSESTree.MemberExpression) => boolean;
365
365
  declare function isFromReactMemberLoose(node: TSESTree.MemberExpression, memberName: string, name: string): boolean;
366
366
  declare function isFromReactMemberStrict(node: TSESTree.MemberExpression, memberName: string, name: string, importSource: string, initialScope: Scope): boolean;
367
- declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
367
+ declare function isFromReactMember(memberName: string, name: string): (context: RuleContext, node: TSESTree.MemberExpression) => boolean;
368
368
 
369
369
  /**
370
370
  * Check if an identifier is initialized from react
@@ -2398,17 +2398,17 @@ declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact
2398
2398
  declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
2399
2399
  declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
2400
2400
  declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
2401
- declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2402
- declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2403
- declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2404
- declare const isChildrenOnly: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2405
- declare const isChildrenToArray: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2406
- declare const isCloneElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2407
- declare const isCreateContext: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2408
- declare const isCreateElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2409
- declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2410
- declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2411
- declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2401
+ declare const isChildrenCount: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2402
+ declare const isChildrenForEach: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2403
+ declare const isChildrenMap: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2404
+ declare const isChildrenOnly: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2405
+ declare const isChildrenToArray: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2406
+ declare const isCloneElement: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2407
+ declare const isCreateContext: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2408
+ declare const isCreateElement: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2409
+ declare const isCreateRef: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2410
+ declare const isForwardRef: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2411
+ declare const isMemo: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2412
2412
  declare const isChildrenCountCall: isCallFromReactMember.ReturnType;
2413
2413
  declare const isChildrenForEachCall: isCallFromReactMember.ReturnType;
2414
2414
  declare const isChildrenMapCall: isCallFromReactMember.ReturnType;
package/dist/index.d.ts CHANGED
@@ -137,7 +137,7 @@ declare namespace useComponentCollectorLegacy {
137
137
  */
138
138
  declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
139
139
 
140
- declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
140
+ declare function getFunctionComponentIdentifier(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
141
141
 
142
142
  type ERComponentKind = "classComponent" | "functionComponent";
143
143
 
@@ -170,7 +170,7 @@ declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
170
170
  declare const RE_COMPONENT_NAME: RegExp;
171
171
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
172
172
  declare function isComponentName(name: string): boolean;
173
- declare function hasNoneOrValidComponentName(node: AST.TSESTreeFunction, context: RuleContext): boolean;
173
+ declare function hasNoneOrValidComponentName(context: RuleContext, node: AST.TSESTreeFunction): boolean;
174
174
 
175
175
  type EREffectPhaseKind = "cleanup" | "setup";
176
176
  type ERLifecyclePhaseKind = "mount" | "unmount";
@@ -192,22 +192,22 @@ declare const isInversePhase: {
192
192
  * _ = <Component renderRow={() => <div />} />
193
193
  * ` ^^^^^^^^^^^^^ `
194
194
  * ```
195
- * @param node The AST node to check
196
195
  * @param context The rule context
196
+ * @param node The AST node to check
197
197
  * @returns `true` if node is a render function, `false` if not
198
198
  */
199
- declare function isRenderFunctionLoose(node: AST.TSESTreeFunction, context: RuleContext): boolean;
199
+ declare function isRenderFunctionLoose(context: RuleContext, node: AST.TSESTreeFunction): boolean;
200
200
  /**
201
201
  * Unsafe check whether given JSXAttribute is a render prop
202
202
  * ```jsx
203
203
  * _ = <Component renderRow={() => <div />} />
204
204
  * ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
205
205
  * ```
206
- * @param node The AST node to check
207
206
  * @param context The rule context
207
+ * @param node The AST node to check
208
208
  * @returns `true` if node is a render prop, `false` if not
209
209
  */
210
- declare function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext): boolean;
210
+ declare function isRenderPropLoose(context: RuleContext, node: TSESTree.JSXAttribute): boolean;
211
211
  /**
212
212
  * Unsafe check whether given node is declared directly inside a render property
213
213
  * ```jsx
@@ -238,7 +238,7 @@ type ERStateKind = "actionState" | "state";
238
238
  declare function isThisSetState(node: TSESTree.CallExpression): boolean;
239
239
 
240
240
  /** internal */
241
- declare function hasValidHierarchy(node: AST.TSESTreeFunction, context: RuleContext, hint: bigint): boolean;
241
+ declare function hasValidHierarchy(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
242
242
 
243
243
  /**
244
244
  * Check if a node is a React class component
@@ -260,18 +260,18 @@ declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | un
260
260
 
261
261
  /**
262
262
  * Determines whether inside `createElement`'s props.
263
- * @param node The AST node to check
264
263
  * @param context The rule context
264
+ * @param node The AST node to check
265
265
  * @returns `true` if the node is inside createElement's props
266
266
  */
267
- declare function isInsideCreateElementProps(node: TSESTree.Node, context: RuleContext): boolean;
267
+ declare function isInsideCreateElementProps(context: RuleContext, node: TSESTree.Node): boolean;
268
268
  /**
269
269
  * Determines whether inside `createElement`'s children.
270
- * @param node The AST node to check
271
270
  * @param context The rule context
271
+ * @param node The AST node to check
272
272
  * @returns `true` if the node is inside createElement's children
273
273
  */
274
- declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
274
+ declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
275
275
 
276
276
  declare function isInsideReactHook(node: TSESTree.Node): boolean | undefined;
277
277
 
@@ -304,25 +304,25 @@ declare function isReactHook(node: AST.TSESTreeFunction | _): boolean | undefine
304
304
  * @returns `true` if the node is a React Hook call, `false` otherwise.
305
305
  */
306
306
  declare function isReactHookCall(node: TSESTree.Node | _): boolean;
307
- declare function isReactHookCallWithName(node: TSESTree.CallExpression | _, context: RuleContext): (name: string) => boolean;
307
+ declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.CallExpression | _): (name: string) => boolean;
308
308
  declare function isReactHookCallWithNameLoose(node: TSESTree.CallExpression | _): (name: string) => boolean;
309
- declare function isReactHookCallWithNameAlias(name: string, context: RuleContext, alias: string[]): (node: TSESTree.CallExpression) => boolean;
309
+ declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias: string[]): (node: TSESTree.CallExpression) => boolean;
310
310
  declare function isUseEffectCallLoose(node: TSESTree.Node | _): boolean;
311
- declare const isUseCallbackCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
312
- declare const isUseContextCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
313
- declare const isUseDebugValueCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
314
- declare const isUseDeferredValueCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
315
- declare const isUseEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
316
- declare const isUseIdCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
317
- declare const isUseImperativeHandleCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
318
- declare const isUseInsertionEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
319
- declare const isUseLayoutEffectCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
320
- declare const isUseMemoCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
321
- declare const isUseReducerCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
322
- declare const isUseRefCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
323
- declare const isUseStateCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
324
- declare const isUseSyncExternalStoreCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
325
- declare const isUseTransitionCall: (node: TSESTree.CallExpression | undefined, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
311
+ declare const isUseCallbackCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
312
+ declare const isUseContextCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
313
+ declare const isUseDebugValueCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
314
+ declare const isUseDeferredValueCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
315
+ declare const isUseEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
316
+ declare const isUseIdCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
317
+ declare const isUseImperativeHandleCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
318
+ declare const isUseInsertionEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
319
+ declare const isUseLayoutEffectCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
320
+ declare const isUseMemoCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
321
+ declare const isUseReducerCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
322
+ declare const isUseRefCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
323
+ declare const isUseStateCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
324
+ declare const isUseSyncExternalStoreCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
325
+ declare const isUseTransitionCall: (context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>, node: TSESTree.CallExpression | undefined) => boolean;
326
326
 
327
327
  interface ERSemanticEntry {
328
328
  node: TSESTree.Node;
@@ -332,7 +332,7 @@ interface ERSemanticEntry {
332
332
  declare namespace isCallFromReact {
333
333
  type ReturnType = {
334
334
  (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
335
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
335
+ (context: RuleContext, node: TSESTree.Node): node is TSESTree.CallExpression;
336
336
  };
337
337
  }
338
338
  declare function isCallFromReact(name: string): isCallFromReact.ReturnType;
@@ -341,7 +341,7 @@ declare namespace isCallFromReactMember {
341
341
  (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
342
342
  callee: TSESTree.MemberExpression;
343
343
  };
344
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
344
+ (context: RuleContext, node: TSESTree.Node): node is TSESTree.CallExpression & {
345
345
  callee: TSESTree.MemberExpression;
346
346
  };
347
347
  };
@@ -361,10 +361,10 @@ declare function isDisplayNameAssignment(node: TSESTree.Node | _): node is TSEST
361
361
 
362
362
  declare function isFromReactLoose(node: TSESTree.Identifier | TSESTree.MemberExpression, name: string): boolean;
363
363
  declare function isFromReactStrict(node: TSESTree.Identifier | TSESTree.MemberExpression, name: string, importSource: string, initialScope: Scope): boolean;
364
- declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTree.MemberExpression, context: RuleContext) => boolean;
364
+ declare function isFromReact(name: string): (context: RuleContext, node: TSESTree.Identifier | TSESTree.MemberExpression) => boolean;
365
365
  declare function isFromReactMemberLoose(node: TSESTree.MemberExpression, memberName: string, name: string): boolean;
366
366
  declare function isFromReactMemberStrict(node: TSESTree.MemberExpression, memberName: string, name: string, importSource: string, initialScope: Scope): boolean;
367
- declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
367
+ declare function isFromReactMember(memberName: string, name: string): (context: RuleContext, node: TSESTree.MemberExpression) => boolean;
368
368
 
369
369
  /**
370
370
  * Check if an identifier is initialized from react
@@ -2398,17 +2398,17 @@ declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact
2398
2398
  declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
2399
2399
  declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
2400
2400
  declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
2401
- declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2402
- declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2403
- declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2404
- declare const isChildrenOnly: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2405
- declare const isChildrenToArray: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2406
- declare const isCloneElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2407
- declare const isCreateContext: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2408
- declare const isCreateElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2409
- declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2410
- declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2411
- declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2401
+ declare const isChildrenCount: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2402
+ declare const isChildrenForEach: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2403
+ declare const isChildrenMap: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2404
+ declare const isChildrenOnly: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2405
+ declare const isChildrenToArray: (context: _eslint_react_shared.RuleContext, node: MemberExpression) => boolean;
2406
+ declare const isCloneElement: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2407
+ declare const isCreateContext: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2408
+ declare const isCreateElement: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2409
+ declare const isCreateRef: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2410
+ declare const isForwardRef: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2411
+ declare const isMemo: (context: _eslint_react_shared.RuleContext, node: Identifier | MemberExpression) => boolean;
2412
2412
  declare const isChildrenCountCall: isCallFromReactMember.ReturnType;
2413
2413
  declare const isChildrenForEachCall: isCallFromReactMember.ReturnType;
2414
2414
  declare const isChildrenMapCall: isCallFromReactMember.ReturnType;
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ function isFromReactStrict(node, name, importSource, initialScope) {
79
79
  return false;
80
80
  }
81
81
  function isFromReact(name) {
82
- return (node, context) => {
82
+ return (context, node) => {
83
83
  const { importSource = defaultImportSource, strictImportCheck = false } = shared.unsafeDecodeSettings(context.settings);
84
84
  if (!strictImportCheck) return isFromReactLoose(node, name);
85
85
  return isFromReactStrict(node, name, importSource, context.sourceCode.getScope(node));
@@ -108,7 +108,7 @@ function isFromReactMemberStrict(node, memberName, name, importSource, initialSc
108
108
  return false;
109
109
  }
110
110
  function isFromReactMember(memberName, name) {
111
- return (node, context) => {
111
+ return (context, node) => {
112
112
  const { importSource = defaultImportSource, strictImportCheck = false } = shared.unsafeDecodeSettings(context.settings);
113
113
  if (!strictImportCheck) return isFromReactMemberLoose(node, memberName, name);
114
114
  return isFromReactMemberStrict(node, memberName, name, importSource, context.sourceCode.getScope(node));
@@ -117,17 +117,17 @@ function isFromReactMember(memberName, name) {
117
117
 
118
118
  // src/utils/is-call-from-react.ts
119
119
  function isCallFromReact(name) {
120
- return eff.dual(2, (node, context) => {
120
+ return eff.dual(2, (context, node) => {
121
121
  if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
122
122
  if (!AST8__namespace.isOneOf([types.AST_NODE_TYPES.Identifier, types.AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
123
- return isFromReact(name)(node.callee, context);
123
+ return isFromReact(name)(context, node.callee);
124
124
  });
125
125
  }
126
126
  function isCallFromReactMember(pragmaMemberName, name) {
127
- return eff.dual(2, (node, context) => {
127
+ return eff.dual(2, (context, node) => {
128
128
  if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
129
129
  if (!AST8__namespace.is(types.AST_NODE_TYPES.MemberExpression)(node.callee)) return false;
130
- return isFromReactMember(pragmaMemberName, name)(node.callee, context);
130
+ return isFromReactMember(pragmaMemberName, name)(context, node.callee);
131
131
  });
132
132
  }
133
133
  var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
@@ -197,7 +197,7 @@ function isReactHookCall(node) {
197
197
  }
198
198
  return false;
199
199
  }
200
- function isReactHookCallWithName(node, context) {
200
+ function isReactHookCallWithName(context, node) {
201
201
  if (node == null) return eff.constFalse;
202
202
  const settings = shared.unsafeDecodeSettings(context.settings);
203
203
  const importSource = settings.importSource ?? "react";
@@ -226,7 +226,7 @@ function isReactHookCallWithNameLoose(node) {
226
226
  }
227
227
  };
228
228
  }
229
- function isReactHookCallWithNameAlias(name, context, alias) {
229
+ function isReactHookCallWithNameAlias(context, name, alias) {
230
230
  const settings = shared.unsafeDecodeSettings(context);
231
231
  const importSource = settings.importSource ?? "react";
232
232
  return (node) => {
@@ -368,22 +368,22 @@ var ERComponentFlag = {
368
368
  ForwardRef: 1n << 3n,
369
369
  Async: 1n << 4n
370
370
  };
371
- function isComponentWrapperCall(node, context) {
371
+ function isComponentWrapperCall(context, node) {
372
372
  if (node.type !== types.AST_NODE_TYPES.CallExpression) {
373
373
  return false;
374
374
  }
375
- return isMemoCall(node, context) || isForwardRefCall(node, context) || isReactHookCallWithNameLoose(node)("useCallback");
375
+ return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
376
376
  }
377
- function getFunctionComponentIdentifier(node, context) {
377
+ function getFunctionComponentIdentifier(context, node) {
378
378
  const functionId = AST8__namespace.getFunctionIdentifier(node);
379
379
  if (functionId != null) {
380
380
  return functionId;
381
381
  }
382
382
  const { parent } = node;
383
- 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) {
383
+ if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent) && parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
384
384
  return parent.parent.id;
385
385
  }
386
- 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) {
386
+ if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent) && parent.parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent.parent) && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
387
387
  return parent.parent.parent.id;
388
388
  }
389
389
  return eff._;
@@ -396,23 +396,23 @@ function getComponentNameFromIdentifier(node) {
396
396
  function isComponentName(name) {
397
397
  return RE_COMPONENT_NAME.test(name);
398
398
  }
399
- function hasNoneOrValidComponentName(node, context) {
400
- const id = getFunctionComponentIdentifier(node, context);
399
+ function hasNoneOrValidComponentName(context, node) {
400
+ const id = getFunctionComponentIdentifier(context, node);
401
401
  if (id == null) return true;
402
402
  const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
403
403
  return name != null && isComponentName(name);
404
404
  }
405
- function isInsideCreateElementProps(node, context) {
405
+ function isInsideCreateElementProps(context, node) {
406
406
  const call = AST8__namespace.findParentNode(node, isCreateElementCall(context));
407
407
  if (call == null) return false;
408
408
  const prop = AST8__namespace.findParentNode(node, AST8__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
409
409
  if (prop == null) return false;
410
410
  return prop === call.arguments[1];
411
411
  }
412
- function isChildrenOfCreateElement(node, context) {
412
+ function isChildrenOfCreateElement(context, node) {
413
413
  const parent = node.parent;
414
414
  if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false;
415
- if (!isCreateElementCall(parent, context)) return false;
415
+ if (!isCreateElementCall(context, parent)) return false;
416
416
  return parent.arguments.slice(2).some((arg) => arg === node);
417
417
  }
418
418
  function isClassComponent(node) {
@@ -476,8 +476,8 @@ function isInsideRenderMethod(node) {
476
476
  }
477
477
 
478
478
  // src/component/hierarchy.ts
479
- function hasValidHierarchy(node, context, hint) {
480
- if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
479
+ function hasValidHierarchy(context, node, hint) {
480
+ if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
481
481
  return false;
482
482
  }
483
483
  if (hint & ERComponentHint.SkipMapCallback && AST8__namespace.isMapCallLoose(node.parent)) {
@@ -554,10 +554,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
554
554
  const entry = getCurrentEntry();
555
555
  if (entry == null) return;
556
556
  const { body } = entry.node;
557
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
557
+ const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
558
558
  if (!isComponent) return;
559
559
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
560
- const id = getFunctionComponentIdentifier(entry.node, context);
560
+ const id = getFunctionComponentIdentifier(context, entry.node);
561
561
  const name = getComponentNameFromIdentifier(id);
562
562
  const key = shared.getId();
563
563
  components.set(key, {
@@ -594,11 +594,11 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
594
594
  "ReturnStatement[type]"(node) {
595
595
  const entry = getCurrentEntry();
596
596
  if (entry == null) return;
597
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
597
+ const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
598
598
  if (!isComponent) return;
599
599
  entry.isComponent = true;
600
600
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
601
- const id = getFunctionComponentIdentifier(entry.node, context);
601
+ const id = getFunctionComponentIdentifier(context, entry.node);
602
602
  const name = getComponentNameFromIdentifier(id);
603
603
  components.set(entry.key, {
604
604
  id,
@@ -669,7 +669,7 @@ var ERPhaseRelevance = birecord__default.default({
669
669
  setup: "cleanup"
670
670
  });
671
671
  var isInversePhase = eff.dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
672
- function isRenderFunctionLoose(node, context) {
672
+ function isRenderFunctionLoose(context, node) {
673
673
  const { body, parent } = node;
674
674
  if (AST8__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
675
675
  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");
@@ -682,11 +682,11 @@ function isRenderFunctionLoose(node, context) {
682
682
  JSX3__namespace.JSXValueHint.SkipNullLiteral | JSX3__namespace.JSXValueHint.SkipUndefined | JSX3__namespace.JSXValueHint.StrictLogical | JSX3__namespace.JSXValueHint.StrictConditional
683
683
  );
684
684
  }
685
- function isRenderPropLoose(node, context) {
685
+ function isRenderPropLoose(context, node) {
686
686
  if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier) {
687
687
  return false;
688
688
  }
689
- return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST8__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
689
+ return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST8__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
690
690
  }
691
691
  function isDirectValueOfRenderPropertyLoose(node) {
692
692
  const matching = (node2) => {
package/dist/index.mjs CHANGED
@@ -52,7 +52,7 @@ function isFromReactStrict(node, name, importSource, initialScope) {
52
52
  return false;
53
53
  }
54
54
  function isFromReact(name) {
55
- return (node, context) => {
55
+ return (context, node) => {
56
56
  const { importSource = defaultImportSource, strictImportCheck = false } = unsafeDecodeSettings(context.settings);
57
57
  if (!strictImportCheck) return isFromReactLoose(node, name);
58
58
  return isFromReactStrict(node, name, importSource, context.sourceCode.getScope(node));
@@ -81,7 +81,7 @@ function isFromReactMemberStrict(node, memberName, name, importSource, initialSc
81
81
  return false;
82
82
  }
83
83
  function isFromReactMember(memberName, name) {
84
- return (node, context) => {
84
+ return (context, node) => {
85
85
  const { importSource = defaultImportSource, strictImportCheck = false } = unsafeDecodeSettings(context.settings);
86
86
  if (!strictImportCheck) return isFromReactMemberLoose(node, memberName, name);
87
87
  return isFromReactMemberStrict(node, memberName, name, importSource, context.sourceCode.getScope(node));
@@ -90,17 +90,17 @@ function isFromReactMember(memberName, name) {
90
90
 
91
91
  // src/utils/is-call-from-react.ts
92
92
  function isCallFromReact(name) {
93
- return dual(2, (node, context) => {
93
+ return dual(2, (context, node) => {
94
94
  if (node.type !== AST_NODE_TYPES.CallExpression) return false;
95
95
  if (!AST8.isOneOf([AST_NODE_TYPES.Identifier, AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
96
- return isFromReact(name)(node.callee, context);
96
+ return isFromReact(name)(context, node.callee);
97
97
  });
98
98
  }
99
99
  function isCallFromReactMember(pragmaMemberName, name) {
100
- return dual(2, (node, context) => {
100
+ return dual(2, (context, node) => {
101
101
  if (node.type !== AST_NODE_TYPES.CallExpression) return false;
102
102
  if (!AST8.is(AST_NODE_TYPES.MemberExpression)(node.callee)) return false;
103
- return isFromReactMember(pragmaMemberName, name)(node.callee, context);
103
+ return isFromReactMember(pragmaMemberName, name)(context, node.callee);
104
104
  });
105
105
  }
106
106
  var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
@@ -170,7 +170,7 @@ function isReactHookCall(node) {
170
170
  }
171
171
  return false;
172
172
  }
173
- function isReactHookCallWithName(node, context) {
173
+ function isReactHookCallWithName(context, node) {
174
174
  if (node == null) return constFalse;
175
175
  const settings = unsafeDecodeSettings(context.settings);
176
176
  const importSource = settings.importSource ?? "react";
@@ -199,7 +199,7 @@ function isReactHookCallWithNameLoose(node) {
199
199
  }
200
200
  };
201
201
  }
202
- function isReactHookCallWithNameAlias(name, context, alias) {
202
+ function isReactHookCallWithNameAlias(context, name, alias) {
203
203
  const settings = unsafeDecodeSettings(context);
204
204
  const importSource = settings.importSource ?? "react";
205
205
  return (node) => {
@@ -341,22 +341,22 @@ var ERComponentFlag = {
341
341
  ForwardRef: 1n << 3n,
342
342
  Async: 1n << 4n
343
343
  };
344
- function isComponentWrapperCall(node, context) {
344
+ function isComponentWrapperCall(context, node) {
345
345
  if (node.type !== AST_NODE_TYPES.CallExpression) {
346
346
  return false;
347
347
  }
348
- return isMemoCall(node, context) || isForwardRefCall(node, context) || isReactHookCallWithNameLoose(node)("useCallback");
348
+ return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
349
349
  }
350
- function getFunctionComponentIdentifier(node, context) {
350
+ function getFunctionComponentIdentifier(context, node) {
351
351
  const functionId = AST8.getFunctionIdentifier(node);
352
352
  if (functionId != null) {
353
353
  return functionId;
354
354
  }
355
355
  const { parent } = node;
356
- if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === AST_NODE_TYPES.Identifier) {
356
+ if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === AST_NODE_TYPES.Identifier) {
357
357
  return parent.parent.id;
358
358
  }
359
- if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent, context) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(parent.parent, context) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === AST_NODE_TYPES.Identifier) {
359
+ if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCall(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === AST_NODE_TYPES.Identifier) {
360
360
  return parent.parent.parent.id;
361
361
  }
362
362
  return _;
@@ -369,23 +369,23 @@ function getComponentNameFromIdentifier(node) {
369
369
  function isComponentName(name) {
370
370
  return RE_COMPONENT_NAME.test(name);
371
371
  }
372
- function hasNoneOrValidComponentName(node, context) {
373
- const id = getFunctionComponentIdentifier(node, context);
372
+ function hasNoneOrValidComponentName(context, node) {
373
+ const id = getFunctionComponentIdentifier(context, node);
374
374
  if (id == null) return true;
375
375
  const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
376
376
  return name != null && isComponentName(name);
377
377
  }
378
- function isInsideCreateElementProps(node, context) {
378
+ function isInsideCreateElementProps(context, node) {
379
379
  const call = AST8.findParentNode(node, isCreateElementCall(context));
380
380
  if (call == null) return false;
381
381
  const prop = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.ObjectExpression));
382
382
  if (prop == null) return false;
383
383
  return prop === call.arguments[1];
384
384
  }
385
- function isChildrenOfCreateElement(node, context) {
385
+ function isChildrenOfCreateElement(context, node) {
386
386
  const parent = node.parent;
387
387
  if (parent == null || parent.type !== AST_NODE_TYPES.CallExpression) return false;
388
- if (!isCreateElementCall(parent, context)) return false;
388
+ if (!isCreateElementCall(context, parent)) return false;
389
389
  return parent.arguments.slice(2).some((arg) => arg === node);
390
390
  }
391
391
  function isClassComponent(node) {
@@ -449,8 +449,8 @@ function isInsideRenderMethod(node) {
449
449
  }
450
450
 
451
451
  // src/component/hierarchy.ts
452
- function hasValidHierarchy(node, context, hint) {
453
- if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
452
+ function hasValidHierarchy(context, node, hint) {
453
+ if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
454
454
  return false;
455
455
  }
456
456
  if (hint & ERComponentHint.SkipMapCallback && AST8.isMapCallLoose(node.parent)) {
@@ -527,10 +527,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
527
527
  const entry = getCurrentEntry();
528
528
  if (entry == null) return;
529
529
  const { body } = entry.node;
530
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
530
+ const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
531
531
  if (!isComponent) return;
532
532
  const initPath = AST8.getFunctionInitPath(entry.node);
533
- const id = getFunctionComponentIdentifier(entry.node, context);
533
+ const id = getFunctionComponentIdentifier(context, entry.node);
534
534
  const name = getComponentNameFromIdentifier(id);
535
535
  const key = getId();
536
536
  components.set(key, {
@@ -567,11 +567,11 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
567
567
  "ReturnStatement[type]"(node) {
568
568
  const entry = getCurrentEntry();
569
569
  if (entry == null) return;
570
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
570
+ const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
571
571
  if (!isComponent) return;
572
572
  entry.isComponent = true;
573
573
  const initPath = AST8.getFunctionInitPath(entry.node);
574
- const id = getFunctionComponentIdentifier(entry.node, context);
574
+ const id = getFunctionComponentIdentifier(context, entry.node);
575
575
  const name = getComponentNameFromIdentifier(id);
576
576
  components.set(entry.key, {
577
577
  id,
@@ -642,7 +642,7 @@ var ERPhaseRelevance = birecord({
642
642
  setup: "cleanup"
643
643
  });
644
644
  var isInversePhase = dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
645
- function isRenderFunctionLoose(node, context) {
645
+ function isRenderFunctionLoose(context, node) {
646
646
  const { body, parent } = node;
647
647
  if (AST8.getFunctionIdentifier(node)?.name.startsWith("render")) {
648
648
  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");
@@ -655,11 +655,11 @@ function isRenderFunctionLoose(node, context) {
655
655
  JSX3.JSXValueHint.SkipNullLiteral | JSX3.JSXValueHint.SkipUndefined | JSX3.JSXValueHint.StrictLogical | JSX3.JSXValueHint.StrictConditional
656
656
  );
657
657
  }
658
- function isRenderPropLoose(node, context) {
658
+ function isRenderPropLoose(context, node) {
659
659
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
660
660
  return false;
661
661
  }
662
- return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST8.isFunction(node.value.expression) && isRenderFunctionLoose(node.value.expression, context);
662
+ return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST8.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
663
663
  }
664
664
  function isDirectValueOfRenderPropertyLoose(node) {
665
665
  const matching = (node2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.28.0-next.2",
3
+ "version": "1.28.0-next.4",
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,11 +41,11 @@
41
41
  "@typescript-eslint/utils": "^8.25.0",
42
42
  "birecord": "^0.1.1",
43
43
  "ts-pattern": "^5.6.2",
44
- "@eslint-react/ast": "1.28.0-next.2",
45
- "@eslint-react/eff": "1.28.0-next.2",
46
- "@eslint-react/jsx": "1.28.0-next.2",
47
- "@eslint-react/shared": "1.28.0-next.2",
48
- "@eslint-react/var": "1.28.0-next.2"
44
+ "@eslint-react/ast": "1.28.0-next.4",
45
+ "@eslint-react/eff": "1.28.0-next.4",
46
+ "@eslint-react/shared": "1.28.0-next.4",
47
+ "@eslint-react/var": "1.28.0-next.4",
48
+ "@eslint-react/jsx": "1.28.0-next.4"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.3.6",