Skip to content

Commit cd1c98b

Browse files
committed
Rename for new version of react-anonymous
1 parent 246bd98 commit cd1c98b

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
@@ -338,20 +338,20 @@ const tests = {
338338
}
339339
`,
340340
`
341-
// Valid because Hooks component acts as a component boundary
341+
// Valid because called in Anonymous component
342342
function App(props) {
343343
return props.isOpen
344-
? <Hooks>
344+
? <Anonymous>
345345
{() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />}
346-
</Hooks>
346+
</Anonymous>
347347
: null;
348348
}
349349
`,
350350
`
351-
// Valid because hooks function acts as a component boundary
351+
// Valid because called in anonymous function
352352
function App(props) {
353353
return props.isOpen
354-
? hooks(() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
354+
? anonymous(() => <Modal close={useCallback(() => props.setIsOpen(false), [props.setIsOpen])} />)
355355
: null;
356356
}
357357
`,

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

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

107-
function isDirectlyInsideRenderHooks(node) {
107+
function isDirectlyInsideAnonymousComponent(node) {
108108
if (!node.parent) {
109109
return false;
110110
}
@@ -113,12 +113,12 @@ function isDirectlyInsideRenderHooks(node) {
113113
node.parent.type === 'JSXExpressionContainer' &&
114114
node.parent.parent &&
115115
node.parent.parent.type === 'JSXElement' &&
116-
node.parent.parent.openingElement.name.name === 'Hooks';
116+
node.parent.parent.openingElement.name.name === 'Anonymous';
117117
const isDirectlyInsideHooksFunction =
118118
node.parent.type === 'CallExpression' &&
119119
node.parent.callee &&
120120
node.parent.callee.type === 'Identifier' &&
121-
node.parent.callee.name === 'hooks';
121+
node.parent.callee.name === 'anonymous';
122122

123123
return isDirectlyInsideHooksComponent || isDirectlyInsideHooksFunction;
124124
}
@@ -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)