Mysterious ESLint Parsing Error

狂风中的少年 提交于 2019-12-05 00:03:59

You cannot have properties inside classes, you can only have methods.

Reference: http://www.2ality.com/2015/02/es6-classes-final.html#inside_the_body_of_a_class_definition

I was able to fix this by:

1) Install babel-eslint

$ npm i --save-dev babel-eslint

OR

$ yarn add babel-eslint --dev

2) Configure ESLint to use babel-eslint as your parser

Just add "parser": "babel-eslint", to your .eslintrc file.

Sample .eslintrc to use babel-eslint and airbnb's configuration with some custom rules:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "rules": {
    "arrow-body-style": "off",
    "no-console": "off",
    "no-continue": "off"
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!