Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ const baseTestCases = {
}
`,
},
])
.concat([
{
name: `should pass when useQuery is imported from non-TanStack source and used with ${reactHookAlias}`,
code: `
${reactHookImport}
import { useQuery } from "./router";

function Component() {
const query = useQuery();
const callback = ${reactHookInvocation}(() => { query.refetch() }, [query]);
return;
}
`,
},
{
name: `should pass when useMutation is imported from non-TanStack source and used with ${reactHookAlias}`,
code: `
${reactHookImport}
import { useMutation } from "./api";

function Component() {
const mutation = useMutation();
const callback = ${reactHookInvocation}(() => { mutation.mutate() }, [mutation]);
return;
}
`,
},
]),
invalid: ({
reactHookImport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const rule = createRule({
},
defaultOptions: [],

create: detectTanstackQueryImports((context) => {
create: detectTanstackQueryImports((context, _options, helpers) => {
const trackedVariables: Record<string, string> = {}
const hookAliasMap: Record<string, string> = {}

Expand Down Expand Up @@ -109,7 +109,8 @@ export const rule = createRule({
node.init !== null &&
node.init.type === AST_NODE_TYPES.CallExpression &&
node.init.callee.type === AST_NODE_TYPES.Identifier &&
allHookNames.includes(node.init.callee.name)
allHookNames.includes(node.init.callee.name) &&
helpers.isTanstackQueryImport(node.init.callee)
) {
// Special case for useQueries with combine property - it's stable
if (
Expand Down
Loading