react icon indicating copy to clipboard operation
react copied to clipboard

cannot upgrade `eslint` to v9 due to `eslint-plugin-react-hooks` peer dependancies

Open DeadEnglish opened this issue 1 year ago • 4 comments
trafficstars

eslint-plugin-react-hooks does not currently support the latest version on eslint, [email protected]

React version: 18.3.1

Steps To Reproduce

  1. create a new react application
  2. install eslint @ 8.56.0
  3. install eslint-plugin-react-hooks @ 4.6.2
  4. try to install eslint @ 9.10.0

Link to code example:

The current behavior

cannot install due to eslint-plugin-react-hooks only having eslint version 8 as a peer dependancy.

npm i output:

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error   dev eslint@"^9.10.0" from the root project
npm error   peer eslint@"^7.5.0 || ^8.0.0 || ^9.0.0" from @babel/[email protected]
npm error   node_modules/@babel/eslint-parser
npm error     dev @babel/eslint-parser@"^7.25.1" from the root project
npm error   6 more (@eslint-community/eslint-utils, ...)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from [email protected]
npm error node_modules/eslint-plugin-react-hooks
npm error   dev eslint-plugin-react-hooks@"^4.6.2" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/eslint
npm error   peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from [email protected]
npm error   node_modules/eslint-plugin-react-hooks
npm error     dev eslint-plugin-react-hooks@"^4.6.2" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error

The expected behavior

ES lint is upgraded successfully

DeadEnglish avatar Sep 10 '24 16:09 DeadEnglish

Seems like the changes have been added to the library here but a new version is yet to be released on NPM

DeadEnglish avatar Sep 10 '24 16:09 DeadEnglish

You can install the eslint-plugin-react-hooks RC to get around this for now.

npm i eslint-plugin-react-hooks@rc

bsal649 avatar Sep 11 '24 22:09 bsal649

You can install the eslint-plugin-react-hooks RC to get around this for now.

npm i eslint-plugin-react-hooks@rc

That doesn't work for me unfortunately. Any idea?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^9.10.0" from the root project
npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm ERR!   node_modules/@eslint-community/eslint-utils
npm ERR!     @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm ERR!     @eslint-community/eslint-utils@"^4.4.0" from @typescript-eslint/[email protected]
npm ERR!     node_modules/@typescript-eslint/utils
npm ERR!       @typescript-eslint/utils@"8.5.0" from @typescript-eslint/[email protected]
npm ERR!       node_modules/@typescript-eslint/eslint-plugin
npm ERR!         dev @typescript-eslint/eslint-plugin@"^8.5.0" from the root project
npm ERR!       1 more (@typescript-eslint/type-utils)
npm ERR!   7 more (@typescript-eslint/eslint-plugin, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from [email protected]
npm ERR! node_modules/eslint-plugin-import
npm ERR!   dev eslint-plugin-import@"^2.30.0" from the root project
npm ERR!   peerOptional eslint-plugin-import@"*" from [email protected]
npm ERR!   node_modules/eslint-import-resolver-typescript
npm ERR!     dev eslint-import-resolver-typescript@"^3.6.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from [email protected]
npm ERR!   node_modules/eslint-plugin-import
npm ERR!     dev eslint-plugin-import@"^2.30.0" from the root project
npm ERR!     peerOptional eslint-plugin-import@"*" from [email protected]
npm ERR!     node_modules/eslint-import-resolver-typescript
npm ERR!       dev eslint-import-resolver-typescript@"^3.6.3" 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.

nikolailehbrink avatar Sep 14 '24 16:09 nikolailehbrink

@nikolailehbrink your issue is with eslint-plugin-import. I don’t use it personally, but you could try see if they have an rc/beta/preview branch with eslint 9 support.

bsal649 avatar Sep 15 '24 01:09 bsal649

@nikolailehbrink you can also use eslint plugin perfectionist as it has a similar feature of import ordering to eslint-plugin-import, and supports eslint v9

bsShoham avatar Sep 17 '24 10:09 bsShoham

thanks @bsal649, whilst using the release candidate as work around does indeed fix the issue (and may be useful for other projects), RCs seem to be updated daily. I'm mainly worried about platform stability and ideally require a stable release version for our application.

DeadEnglish avatar Sep 19 '24 10:09 DeadEnglish

I believe this related to https://github.com/facebook/react/issues/28313

DAcodedBEAT avatar Sep 19 '24 19:09 DAcodedBEAT

Fixed in https://github.com/facebook/react/pull/28773. Will be released alongside React 19 as stable. You can use it today by install eslint-plugin-react-hooks@rc.

eps1lon avatar Sep 25 '24 15:09 eps1lon