File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
packages/eslint-plugin-react-hooks Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -338,20 +338,20 @@ const tests = {
338
338
}
339
339
` ,
340
340
`
341
- // Valid because Hooks component acts as a component boundary
341
+ // Valid because called in Anonymous component
342
342
function App(props) {
343
343
return props.isOpen
344
- ? <Hooks >
344
+ ? <Anonymous >
345
345
{() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />}
346
- </Hooks >
346
+ </Anonymous >
347
347
: null;
348
348
}
349
349
` ,
350
350
`
351
- // Valid because hooks function acts as a component boundary
351
+ // Valid because called in anonymous function
352
352
function App(props) {
353
353
return props.isOpen
354
- ? hooks (() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
354
+ ? anonymous (() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
355
355
: null;
356
356
}
357
357
` ,
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ function isInsideComponentOrHook(node) {
104
104
return false ;
105
105
}
106
106
107
- function isDirectlyInsideRenderHooks ( node ) {
107
+ function isDirectlyInsideAnonymousComponent ( node ) {
108
108
if ( ! node . parent ) {
109
109
return false ;
110
110
}
@@ -113,12 +113,12 @@ function isDirectlyInsideRenderHooks(node) {
113
113
node . parent . type === 'JSXExpressionContainer' &&
114
114
node . parent . parent &&
115
115
node . parent . parent . type === 'JSXElement' &&
116
- node . parent . parent . openingElement . name . name === 'Hooks ' ;
116
+ node . parent . parent . openingElement . name . name === 'Anonymous ' ;
117
117
const isDirectlyInsideHooksFunction =
118
118
node . parent . type === 'CallExpression' &&
119
119
node . parent . callee &&
120
120
node . parent . callee . type === 'Identifier' &&
121
- node . parent . callee . name === 'hooks ' ;
121
+ node . parent . callee . name === 'anonymous ' ;
122
122
123
123
return isDirectlyInsideHooksComponent || isDirectlyInsideHooksFunction ;
124
124
}
@@ -373,7 +373,7 @@ export default {
373
373
isHook ( codePathFunctionName )
374
374
: isForwardRefCallback ( codePathNode ) ||
375
375
isMemoCallback ( codePathNode ) ||
376
- isDirectlyInsideRenderHooks ( codePathNode ) ;
376
+ isDirectlyInsideAnonymousComponent ( codePathNode ) ;
377
377
378
378
// Compute the earliest finalizer level using information from the
379
379
// cache. We expect all reachable final segments to have a cache entry
You can’t perform that action at this time.
0 commit comments