create-config icon indicating copy to clipboard operation
create-config copied to clipboard

Init wizard installs old version

Open elygeo opened this issue 1 year ago • 11 comments
trafficstars

Environment

Node version: v21.7.3 npm version: 10.5.2 Local ESLint version: v9.1.1 Operating System: MacOS

What parser are you using?

Default (Espree)

What did you do?

$ npm init @eslint/config@latest (accept defaults)

$ npx eslint --version

What did you expect to happen?

v9.1.1

What actually happened?

v8.57.0

elygeo avatar Apr 22 '24 15:04 elygeo

Duplicate of https://github.com/eslint/eslint/issues/18369

nzakas avatar Apr 22 '24 18:04 nzakas

Moving this over to the create-config repo as this isn't tied to anything ESLint is doing.

nzakas avatar Apr 22 '24 18:04 nzakas

@aladdin-add can you take a look at this?

nzakas avatar Apr 23 '24 17:04 nzakas

I was able to repro!

However, it's expected behavior: the required deps eslint-plugin-react does not allow eslint v9. So, package managers like npm will install v8 instead; while yarn v1 will install eslint v9. 🤔

https://github.com/jsx-eslint/eslint-plugin-react/blob/4467db503e38b9356517cf6926d11be544ccf4b1/package.json#L81

you can use "npm install eslint@9 --force" to accept a "broken" deps tree. But the safest way is using eslint v8 before v9 is officially supported.

aladdin-add avatar Apr 24 '24 03:04 aladdin-add

Should we maybe detect this and then ask if people want to override and force ESLint 9 to be installed?

nzakas avatar Apr 24 '24 18:04 nzakas

I don't think it's appropriate (at least for most users) - eslint v9 is not supported by the plugin, and not even tested. We can output some information, the advanced users can upgrade to v9 manually if they are willing to try, just like use-at-your-own-risks.

aladdin-add avatar Apr 25 '24 02:04 aladdin-add

some known issues: https://github.com/jsx-eslint/eslint-plugin-react/issues/3699

aladdin-add avatar Apr 25 '24 02:04 aladdin-add

What part isn't appropriate?

I think telling people that they're using a plugin that isn't supported in v9 and then giving them the option to continue or install v8 makes sense in all cases. Is there something I'm missing?

nzakas avatar Apr 25 '24 18:04 nzakas

It doesn't seem reasonable to install a version that may not work. good to use @eslint/backcompat as described in https://github.com/eslint/rewrite/issues/4.

aladdin-add avatar Apr 28 '24 01:04 aladdin-add

Sorry, I think maybe I'm not explaining myself well.

What I think we should do for now is, if they select React, to message them saying, "The React plugin works in ESLint < 9.0.0. Would you like to install ESLint 8.57?" (or something like that) To make it obvious what is happening. If they answer "No", then we just don't add the plugin. Does that make sense?

And yes, once the compat utility is published, we can always go back and wrap the plugin and avoid this mess.

nzakas avatar Apr 29 '24 20:04 nzakas

I see, thanks for explaining. SGTM. 👍

aladdin-add avatar Apr 30 '24 03:04 aladdin-add

Compat utility is ready: https://eslint.org/blog/2024/05/eslint-compatibility-utilities/

nzakas avatar May 09 '24 15:05 nzakas