【问题标题】:ESlint doesn't work on .vue file with typescriptESlint 不适用于带有打字稿的 .vue 文件
【发布时间】:2020-04-06 18:38:25
【问题描述】:

我使用vue ui 构建了我的项目,这是我的 package.json

"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-typescript": "^4.1.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/eslint-config-typescript": "^4.0.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^6.0.1",
"typescript": "~3.5.3",

这是我的 .eslintrc.js 文件

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    '@vue/standard',
    '@vue/typescript'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    "indent": ['error', 4]
  },
  parserOptions: {
    parser: '@typescript-eslint/parser'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]
}

这是我的 Visual Studio 代码设置,settings.json

{
  "eslint.alwaysShowStatus": true,
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
      "javascript",
      "javascriptreact",
      { "language": "vue", "autoFix": true },
      { "language": "typescript", "autoFix": true },
      { "language": "typescriptreact", "autoFix": true }
  ]
}

它在 .ts 文件上运行良好,但在 .vue 文件上运行良好(没有任何 eslint 提示的类)。那么我应该怎么做才能解决它,有什么想法吗?

【问题讨论】:

    标签: typescript vue.js eslint


    【解决方案1】:

    你是如何运行 eslint 的?在 .eslintrc.json 文件中,您没有声明 eslint 来读取 .vue 文件。您应该使用 --ext 标志运行 eslint。 (eslnit .--ext .vue)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-01
      • 2018-12-07
      • 2020-02-08
      • 2017-01-01
      • 2019-09-08
      • 2021-03-20
      • 2018-02-11
      • 1970-01-01
      相关资源
      最近更新 更多