Open
Description
Describe the bug
@tanstack/eslint-plugin-query
tries to import typescript
, but does not declare it as a dependency or peer dependency.
This happens to work with npm
's hoisting due to other dependencies pulling that package in, but will fail with yarn
's p'n'p or pnpm
with hoisting disabled.
Your minimal, reproducible example
Reproduction steps explain how to reproduce starting with an empty directory.
Steps to reproduce
With yarn:
- Create a temporary directory, and cd into it.
echo '{}' > package.json
yarn set version stable
yarn add eslint @tanstack/eslint-plugin-query
echo 'import pluginQuery from "@tanstack/eslint-plugin-query"; export default [ ...pluginQuery.configs["flat/recommended"], ];' > eslint.config.mjs
yarn exec eslint .
With pnpm:
- Create a temporary directory, and cd into it.
echo 'hoist-pattern=[]' > .npmrc
pnpm add eslint @tanstack/eslint-plugin-query
echo 'import pluginQuery from "@tanstack/eslint-plugin-query"; export default [ ...pluginQuery.configs["flat/recommended"], ];' > eslint.config.mjs
pnpm exec eslint .
Expected behavior
Eslint runs.
How often does this bug happen?
Every time
Screenshots or Videos
No video or screenshot, but the console output would seem to be helpful here.
With yarn:
Oops! Something went wrong! :(
ESLint: 9.25.1
Error: @tanstack/eslint-plugin-query tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: typescript (via "typescript/package.json")
Required by: @tanstack/eslint-plugin-query@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:5.74.7 (via /tmp/test/.yarn/__virtual__/@tanstack-eslint-plugin-query-virtual-135df79552/3/home/me/.yarn/berry/cache/@tanstack-eslint-plugin-query-npm-5.74.7-a9272f7a3e-10c0.zip/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-6ZHBB3IQ.js)
at makeError (/tmp/test/.pnp.cjs:6959:34)
at resolveToUnqualified (/tmp/test/.pnp.cjs:8600:21)
at Object.resolveToUnqualified (/tmp/test/.pnp.cjs:8780:26)
at resolve$1 (file:///tmp/test/.pnp.loader.mjs:2031:31)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
at handleMessage (node:internal/modules/esm/worker:199:24)
at Immediate.checkForMessages (node:internal/modules/esm/worker:141:28)
at process.processImmediate (node:internal/timers:485:21)
With pnpm:
Oops! Something went wrong! :(
ESLint: 9.25.1
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'typescript' imported from /tmp/test/node_modules/.pnpm/@tanstack+eslint-plugin-query@5.74.7_eslint@9.25.1_typescript@5.8.3/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-6ZHBB3IQ.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)
at packageResolve (node:internal/modules/esm/resolve:768:81)
at moduleResolve (node:internal/modules/esm/resolve:854:18)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
at ModuleJob._link (node:internal/modules/esm/module_job:137:49)
Platform
- OS: Linux
- Browser: N/A
- Browser version: N/A
- node version: v22.15.0
- pnpm version: 10.10.0
- yarn version: 4.9.1
Tanstack Query adapter
None
TanStack Query version
@tanstack/eslint-plugin-query v5.74.7
TypeScript version
none
Additional context
The attempt to import typescript
is here:
Added in #8925.