Skip to content

Commit 7de74ec

Browse files
committed
Rename for new version of react-anonymous
1 parent 473fbdb commit 7de74ec

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,20 +407,20 @@ const tests = {
407407
}
408408
`,
409409
`
410-
// Valid because Hooks component acts as a component boundary
410+
// Valid because called in Anonymous component
411411
function App(props) {
412412
return props.isOpen
413-
? <Hooks>
413+
? <Anonymous>
414414
{() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />}
415-
</Hooks>
415+
</Anonymous>
416416
: null;
417417
}
418418
`,
419419
`
420-
// Valid because hooks function acts as a component boundary
420+
// Valid because called in anonymous function
421421
function App(props) {
422422
return props.isOpen
423-
? hooks(() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
423+
? anonymous(() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
424424
: null;
425425
}
426426
`,

packages/eslint-plugin-react-hooks/src/RulesOfHooks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function isInsideComponentOrHook(node) {
105105
return false;
106106
}
107107

108-
function isDirectlyInsideRenderHooks(node) {
108+
function isDirectlyInsideAnonymousComponent(node) {
109109
if (!node.parent) {
110110
return false;
111111
}
@@ -114,12 +114,12 @@ function isDirectlyInsideRenderHooks(node) {
114114
node.parent.type === 'JSXExpressionContainer' &&
115115
node.parent.parent &&
116116
node.parent.parent.type === 'JSXElement' &&
117-
node.parent.parent.openingElement.name.name === 'Hooks';
117+
node.parent.parent.openingElement.name.name === 'Anonymous';
118118
const isDirectlyInsideHooksFunction =
119119
node.parent.type === 'CallExpression' &&
120120
node.parent.callee &&
121121
node.parent.callee.type === 'Identifier' &&
122-
node.parent.callee.name === 'hooks';
122+
node.parent.callee.name === 'anonymous';
123123

124124
return isDirectlyInsideHooksComponent || isDirectlyInsideHooksFunction;
125125
}
@@ -373,7 +373,7 @@ export default {
373373
isHook(codePathFunctionName)
374374
: isForwardRefCallback(codePathNode) ||
375375
isMemoCallback(codePathNode) ||
376-
isDirectlyInsideRenderHooks(codePathNode);
376+
isDirectlyInsideAnonymousComponent(codePathNode);
377377

378378
// Compute the earliest finalizer level using information from the
379379
// cache. We expect all reachable final segments to have a cache entry

0 commit comments

Comments
 (0)