eslint在案例类属性声明中无法识别格式错误

时间:2019-07-03 09:40:24

标签: javascript eslint ecmascript-7

我在代码中使用了eslint和es7类。 声明变量的情况下eslint的默认行为如下

let myVariable='some text'

使用eslint后的结果是

let myVariable = 'some text';

但是当我声明类似的类

class Person {
  firstName='mike'
}

结帐后的结果是

class Person {
  firstName= 'mike';
}

但必须是

class Person {
  firstName = 'mike';
}

这是我的devDependencies

"@babel/preset-env": "^7.4.5",
  "@babel/register": "^7.4.4",
  "@types/jest": "^24.0.13",
  "babel-eslint": "^10.0.2",
  "eslint": "^5.16.0",
  "eslint-config-airbnb": "^17.1.1",
  "eslint-plugin-babel": "^5.3.0",
  "eslint-plugin-import": "^2.17.3",
  "eslint-plugin-jsx-a11y": "^6.2.3",
  "eslint-plugin-react": "^7.14.2",
  "jest": "^24.8.0",
  "prettier": "^1.18.2",
  "pretty-quick": "^1.11.1",
  "webpack": "^4.34.0",
  "webpack-cli": "^3.3.4",
  "webpack-dev-server": "^3.7.2"

这是.eslintrc内容

"root": true,
  "extends": "airbnb-base",
  "env": {
    "jest": true,
    "es6": true
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module",
    "ecmaFeatures": {
      "impliedStrict": true,
      "jsx": true
    }
  },
  "plugins": [
    "babel"
  ],
  "rules": {
    "babel/new-cap": 1,
    "babel/camelcase": 1,
    "babel/no-invalid-this": 1,
    "babel/object-curly-spacing": 1,
    "babel/quotes": 0,
    "babel/semi": 2,
    "babel/no-unused-expressions": 1,
    "babel/valid-typeof": 1
  }

请您帮我解决这个问题

0 个答案:

没有答案