* fix(eslint-plugin-query): detect rest destructuring on custom query hooks
Adds an opportunistic type-aware path to no-rest-destructuring. When
TypeScript parser services are available, the rule resolves the call
expression's return type and reports rest destructuring on custom hooks
that return a TanStack Query result. Untyped projects keep the existing
AST-only behavior unchanged.
Closes#8951
* perf(eslint-plugin-query): gate type lookup behind cheap binding check
Only run the type checker on non-direct hook calls when the binding can
actually report (rest destructure or identifier), avoiding type lookups on
every variable declarator. Add tests for cross-statement rest destructuring
and interface-typed (non-alias) query results.
* ci: apply automated fixes
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat(eslint-plugin): add allowlist option to exhaustive-deps rule
Introduce an `allowlist` option with `variables` and `types` arrays so
stable variables and types can be excluded from dependency enforcement.
Also report member expression dependencies more granularly for call
expressions (e.g. `a.b.foo()` suggests `a.b` instead of only `a`).
BREAKING CHANGE: exhaustive-deps now reports member expression deps more
granularly, so some previously passing code may now report missing deps.
Use the allowlist option to exclude stable variables/types as needed.
* fix
* ci: apply automated fixes
* increase coverage
* address false positives
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
On https://tanstack.com/query/latest/docs/framework/react/installation for example, the Bash snippets do *not* have a leading `$` character. So you can click the clipboard and then paste these into your terminal.
Doesn't work if there's a `$ ` prefix on the bash command.
* feat(eslint-plugin-query): add rule that disallows putting the result of useMutation directly in a React hook dependency array
* add doc
* add rule to recommended rules
* generalize to all affected query hooks
* rename rule to "no-unstable-deps"
* add @tanstack/eslint-plugin-query
* fix .eslintrc rule name
* make rule compatible with babel parser
* fix script typo
* remove dedicated example in favor of the basic example
* align package version with the other packages
* align eslint-plugin-query version
* fix displayName
* remove typescript from package
* omit call expressions from keys without the need of whitelist
* lint queryKey instead of useQuery
* update pnpm-lock.yaml
* fix auto-fix suggestion for complex ast
* better inline query key
* fix typo
* update scripts
* restore .eslintrc
* update typescript-eslint packages
* support member expression keys
* format
* should not fix with duplicate keys
* format
* empty commit (flaky test)
* should ignore keys from callback
* Update packages/eslint-plugin-query/package.json
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* add prefer-query-object-syntax rule
* fix indention
* fix headline
* add rule description
* fix lint errors
* widen import check for all adapters
* add support for solid-query (createQuery)
* docs: add eslint plugin section
* prettier
* move docs
* EsLint -> ESLint
* fix typo
* add missing dep
* update lockfile
* give credit where credit is due
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>