typescript-eslint / typescript-eslint

:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript
https://typescript-eslint.io
Other
14.91k stars 2.68k forks source link

Bug: Missing peer dependencies #9224

Open latin-1 opened 1 month ago

latin-1 commented 1 month ago

Before You File a Bug Report Please Confirm You Have Done The Following...

Relevant Package

typescript-eslint

Playground Link

No response

Repro Code

{
  "devDependencies": {
    "eslint": "9.4.0",
    "typescript": "5.4.5",
    "typescript-eslint": "8.0.0-alpha.25"
  }
}
Package @typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe] is requested to provide typescript by its descendants

@typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe]
└─ @typescript-eslint/typescript-estree@npm:8.0.0-alpha.25 [fd6b8] (via *)
   └─ ts-api-utils@npm:1.3.0 [e2004] (via >=4.2.0)

✘ Package @typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe] does not provide typescript.
Package @typescript-eslint/type-utils@npm:8.0.0-alpha.25 [47dfd] is requested to provide eslint by its descendants

@typescript-eslint/type-utils@npm:8.0.0-alpha.25 [47dfd]
└─ @typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe] (via ^8.57.0 || ^9.0.0)
   └─ @eslint-community/eslint-utils@npm:4.4.0 [fd6b8] (via ^6.0.0 || ^7.0.0 || >=8.0.0)

✘ Package @typescript-eslint/type-utils@npm:8.0.0-alpha.25 [47dfd] does not provide eslint.
Package typescript-eslint@npm:8.0.0-alpha.25 [14e3a] is requested to provide eslint by its descendants

typescript-eslint@npm:8.0.0-alpha.25 [14e3a]
├─ @typescript-eslint/eslint-plugin@npm:8.0.0-alpha.25 [a23fe] (via ^8.57.0 || ^9.0.0)
│  └─ @typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe] (via ^8.57.0 || ^9.0.0)
│     └─ @eslint-community/eslint-utils@npm:4.4.0 [fd6b8] (via ^6.0.0 || ^7.0.0 || >=8.0.0)
├─ @typescript-eslint/parser@npm:8.0.0-alpha.25 [a23fe] (via ^8.57.0 || ^9.0.0)
└─ @typescript-eslint/utils@npm:8.0.0-alpha.25 [a23fe] (via ^8.57.0 || ^9.0.0)
   └─ ...

✘ Package typescript-eslint@npm:8.0.0-alpha.25 [14e3a] does not provide eslint.

ESLint Config

No response

tsconfig

No response

Expected Result

Installed without any warnings.

Actual Result

yarn install reports unmet peer dependencies.

Additional Info

No response

Versions

package version
typescript-eslint 8.0.0-alpha.25
TypeScript 5.4.5
ESLint 9.4.0
bradzacher commented 1 month ago

This seems like a really weird constraint for yarn to enforce - to force a package to declare a peer dependency for its transient peer dependencies.

For the record the dependencies haven't changed since v7 AFAIK. So it should fail in the same way.

Josh-Cena commented 1 month ago

@bradzacher The requirement for Yarn is that every transitive peer dependency needs to either be "passed on" as peer dependency or declared as dependency (so all packages further up the chain don't need to declare it anymore)

latin-1 commented 1 month ago

(maybe off-topic) BTW, yarn and pnpm (but not npm >= 7, which appears to have a bug^1) allow you to declare a dependency in both dependencies and peerDependencies. The one in dependencies will act as a fallback.

LFCavalcanti commented 1 month ago

Hi,

Same problem here today but using NPM.

My dev dependencies versions:

"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^7.12.0",
    "@typescript-eslint/parser": "^7.12.0",
    "eslint": "^9.4.0",
  }

When I try to run npm install:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project-name@0.1.0
npm ERR! Found: eslint@9.4.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^9.4.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from @typescript-eslint/parser@7.12.0
npm ERR! node_modules/@typescript-eslint/parser
npm ERR!   dev @typescript-eslint/parser@"^7.12.0" from the root project
npm ERR!   peer @typescript-eslint/parser@"^7.0.0" from @typescript-eslint/eslint-plugin@7.12.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"^7.12.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
bradzacher commented 1 month ago

@LFCavalcanti youre using eslint v9 with typescript-eslint v7. That pairing is not valid - typescript-eslint v7 only supports eslint v8.

LFCavalcanti commented 1 month ago

@LFCavalcanti youre using eslint v9 with typescript-eslint v7. That pairing is not valid - typescript-eslint v7 only supports eslint v8.

Yeah, I managed to fix that updating to this:

"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^7.12.0",
    "@typescript-eslint/parser": "^7.12.0",
    "eslint": "^8.57.0",
  }

I already tried fixing the Eslint version to ^8.57.0 but the error persisted.

The catch was updating Eslint first, then the parser and finally the plugin.

Thanks!

callmeberzerker commented 1 month ago

@LFCavalcanti youre using eslint v9 with typescript-eslint v7. That pairing is not valid - typescript-eslint v7 only supports eslint v8.

What's the meaning behind this statement? Does typescript-eslint plan to ever support ESLint 9 or? I see the documentation references flat config which is for ESLint 9 - but peer dependency says v8.x.x. Also aside from the warning everything works?

JoshuaKGoldberg commented 1 month ago

Flat config support !== ESLint 9 support. You can support one without the other.

Issues on our side:

facucarbonel commented 1 month ago

@bradzacher

@LFCavalcanti youre using eslint v9 with typescript-eslint v7. That pairing is not valid - typescript-eslint v7 only supports eslint v8.

current eslint version is v9, how do I use typescript-eslint if the current version is v7? is there an alpha version or something like that?

JoshuaKGoldberg commented 1 month ago

https://github.com/typescript-eslint/typescript-eslint/issues/8211 -> https://typescript-eslint.io/blog/announcing-typescript-eslint-v8-beta

bradzacher commented 1 month ago

I'm going to lock this issue as the conversation is going way off topic. We shall investigate the peer deps.