如何在vue-cli项目上配置eslint以使其正常工作

时间:2019-10-16 22:02:01

标签: typescript vue.js eslint babel-eslint

我有一个成功构建的Vue项目,但是当我在package.json文件中添加eslint选项时,我收到解析错误:意外的令牌指向私有变量。我已经研究了最近几个小时,但未能找到可行的解决方案。

我访问过的网站,并尝试过解决方法

https://stackoverflow.com/a/49129502/4250126

https://github.com/vuejs/eslint-plugin-vue/issues/746

https://stackoverflow.com/a/53609667/4250126

https://dev.to/ferasdawod/setting-up-eslint-for-a-vuejs-project-using-vs-code-i54

和其他一些...

我似乎无法弄清楚为什么皮棉抱怨变量。 从package.json运行vue-cli-service棉绒的屏幕截图。下面,我尝试将公共改为私有或删除下划线,但这似乎无济于事 enter image description here

我的package.json

{
  "name": "data-dictionary",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "description": "DataDictionary",
  "author": {
    "name": ""
  },
  "dependencies": {
    "@typescript-eslint/parser": "^2.4.0",
    "axios": "^0.19.0",
    "bootstrap-vue": "^2.0.4",
    "buefy": "^0.8.5",
    "eslint-plugin-import": "^2.18.2",
    "vue": "2.5.17",
    "vue-property-decorator": "^8.2.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "3.0.4",
    "@vue/cli-plugin-eslint": "3.0.4",
    "@vue/cli-plugin-typescript": "^3.12.0",
    "@vue/cli-service": "3.0.4",
    "babel-eslint": "^10.0.3",
    "eslint": "5.6.0",
    "eslint-plugin-vue": "^4.7.1",
    "typescript": "^3.6.4",
    "vue-template-compiler": "2.5.17"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:import/typescript",
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {
    },
    "parserOptions": {
      "parser": "babel-eslint",
      "sourceType": "module",
      "ecmaFeatures": {
        "legacyDecorators": true
      },
      "ecmaVersion": 6
    }
  },
  "eslintIgnore": [ "/**/*.d.ts" ],
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

感谢您的帮助。我可能正在做一些完全错误的事情,但是对在Vue中使用lint不太熟悉。

更新 如果我删除了public / private关键字,那么vue-cli-service的lint就会通过。

0 个答案:

没有答案