Skip to content

Commit cd75f93

Browse files
authored
eslint-plugin-react-hooks: fix compatibility with @typescript-eslint/parser@4.0.0+ (#19751)
In addition to `TSTypeQuery`, dependency nodes with a `TSTypeReference` parent need to be ignored as well. Without this fix, generic type variables will be listed as missing dependencies. Example: export function useFoo<T>(): (foo: T) => boolean { return useCallback((foo: T) => false, []); } This will report the following issue: React Hook useCallback has a missing dependency: 'T'. Either include it or remove the dependency array Closes: #19742
1 parent a08ae9f commit cd75f93

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ export default {
406406
});
407407
}
408408

409-
if (dependencyNode.parent.type === 'TSTypeQuery') {
409+
if (
410+
dependencyNode.parent.type === 'TSTypeQuery' ||
411+
dependencyNode.parent.type === 'TSTypeReference'
412+
) {
410413
continue;
411414
}
412415

0 commit comments

Comments
 (0)