@boring-stack-pkg/eslint-plugin-tanstack-query-cache
v0.2.0
Published
ESLint rules for TanStack Query cache consistency: spread query keys must use setQueriesData / matcher APIs instead of setQueryData on the prefix alone.
Downloads
2,020
Maintainers
Readme
eslint-plugin-tanstack-query-cache
ESLint rules that catch TanStack Query cache bugs when list keys are built with spreads (queryKey: [...LIST_KEY, filter]) but mutations still call setQueryData(LIST_KEY, …) — which only updates one cache entry.
Rules
| Rule | Description |
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| prefix-query-key-must-use-set-queries-data | Prefer setQueriesData({ queryKey: prefix }, …) and matcher-style cancelQueries when hooks extend the key after a spread. |
Usage (flat config)
import tanstackQueryCache from "@boring-stack-pkg/eslint-plugin-tanstack-query-cache";
export default [
{
files: ["**/*.queries.ts"],
plugins: { "tanstack-query-cache": tanstackQueryCache },
rules: {
"tanstack-query-cache/prefix-query-key-must-use-set-queries-data":
"error",
},
},
];Development
pnpm install
pnpm test
pnpm build