File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
packages/eslint-plugin-query/src Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,34 @@ const baseTestCases = {
6363 }
6464 ` ,
6565 } ,
66+ ] )
67+ . concat ( [
68+ {
69+ name : `should pass when useQuery is imported from non-TanStack source and used with ${ reactHookAlias } ` ,
70+ code : `
71+ ${ reactHookImport }
72+ import { useQuery } from "./router";
73+
74+ function Component() {
75+ const query = useQuery();
76+ const callback = ${ reactHookInvocation } (() => { query.refetch() }, [query]);
77+ return;
78+ }
79+ ` ,
80+ } ,
81+ {
82+ name : `should pass when useMutation is imported from non-TanStack source and used with ${ reactHookAlias } ` ,
83+ code : `
84+ ${ reactHookImport }
85+ import { useMutation } from "./api";
86+
87+ function Component() {
88+ const mutation = useMutation();
89+ const callback = ${ reactHookInvocation } (() => { mutation.mutate() }, [mutation]);
90+ return;
91+ }
92+ ` ,
93+ } ,
6694 ] ) ,
6795 invalid : ( {
6896 reactHookImport,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export const rule = createRule({
3434 } ,
3535 defaultOptions : [ ] ,
3636
37- create : detectTanstackQueryImports ( ( context ) => {
37+ create : detectTanstackQueryImports ( ( context , _options , helpers ) => {
3838 const trackedVariables : Record < string , string > = { }
3939 const hookAliasMap : Record < string , string > = { }
4040
@@ -109,7 +109,8 @@ export const rule = createRule({
109109 node . init !== null &&
110110 node . init . type === AST_NODE_TYPES . CallExpression &&
111111 node . init . callee . type === AST_NODE_TYPES . Identifier &&
112- allHookNames . includes ( node . init . callee . name )
112+ allHookNames . includes ( node . init . callee . name ) &&
113+ helpers . isTanstackQueryImport ( node . init . callee )
113114 ) {
114115 // Special case for useQueries with combine property - it's stable
115116 if (
You can’t perform that action at this time.
0 commit comments