0

At some point in one of my Vue projects Eslint started breaking builds due to any error (such as "Strings must use singlequote", or "Variable declared but never used"). Also the formatting errors are not corrected automatically (although they should?). I don't know when exatly this happened and what caused it. Could be after some npm install.

I have found multiple suggestions to solve the problem by adding emitWarning: true to eslint config, but it does not work form me unfortunatelly.

It seems to me that sometimes the first attempt to build is successfull and errors are "detected" and thrown only after I change something in the code, save and the server restars. Also eslint seems to care only about files that are actually open in VS Code at the moment, if I close a file and restart, eslint no longer cares that the formatting is incorrect there.

Here's my .eslintrc.js contents:

module.exports = {
    root: true,
    env: {
        node: true,
        "es6": true
    },
    extends: [
        "plugin:vue/essential",
        "@vue/standard"
    ],
    rules: {
        "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
        "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
        "indent": ["error", 4],
        "semi": ["error", "always"],
        "space-before-function-paren": ["error", "never"],
        "quotes": ["error", "single"]
    },
    parserOptions: {
        parser: "babel-eslint",
        sourceType: "module",
        ecmaVersion: 6,
        emitWarning: true, // tried with and without this
        emitError: false, // tried with and without this
        failOnError: false, // tried with and without this
        failOnWarning: false // tried with and without this
    }
};

My other Vue project works fine. I'm not able to pinpoint any meaningful differences in setup.

How to stop eslint from breaking builds? What else can be wrong here? I'll be greatful for any help!

1 Answer 1

1

You can make the build command skip ESlint by changing the build script in the package.json file:

"scripts": {
    "build": "vue-cli-service build --skip-plugins @vue/cli-plugin-eslint",
}

Replace the plugin with the appropriate one if that's not the one being used in your project.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! I see that some formatting is still being corrected - what is responsible for that if that plugin is disabled? In VS Code I have the formatOnSave disabled as well, so it's not VS code.
@Eggon Perhaps you should set lintOnSave to false in the vue.config.js file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.