Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Warning: React version specified in eslint-plugin-react-settings must be a valid semver version, or "detect"; got “^17” #3857

Open
2 tasks done
Redirts opened this issue Nov 28, 2024 · 14 comments
Labels

Comments

@Redirts
Copy link

Redirts commented Nov 28, 2024

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

I am getting this Warning message:

Warning: React version specified in eslint-plugin-react-settings must be a valid semver version, or "detect"; got “^17”

I have a .eslintrc file with this setup:

"settings": {
"react": {
"version": "detect"
},

Expected Behavior

This plugin should be able to cope with carets which are part of the semver specification

eslint-plugin-react version

v7.37.2

eslint version

v8.57.0

node version

v20.10.0

@Redirts Redirts added the bug label Nov 28, 2024
@ljharb
Copy link
Member

ljharb commented Nov 28, 2024

Technically no, ranges are not part of the semver specification, they're something npm invented (although, they should be, and there's an open PR on the spec to add them).

It's meant to target a specific version. is there a reason you can't use "detect"?

@Redirts
Copy link
Author

Redirts commented Nov 29, 2024

I currently have "detect" on the .eslintc file. Are you referring to adding that tag somewhere else?

@ljharb
Copy link
Member

ljharb commented Nov 29, 2024

No, that’s what i meant. If you have that setting, where does the ^17 come from?

@Redirts
Copy link
Author

Redirts commented Nov 29, 2024

Well, from what I gather, the "detect" tag in .eslintc is making the plugin fetch the ^17 from my package.json (from the react dependency) and hence giving the warning.

My package.json has this in the dependencies:
...
"react": "^17",
....

@ljharb
Copy link
Member

ljharb commented Nov 29, 2024

The way "detect" works is it pulls the version number directly from the react you have installed on disk, so package.json shouldn't be involved at all (except in that it informs what ends up on disk).

@Redirts
Copy link
Author

Redirts commented Nov 29, 2024

If not from my package.json then I don't where else it would retrieve ^17 from:
If I do "npm list" I get, for React:

├── [email protected]

@ljharb
Copy link
Member

ljharb commented Nov 29, 2024

Can you use eslint --print-config=path/to/some/file and see what it says under settings? it's possible a shared config or a nested .eslintrc file is setting it to ^17.

@Redirts
Copy link
Author

Redirts commented Dec 1, 2024

Image

@Redirts
Copy link
Author

Redirts commented Jan 10, 2025

Is there any news on this @ljharb ? Thanks

@ljharb
Copy link
Member

ljharb commented Jan 10, 2025

I still can't reproduce or figure this out. Are you sure the output you gave was from that eslint command and not directly from your config in vscode?

@Redirts
Copy link
Author

Redirts commented Jan 10, 2025

Image

@ljharb
Copy link
Member

ljharb commented Jan 10, 2025

ok, so then the computed config is still not ^17, and we still don't know where that's coming from. can you run the same command, but pass the path to a file that normally generates this error?

@Redirts
Copy link
Author

Redirts commented Jan 10, 2025

Not sure I follow. Currently, I can see this error popping up during the execution of our sonarqube scan

Image

Not quite sure why it is throwing that error....

@ljharb
Copy link
Member

ljharb commented Jan 10, 2025

Does it only happen via sonarqube, not with the eslint cli?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants