File tree 2 files changed +15
-1
lines changed
packages/eslint-plugin-react-hooks
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1452,6 +1452,15 @@ const tests = {
1452
1452
}
1453
1453
` ,
1454
1454
} ,
1455
+ {
1456
+ code : normalizeIndent `
1457
+ function MyComponent() {
1458
+ useEffect(() => {
1459
+ console.log('banana banana banana');
1460
+ }, undefined);
1461
+ }
1462
+ ` ,
1463
+ } ,
1455
1464
] ,
1456
1465
invalid : [
1457
1466
{
Original file line number Diff line number Diff line change @@ -1161,7 +1161,12 @@ export default {
1161
1161
const callback = node . arguments [ callbackIndex ] ;
1162
1162
const reactiveHook = node . callee ;
1163
1163
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 ;
1165
1170
const isEffect = / E f f e c t ( $ | [ ^ a - z ] ) / g. test ( reactiveHookName ) ;
1166
1171
1167
1172
// Check whether a callback is supplied. If there is no callback supplied
You can’t perform that action at this time.
0 commit comments