The following code located in a class that extends React.Component
nextState = () => {
this.setState({
state : this.state.state + 1
});
};
However ESLint with airbnb rules catches this and throws the following error:
error Parsing error: Unexpected token =
I would like to keep this syntax as it allows me to avoid binding this
in the constructor.
I struggled with this problem for quite a while.
I found that this configuration of .eslintrc
works for your problem.
{
"extends": "airbnb",
"parser": "babel-eslint"
}
It works nicely with Sublime Text 3 with SublimeLinter-contrib-eslint.
Note that you need to npm install -g eslint babel-eslint
put .eslintrc
in ~/
for global config, put .eslintrc
in app folder to overwrite global config.
also note that: Assignment operation inside class is not part of es6, see this link for discussion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With