小编典典

如何配置ESLint以允许使用胖箭头类方法

reactjs

Parsing error: Unexpected token =当我尝试整理Es6类时,ESLint引发错误。我缺少在eslint中启用胖箭头类方法的配置参数吗?

范例类别:

class App extends React.Component{
    ...
    handleClick = (evt) => {
        ...
    }
}

.eslint

{
  "ecmaFeatures": {
    "jsx": true,
    "modules":true,
    "arrowFunctions":true,
    "classes":true,
    "spread":true,

  },
  "env": {
    "browser": true,
    "node": true,
    "es6": true
  },
  "rules": {
    "strict": 0,
    "no-underscore-dangle": 0,
    "quotes": [
      2,
      "single"
    ],
  }
}

阅读 362

收藏
2020-07-22

共1个答案

小编典典

如果要使用实验性功能(例如箭头作为类方法),则需要babel-eslint用作解析器。默认解析器(Espree)不支持实验性功能。

2020-07-22