在“eslint-plugin-react-settings”中收到警告;运行 eslint 时

发布于 2025-01-13 11:12:23 字数 234 浏览 3 评论 0原文

得到:

警告:eslint-plugin-react-settings 中指定的 React 版本必须是有效的 semver 版本,或“检测”;运行 eslint 时获得“最新”。

这背后的原因是什么以及如何解决?

问题的屏幕截图

Getting the:

warning: React version specified in eslint-plugin-react-settings must be a valid semver version, or "detect"; got “latest”' while running eslint.

What is the reason behind this and how to resolve it?

Screenshot of the issue

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮华 2025-01-20 11:12:23

您的 .eslintrc 文件中将定义一个对象作为设置。而这个错误是说其中定义的react版本不是你机器上安装的版本。请将设置对象替换为以下代码,以便 es lint 可以在运行时自动检测到它。

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

There will be an Object defined in your .eslintrc file as settings. And this error is saying that the version of react defined in it is not the version installed in your machine. Please replace settings object with following code so that es lint can detect it automatically on runtime.

"settings": {
    "react": {
      "version": "detect"
    }
  }
呆头 2025-01-20 11:12:23

只需在 .eslintrc 文件中添加代码(js,json)
因为这个 eslint 会自动检测 React 版本

Just add the code in the .eslintrc file (js,json)
as this eslint will automatically detect the react version ????

"plugins": [
...
],
"settings": {
  "react": {
    "version": "detect"
  }
},
"rules": {
...
}
只是一片海 2025-01-20 11:12:23

将其添加到我的 .eslintrc 文件中解决了问题。

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

adding this in my .eslintrc file fixed the problem.

"settings": {
    "react": {
      "version": "detect"
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文