Skip to content

Commit fefb951

Browse files
authored
fix(eslint-plugin): omit generics/types from dependencies (#4462)
* remove test only * omit type identifiers from check
1 parent fc743a9 commit fefb951

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.rule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const rule = createRule({
7979
}))
8080
.filter(({ ref, text }) => {
8181
return (
82+
!ref.isTypeReference &&
8283
!ASTUtils.isAncestorIsCallee(ref.identifier) &&
8384
!existingKeys.some((existingKey) => existingKey === text)
8485
)

packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ ruleTester.run('exhaustive-deps', rule, {
6363
`,
6464
},
6565
{
66-
only: true,
6766
name: 'identify props!.id (ts non null expression)',
6867
code: `
6968
function MyComponent(props) {
@@ -82,6 +81,18 @@ ruleTester.run('exhaustive-deps', rule, {
8281
}
8382
`,
8483
},
84+
{
85+
name: 'should ignore type identifiers',
86+
code: `
87+
type Result = {};
88+
function MyComponent(props) {
89+
useQuery({
90+
queryKey: ["foo", dep1],
91+
queryFn: () => api.get<Result>(dep),
92+
});
93+
}
94+
`,
95+
},
8596
],
8697
invalid: [
8798
{

0 commit comments

Comments
 (0)