Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent webpack to fail build on eslint error?

i used the default vue-cli command to create a vue project.

When webpack is building, it fails, as shown in the image:

enter image description here

I am not using any special webpack configuration. What am i doing wrong?

My package.json:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.4.4",
    "firebase": "^7.6.2",
    "register-service-worker": "^1.6.2",
    "vue": "^2.6.10",
    "vue-router": "^3.1.3",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-plugin-pwa": "^4.1.0",
    "@vue/cli-plugin-router": "^4.1.0",
    "@vue/cli-plugin-vuex": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "babel-eslint": "^10.0.3",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "node-sass": "^4.12.0",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.10"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}
like image 448
johannesdz Avatar asked Jan 10 '20 14:01

johannesdz


1 Answers

You can force ESLint to always emit just warnings instead of errors by webpack configuration. That will not stop your build as you expect. You need to set emitWarning option to true in your webpack.config.js file. eg.

module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        exclude: /node_modules/,
        loader: "eslint-loader",
        options: {
          emitWarning: true
        }
      }
    ]
  }
};

You can read more in the documentation https://github.com/webpack-contrib/eslint-loader#errors-and-warning

like image 109
ilnicki010 Avatar answered Sep 27 '22 17:09

ilnicki010