React version not specified in eslint-plugin-react settings

执行npm start启动项目时在 Terminal 有警告信息,如下:

  1. Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .

未在 eslint-plugin-react 设置中,指定 React 版本号。

解决方法:

在 Github 中有提问,并且已经解决,链接如下:

https://github.com/yannickcr/eslint-plugin-react/issues/2157

eslintrc.js或者.eslintrc文件中添加配置项:

  1. "settings": {
  2. "react": {
  3. "version": "detect"
  4. }
  5. }

配置参数detect意思是自动检测。

至此,问题解决,重新启动项目不再警告。

另外,在警告信息里,给出的链接页面中,也有相应注明:

  1. "settings": {
  2. "react": {
  3. "createClass": "createReactClass", // Regex for Component Factory to use,
  4. // default to "createReactClass"
  5. "pragma": "React", // Pragma to use, default to "React"
  6. "version": "detect", // React version. "detect" automatically picks the version you have installed.
  7. // You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
  8. // default to latest and warns if missing
  9. // It will default to "detect" in the future
  10. "flowVersion": "0.53" // Flow version
  11. },

(完)