【问题标题】:Use the latest vue-eslint-parser - encore使用最新的 vue-eslint-parser - encore
【发布时间】:2020-02-15 04:23:09
【问题描述】:

我能够使用 Encore (Symfony) 设置 ESLint。我的.eslintrc.js 文件有以下配置:

module.exports = {
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaFeatures": {
            "legacyDecorators": true
        },
        "ecmaVersion": 5,
    },
    "extends": [
        "plugin:vue/base",
        "airbnb-base"
    ],
    "rules": {
       "vue/html-indent": [2, 4],
        ...
    },
    "env": {
        browser: true,
        es6: true,
        node: true
    },
    "plugins": [
        "vue",
    ]
};

每当我观看文件时,我都会收到以下错误1:1 error Use the latest vue-eslint-parser. See also https://vuejs.github.io/eslint-plugin-vue/user-guide/#what-is-the-use-the-latest-vue-eslint-parser-error vue/html-indent

我已经尝试了以下链接中的解决方案:

任何建议将不胜感激。谢谢

【问题讨论】:

    标签: vue.js eslint webpack-encore eslintrc


    【解决方案1】:

    这是因为 Encore 对 babel-eslint 强制解析器选项,它与 eslint-plugin-vue 不兼容。

    作为一种解决方法,您可以使用以下代码让 Encore/ESLint 对您的 .vue 文件进行 lint:

    Encore
      .enableEslintLoader(options => {
          delete options.parser;
      })
      .configureLoaderRule('eslint', loader => {
          loader.test = /\.(jsx?|vue)$/;
      })
    

    所有学分都归于 Github 上的 Kocal:https://github.com/symfony/webpack-encore/issues/656

    【讨论】:

      猜你喜欢
      • 2019-07-16
      • 2020-11-10
      • 2021-12-22
      • 2021-06-01
      • 2020-05-23
      • 1970-01-01
      • 2019-06-25
      • 1970-01-01
      • 2020-06-10
      相关资源
      最近更新 更多