简体   繁体   English

使用最新的 vue-eslint-parser - encore

[英]Use the latest vue-eslint-parser - encore

I was able to set up ESLint working with Encore (Symfony).我能够使用 Encore (Symfony) 设置 ESLint。 My .eslintrc.js file has the following configuration:我的.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",
    ]
};

and whenever I watch the files I get the following error 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每当我观看文件时,我都会收到以下错误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 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 . 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

I have tried the solutions in the following links:我已经尝试了以下链接中的解决方案:

Any suggestion would be highly appreciated.任何建议将不胜感激。 Thank you谢谢

it's because Encore force parser option to babel-eslint and it's not compatible with eslint-plugin-vue.这是因为 Encore 对 babel-eslint 强制解析器选项,并且它与 eslint-plugin-vue 不兼容。

As a workaround you can use the following code to let Encore/ESLint lint your.vue files:作为一种解决方法,您可以使用以下代码让 Encore/ESLint 对您的 .vue 文件进行 lint:

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

All credits goes to Kocal at Github: https://github.com/symfony/webpack-encore/issues/656所有学分都归 Kocal 在 Github: https://github.com/symfony/webpack-encore/issues/656

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM