解决eslint配置导致vue template 报错

背景:

项目使用eslint-config-elemefe,饿了么的eslint配置。按官网提示配置.eslintrc,内容是{"extends": "elemefe"},packet.json添加

"eslint": "4.14.0",

"eslint-config-elemefe": "0.1.1",

"eslint-loader": "^1.9.0",

"eslint-plugin-html": "^4.0.1",

"eslint-plugin-json": "^1.2.0":

npm install后,用vscode打开,vue文件的template标签里面 ,使用:xx,等vue模板的写法全部都报错。

解决方案:

.eslintrc文件修改为

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true,
    "mocha": true
  },
  "plugins": [
    "html"
  ],
  "parserOptions": {
    "sourceType": "module",
    "ecmaVersion": 2017,
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
    }
  },
  "extends": "elemefe"
}

 重新打开就可以了。

附上vscode的设置项

{
  //使用vscode的格式化代码时,按eslint的规则
  "prettier.eslintIntegration": true,
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    {
      "language": "vue",
      "autoFix": true
    },
    "html",
    "vue"
  ],
  "vetur.validation.template": false
}

 

你可能感兴趣的:(解决eslint配置导致vue template 报错)