lightsoutAlpha

query-options

TanStack Query options declared outside the feature's `queries/` folder

Agent checkadvisory by defaulttanstackcode

The argument

Query Options

Query-options factories live in the feature's queries/ folder — the conventional domain folder for a feature's query definitions (a grouping, not a module, per a domain folder is not a module). This pack's convention — consistency across TanStack repos is worth the noun — not a TanStack requirement.

// features/issues/queries/issuesQueryOptions.ts
interface Params {
	searchParams: IssuesSearchParams;
}

export const issuesQueryOptions = ({ searchParams }: Params) =>
	queryOptions({
		queryKey: [QueryKey.Issues, searchParams],
		queryFn: () => findAllIssuesServerFn({ data: searchParams }),
	});

The factory's inferred return type is deliberate — see the return-types note in this channel's document.

The proof

failsrc/features/issues/screens/IssuesScreen/IssuesScreen.tsx
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query';
import { findAllIssuesServerFn } from '../../serverFns/findAllIssues';

// The query is declared inline in the screen, so the next caller that needs the
// same data writes its own key and the cache quietly splits in two.
export const IssuesScreen = ({ search }: { search: string }) => {
	const { data } = useSuspenseQuery(
		queryOptions({ queryKey: ['issues', search], queryFn: () => findAllIssuesServerFn({ data: { search } }) }),
	);

	return <ul>{data.map((issue: string) => <li key={issue}>{issue}</li>)}</ul>;
};
pass
export const QueryKey = {
	Issues: 'issues',
} as const;

export type QueryKey = (typeof QueryKey)[keyof typeof QueryKey];

Turn it down

Both lines go in your lightsout.config.json.

"standards-checks": { "query-options": "advisory" }
"standards-checks": { "query-options": "off" }