ESLint 抛出 Parsing error: Unexpected token =
错误,当我尝试检查我的 Es6 类时。我缺少什么配置参数来启用 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"
],
}
}
最佳答案
如果您想使用实验性功能(例如箭头作为类方法),您需要使用 babel-eslint
作为解析器。默认解析器 (Espree) 不支持实验性功能。
关于javascript - 如何配置 ESLint 以允许粗箭头类方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34244888/