ESLint 正在抛出一个Parsing error: Unexpected token =
当我尝试 lint 我的 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)不支持实验性功能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)