Encore,Vue,Eslint-使用最新的vue-eslint-parser [英] Encore, Vue, Eslint - Use the latest vue-eslint-parser

查看:237
本文介绍了Encore,Vue,Eslint-使用最新的vue-eslint-parser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我遇到了vue-eslint-parser的问题.我正在尝试在Encore上运行它

Hi guys I'm having an issue with vue-eslint-parser. I'm trying to run it on Encore

/var/app/assets/js/app.js 1:1错误使用最新的vue-eslint-parser.另请参见 https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/valid-v-pre 1:1错误使用最新的vue-eslint-parser.另请参见 https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-duplicate-attributes 1:1错误使用最新的vue-eslint-parser.另请参见 https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-textarea-mustache

/var/app/assets/js/app.js 1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/valid-v-pre 1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-duplicate-attributes 1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-textarea-mustache

无法确定发生了什么,链接错误无济于事 我在docker容器中运行yarn

Can't figure out what's going on, link in an error doesn't help I'm running yarn in docker container

docker-compose.yaml文件

docker-compose.yaml file

yarn:
    image: node:10
    command: yarn run install_watch
    working_dir: /var/app
    volumes:
      - .:/var/app/:cached
    environment:
      NPM_TOKEN: "${NPM_TOKEN}"

webpack.config.js

webpack.config.js

var Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .addEntry('app', './assets/js/app.js')
    .enableSingleRuntimeChunk()
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    .enableEslintLoader()
    .enableSassLoader()
    .enableVueLoader()
;

module.exports = Encore.getWebpackConfig();

package.json

package.json

{
    "devDependencies": {
        "@symfony/webpack-encore": "^0.22.0",
        "@vue/cli-plugin-eslint": "^3.4.1",
        "babel-eslint": "^8.2.1",
        "eslint-loader": "^1.9.0",
        "node-sass": "^4.11.0",
        "sass-loader": "^7.0.1",
        "vue": "^2.6.6",
        "vuex": "^3.1.0",
        "vue-loader": "^15.0.11",
        "vue-router": "^3.0.2",
        "vue-template-compiler": "^2.6.6",
        "webpack-notifier": "^1.6.0"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production --progress",
        "install_prod": "yarn install && yarn run build",
        "install_watch": "yarn install && yarn run watch"
    }
}

.eslintrc.json

.eslintrc.json

{
    "env": {
        "browser": true,
        "es6": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "plugins": [
        "vue"
    ],
    "rules": {
    }
}

推荐答案

"parser": "babel-eslint"与Vue插件之间似乎存在冲突.

Seems like there is a conflict between "parser": "babel-eslint" and the Vue plugin.

  • Source : https://github.com/vuejs/eslint-plugin-vue/issues/30
  • Solution described here : The workaround is here: https://github.com/mysticatea/vue-eslint-parser#-options "parserOptions": {"parser": "babel-eslint"} should work.

这是一个完整的可以运行的.eslintrc.js文件(至少在我的项目中如此):

Here is a complete working .eslintrc.js file (at least on my project):

module.exports = {  
    // Use only this configuration  
    root: true,  
    // File parser
    parser: 'vue-eslint-parser',  
    parserOptions: {    
        // Use babel-eslint for JavaScript    
        'parser': 'babel-eslint',    
        'ecmaVersion': 2017,    
        // With import/export syntax    
        'sourceType': 'module' 
    },  
    // Environment global objects  
    env: {    
        browser: true,    
        es6: true,  
    },  
    extends: [    
        // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style   
        'standard',    
        // https://github.com/vuejs/eslint-plugin-vue#bulb-rules    
        'plugin:vue/recommended',
    ]
,}

这篇关于Encore,Vue,Eslint-使用最新的vue-eslint-parser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆