3

我有一个成功构建的 vue 项目,但是当我在 package.json 文件中添加 eslint 选项时,我收到 Parsing error: Unexpected token pointing at a private variable。过去几个小时我一直在研究,但未能找到有效的解决方案。

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

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

还有一些……

我似乎无法弄清楚为什么 lint 抱怨一个变量。从 package.json 运行 vue-cli-service lint 的屏幕截图。下面我尝试将公共更改为私有或删除下划线,但这似乎没有帮助 在此处输入图像描述

我的 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 通过。

4

0 回答 0