[英]ESLint shows error on class instance property initialized to arrow function
可能类似于我如何配置ESLint以允许胖箭头类方法
当类方法定义为箭头函数Eslint高亮显示错误“方法”未定义时。 (无为undef)。 简单的例子
class abc {
d = () => {
// method body
}
}
这里没有定义“ d”
我的.eslintrc配置
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:flowtype/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react",
"flowtype"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
.babelrc
{
"presets": ["react", "es2015", "stage-1", "flow"]
}
也许我需要声明一些规则?
如MinusFour答案所提及,我尝试通过命令行运行eslint,但没有看到该错误。
我的编辑器配置错误。 (原子的linter-eslint包中的node_modules文件夹路径错误)。 在删除此路径并重新启动编辑器后,一切正常。
这还没有融入Java语言 。 它可以作为babel的实验性插件使用,因此您需要使用babel-eslint
更改eslint的默认解析器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.