eslint-community / eslint-utils

Utilities for ESLint plugins and custom rules.
https://eslint-community.github.io/eslint-utils
MIT License
18 stars 7 forks source link

Support ESLint 9 #183

Open fisker opened 9 months ago

fisker commented 9 months ago

ESLint v9.0.0-alpha.0 released

JoshuaKGoldberg commented 7 months ago

🤔 #186 mostly just has test file changes. Does that imply eslint-utils already supports ESLint 9?

cc @voxpelli from https://github.com/eslint/eslint/issues/18093#issuecomment-1986517191

fisker commented 7 months ago

No, can't be installed without --legacy-peer-deps, it's blocking unicorn https://github.com/sindresorhus/eslint-plugin-unicorn/actions/runs/8019879716/job/21908544750?pr=2250#step:4:14

voxpelli commented 7 months ago

No, can't be installed without --legacy-peer-deps, it's blocking unicorn

I guess that's because >=8.0.0 doesn't match prereleases, which makes little sense for peer dependencies, but since it's easier to change here than to change npm I guess we could update it to say:

^8.0.0 || >=9.0.0-beta.2

That should fix it, right?

voxpelli commented 7 months ago

One thing I don't get about version ranges and npm is that when I try it on https://semver.npmjs.com/ I get this:

>=9.0.0-0: 9.0.0-alpha.0, 9.0.0-alpha.1, 9.0.0-alpha.2, 9.0.0-beta.0, 9.0.0-beta.1, 9.0.0-beta.2 ^8.0.0 || >=9.0.0-0: no 9.x versions at all 🤔

I wonder if that's a bug with semver.npmjs.com or with semver in itself – I will investigate.


This is a similar issue as in https://github.com/eslint-community/eslint-plugin-n/issues/197 – that >=8.0.0 doesn't include prereleases of new versions is quite a challenge. Might be that we should always do the >= on the earliest next major version pre-release rather than on the current stable major release

voxpelli commented 7 months ago

I tested using the semver module itself:

import { satisfies, compare } from 'semver';

console.log(satisfies('8.2.3',         '^8.0.0 || >=9.0.0-0')); // true
console.log(satisfies('9.0.0-beta.2',  '^8.0.0 || >=9.0.0-0')); // true
console.log(satisfies('9.2.3',         '^8.0.0 || >=9.0.0-0')); // true
console.log(satisfies('9.2.3-beta.2',  '^8.0.0 || >=9.0.0-0')); // false
console.log(satisfies('10.0.0-beta.2', '^8.0.0 || >=9.0.0-0')); // false
console.log(satisfies('10.0.0',        '^8.0.0 || >=9.0.0-0')); // true

console.log('');

console.log(satisfies('9.0.0-beta.2',  '>=8.0.0', { includePrerelease: true })); // true
console.log(satisfies('9.2.3-beta.2',  '>=8.0.0', { includePrerelease: true })); // true
console.log(satisfies('10.0.0-beta.2', '>=8.0.0', { includePrerelease: true })); // true

// [ '9.0.0-0', '9.0.0--', '9.0.0-a', '9.0.0-beta.2' ]
console.log(['9.0.0--', '9.0.0-0', '9.0.0-a', '9.0.0-beta.2'].sort(compare));

This shows:

I'll open a PR

voxpelli commented 7 months ago

Found a relevant RFC: https://github.com/npm/rfcs/pull/397

harryzcy commented 6 months ago

It looks like ESLint 9 is released, so matching pre-releases is no longer necessary.

barbalex commented 6 months ago

It seems it does not work though? I am using:

"eslint": "9.0.0",

And getting:

√ Run npm install to install new versions? ... yes
Installing dependencies...
npm ERR! 
code ERESOLVE

npm ERR!
 ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @typescript-eslint/eslint-plugin@7.5.0
npm ERR! Found: eslint@9.0.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"9.0.0" from the root project
npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/eslint-utils@4.4.0
npm ERR!   node_modules/@eslint-community/eslint-utils
npm ERR!     @eslint-community/eslint-utils@"^4.4.0" from @typescript-eslint/utils@7.5.0
npm ERR!     node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils
npm ERR!       @typescript-eslint/utils@"7.5.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR!       node_modules/@typescript-eslint/eslint-plugin
npm ERR!         dev @typescript-eslint/eslint-plugin@"7.5.0" from the root project
npm
ERR!       1 more (@typescript-eslint/type-utils)
npm ERR!     @eslint-community/eslint-utils@"^4.2.0" from eslint@9.0.0
npm ERR!   1 more (eslint-plugin-react-refresh)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   dev @typescript-eslint/eslint-plugin@"7.5.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@8.57.0
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"7.5.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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\alexa\AppData\Local\npm-cache\_logs\2024-04-07T08_45_30_389Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\alexa\AppData\Local\npm-cache\_logs\2024-04-07T08_45_30_389Z-debug-0.log

Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @typescript-eslint/eslint-plugin@7.5.0
npm ERR! Found: eslint@9.0.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"9.0.0" from the root project
npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/eslint-utils@4.4.0
npm ERR!   node_modules/@eslint-community/eslint-utils
npm ERR!     @eslint-community/eslint-utils@"^4.4.0" from @typescript-eslint/utils@7.5.0
npm ERR!     node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils
npm ERR!       @typescript-eslint/utils@"7.5.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR!       node_modules/@typescript-eslint/eslint-plugin
npm ERR!         dev @typescript-eslint/eslint-plugin@"7.5.0" from the root project
npm ERR!       1 more (@typescript-eslint/type-utils)
npm ERR!     @eslint-community/eslint-utils@"^4.2.0" from eslint@9.0.0
npm ERR!   1 more (eslint-plugin-react-refresh)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   dev @typescript-eslint/eslint-plugin@"7.5.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@8.57.0
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.5.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"7.5.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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\alexa\AppData\Local\npm-cache\_logs\2024-04-07T08_45_30_389Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\alexa\AppData\Local\npm-cache\_logs\2024-04-07T08_45_30_389Z-debug-0.log

    at C:\Users\alexa\AppData\Roaming\nvm\v21.1.0\node_modules\npm-check-updates\build\src\index.js:178:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
voxpelli commented 6 months ago

@barbalex I believe that error is caused by @typescript-eslint/eslint-plugin not allowing eslint 9

JoshuaKGoldberg commented 6 months ago

For reference: https://github.com/typescript-eslint/typescript-eslint/issues/8211

We're a little behind over on typescript-eslint but we're working on it. Hoping to get the support out soon. ❤️

Edivion commented 4 months ago

Hi @JoshuaKGoldberg / @voxpelli, any update on the support for this?

sacru2red commented 3 months ago

ping Because of this issue, I won't be able to upgrade to eslint@9 for several months.

206 doesn't seem to need to be merged.

As for #186, I think you only need to change the peerDependency in package.json after merging, right?

voxpelli commented 3 months ago

@sacru2red How is it blocking? Isn't even ESLint 9 itself shipping with this module?

sacru2red commented 3 months ago

@voxpelli Opps. I saw simiar logs https://github.com/eslint-community/eslint-utils/issues/183#issuecomment-2041374657 I checked again and found that @typescript-eslint/parser was causing the problem. Thanks..