Disable eslint Vue.js
Answer a question
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:

I searched on the internet, but I couldn't understand how to disable it.
Answers
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:

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,
更多推荐




所有评论(0)