【问题标题】:Eslint in reactjs project fixing warningsreactjs 项目中的 Eslint 修复警告
【发布时间】:2020-07-14 06:46:15
【问题描述】:

我有警告规则'react/state-in-constructor'的定义不是foundeslint(react/state-in-constructor)

Eslint 版本 6.8.0

我的文件中的代码 .eslintrc.js

module.exports = {
  env: {
    node: true
  },
  extends: ['eslint:recommended', 'plugin:react/recommended'],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parser: 'babel-eslint',
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: ['react'],
  rules: {
    strict: 0,
    semi: 'error',
    'react/state-in-constructor': 1,
    'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }]
  },
  settings: {
    react: {
      createClass: 'createReactClass',
      pragma: 'React',
      version: 'detect',
      flowVersion: '0.53'
    },
    propWrapperFunctions: [
      'forbidExtraProps',
      { property: 'freeze', object: 'Object' },
      { property: 'myFavoriteWrapper' }
    ],
    linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }]
  }
};

【问题讨论】:

  • 你能发布你的package.json吗,好像有些依赖没有安装。
  • 你可以在codepen看到
  • 将 eslint-plugin-react 更新到最新版本。

标签: javascript reactjs eslint


【解决方案1】:

您的eslint-plugin-react npm 包需要更新才能使该功能正常工作。

通过运行npm install eslint-plugin-react@latest来解决它。

或者用纱线:yarn add eslint-plugin-react@latest

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 2020-07-21
    • 1970-01-01
    • 2017-05-21
    • 2018-10-06
    • 2016-01-09
    • 1970-01-01
    相关资源
    最近更新 更多