简体   繁体   中英

Eslint in reactjs project fixing warnings

I have warning Definition for rule 'react/state-in-constructor' was not foundeslint(react/state-in-constructor)

Eslint version 6.8.0

Code in my file .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' }]
  }
};

Your eslint-plugin-react npm package needs to be updated for that feature to work.

Solve it by running npm install eslint-plugin-react@latest .

Or with yarn: yarn add eslint-plugin-react@latest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM