File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/eslint-plugin-react-hooks Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1452,6 +1452,15 @@ const tests = {
14521452 }
14531453 ` ,
14541454 } ,
1455+ {
1456+ code : normalizeIndent `
1457+ function MyComponent() {
1458+ useEffect(() => {
1459+ console.log('banana banana banana');
1460+ }, undefined);
1461+ }
1462+ ` ,
1463+ } ,
14551464 ] ,
14561465 invalid : [
14571466 {
Original file line number Diff line number Diff line change @@ -1161,7 +1161,12 @@ export default {
11611161 const callback = node . arguments [ callbackIndex ] ;
11621162 const reactiveHook = node . callee ;
11631163 const reactiveHookName = getNodeWithoutReactNamespace ( reactiveHook ) . name ;
1164- const declaredDependenciesNode = node . arguments [ callbackIndex + 1 ] ;
1164+ const maybeNode = node . arguments [ callbackIndex + 1 ] ;
1165+ const declaredDependenciesNode =
1166+ maybeNode &&
1167+ ! ( maybeNode . type === 'Identifier' && maybeNode . name === 'undefined' )
1168+ ? maybeNode
1169+ : undefined ;
11651170 const isEffect = / E f f e c t ( $ | [ ^ a - z ] ) / g. test ( reactiveHookName ) ;
11661171
11671172 // Check whether a callback is supplied. If there is no callback supplied
You can’t perform that action at this time.
0 commit comments