5

I'm trying to complete a tutorial.

I'm stuck with an error that is caused by ESLint:

> Failed to compile.

./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):

C:\Users\romul\Vue Projects\produto-client\src\App.vue
  110:36  error  'resposta' is defined but never used  no-unused-vars

✖ 1 problem (1 error, 0 warnings)

I want to know how to disable eslint.

This is my project structure:

enter image description here

I searched on the internet, but I couldn't understand how to disable it.

3
  • 3
    Why not just remove the unused vars? And is this VS Code? Commented Mar 11, 2020 at 0:11
  • you can disable this rule in the config Commented Mar 11, 2020 at 0:18
  • Yes i´m using vs code, i'm just trying to follow the tutorial and this is how he ask to do Commented Mar 11, 2020 at 3:15

3 Answers 3

6

The correct solution to your problem is to actually follow the linter error and remove the unused variables from your code, either temporarily comment them out or delete the line entirely. Disabling the linter is a temporary workaround, but should not be a long-term solution.

But, for the purposes of your question, it is possible to disable the linter (ESLint).

When creating the standard Vue app directory, you have the option of enabling ESLint and storing the ESLint configuration in either the package.json or in a separate .eslintrc.js file. From your screenshot, it seems you added the ESLint configuration in your package.json, like this:

enter image description here

See that eslintConfig block?

  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/standard"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },

You can enable/disable specific ESLint rules in the rules block.
For example, for no-unused-vars:

    "rules": {
        "no-unused-vars": "off"
    }

Then make changes to the src files and save (the default Vue configuration is to run the linter on save).

If the ESLint rules are in a separate .eslintrc.js file, the procedure is the same, just on/off specific rules under the rules block.

Or, if you want to disable ESLint entirely, create a vue.config.js file with the lintOnSave setting set to false:

// vue.config.js
module.exports = {
    lintOnSave: false
}

Now, running the app (npm run serve) won't anymore trigger the linter.

Additionally, if you are using VS Code, it supports ESLint integration. I'm not sure if the rest of your tutorial will also discuss linting with VS Code, but it can/might also report some errors/warnings in the Problems tab.

You can disable them from your User/Workspace settings:

"eslint.enable": false,
Sign up to request clarification or add additional context in comments.

Comments

0

several ways to do this:

  • create a .eslintignore file at the root of your project, and input **/*. this will ignore all files in your project

OR

  • create a .eslintrc.json file at the root of your project. and input
{
  "rules":{
  "no-unused-vars": "off"
 }
}

this will suppress the specific error you are getting.

Comments

0

The simplest solution is to set the lintOnSave: false in your vue.config.js file.

This simply stops the eslint-loader running when the file is compiled.

// vue.config.js
module.exports = {
  lintOnSave: false
}

The better solution is to set lineOnSave: 'warning' which ensures that eslint errors are emitted as warnings therefore the errors aren't surpressed but they also don't prevent the compiling.

// vue.config.js
module.exports = {
  lintOnSave: 'warning'
}

See documentation here: https://cli.vuejs.org/config/#lintonsave

Comments

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.