也许类似于How do I configure ESLint to allow fat arrow class methodsESLint示出了类实例属性错误初始化为箭头功能
当类方法定义为箭头函数Eslint高亮错误“方法”没有定义。 (无为undef)。 简单的例子
class abc {
d =() => {
// method body
}
}
这里就不difined '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"]
}
也许我需要声明一些规则?
ES6类没有实例变量,这就是'd'在这里。 – 2017-08-17 03:47:07
箭头函数在'class'中没有意义 - 就像设置'Something.prototype.somefunction =()=> {}'没有意义 –
@torazaburo - 'class'语法不提供实例变量,但是如果在方法中创建的话,结果类可以拥有它们。 (正在选择措辞。)(所以我的措辞可能也是错误的。) – nnnnnn