query icon indicating copy to clipboard operation
query copied to clipboard

Missing peer dependency declaration for TypeScript (YN0086 warnings under Yarn 4)

Open DK333D opened this issue 2 months ago • 4 comments

Describe the bug

Summary Yarn 4 reports peer dependency warnings (YN0086) related to two ESLint plugins used in our project: @tanstack/eslint-plugin-query and eslint-plugin-testing-library. Both depend (transitively) on @typescript-eslint/utils, which declares a peer dependency on typescript, but neither plugin forwards that peer requirement in its own peerDependencies. This causes cosmetic warnings in strict installs and makes dependency hygiene noisier.

Affected packages @tanstack/[email protected] [email protected] @typescript-eslint/[email protected] Yarn: 4.x (strict peer validation) TypeScript in our project: ~5.9.0 eslint: 9.15.0

Actual Strict peer check flags the plugins for not supplying the typescript peer expected by @typescript-eslint/utils.

Expected No warnings: plugins should forward the typescript peer requirement (optionally) so dependency graphs remain clean under Yarn 4 strict validation.

Suggested fix Please consider adding an optional typescript peer to the plugin manifests. Example snippet to add to each plugin's package.json

"peerDependencies": {
  "eslint": "^8.0.0 || ^9.0.0",
  "typescript": ">=5.0.0"
},
"peerDependenciesMeta": {
  "typescript": {
    "optional": true
  }
}

Why optional? Projects using only JS (no TS) may still want the plugin; marking typescript optional prevents forcing an install while satisfying Yarn’s propagation expectations in TS projects.

Impact

Eliminates noisy YN0086 warnings in modern Yarn setups (cleaner CI logs and developer installs). Encourages consistent manifest hygiene with other ESLint + TypeScript tooling. Avoids downstream hacks (Yarn packageExtensions) or local patch: modifications that only mask, not fix, the upstream issue.

Your minimal, reproducible example

Difficult to reproduce. I have yarn 4.x with strict dependency check and StackBlitz uses yarn 1.x with not-strict checking

Steps to reproduce

  1. Create a project using Yarn 4.
  2. Add devDependencies including eslint, typescript, and either/both plugins listed above.
  3. Run yarn install.
  4. Run yarn explain peer-requirements and observe lines like: ✘ @tanstack/eslint-plugin-query@... doesn't provide typescript to @typescript-eslint/utils@... ✘ eslint-plugin-testing-library@... doesn't provide typescript to @typescript-eslint/utils@...

Expected behavior

I don't see: Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.

when executing command yarn install

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

Ubuntu 22 LTS

Tanstack Query adapter

react-query

TanStack Query version

5.91.2

TypeScript version

5.9.0

Additional context

No response

DK333D avatar Nov 05 '25 12:11 DK333D

A summary of the changes CodeRabbit can apply:

  • Update packages/eslint-plugin-query/package.json to add a peerDependencies block declaring "eslint": "^8.57.0 || ^9.0.0" and "typescript": ">=5.0.0", and add a peerDependenciesMeta entry marking "typescript" as optional to silence Yarn 4 YN0086 warnings while keeping TypeScript optional.

  • Update packages/eslint-plugin-query/package.json to add "typescript": ">=5.0.0" as a (optional) peerDependency via peerDependenciesMeta and adjust formatting around the existing "eslint" peerDependency.

  • [ ] Executed edits - (🔄 Check again to try again)

coderabbitai[bot] avatar Nov 05 '25 12:11 coderabbitai[bot]

[!CAUTION] The CodeRabbit agent's plans did not produce any file changes.

coderabbitai[bot] avatar Nov 05 '25 13:11 coderabbitai[bot]

well, the bots failed to make a PR. Do you want to contribute this @DK333D ?

TkDodo avatar Nov 05 '25 13:11 TkDodo

@TkDodo since there hasn’t been any activity for three weeks and the change is straightforward, would it be okay if I open a PR to address it?

976520 avatar Nov 25 '25 02:11 976520