在React中设置状态时,出现了eslint错误。

18 浏览
0 Comments

在React中设置状态时,出现了eslint错误。

我在React中有一个非常简单的例子:

export default class App extends Component{
  state={
    count:0
  }

我在`state={....`下遇到了一个ESLint错误:

Parsing error: Unexpected token = eslint

我不知道为什么会出现这个错误...我需要安装ESLint-react插件吗?

这是我的eslintrc.js文件:

module.exports = {
  env: {
    browser: true,
    es6: true
  },
  extends: [
    'standard'
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: [
    'react'
  ],
  rules: {
  }
}

0