Javascript 如何在 vue-cli 中禁用 ESLint?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38757069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable ESLint in vue-cli?
提问by Mahmud Adam
How do I go about disabling ESlint
in project generated with vue-cli
?
如何禁用ESlint
生成的项目vue-cli
?
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
]
If I remove the loader: 'eslint'
line it won't compile, same with setting it to an empty string. I know I can opt out of ESLint
during the initialization phase, but how can I disable it after my project has been created?
如果我删除该loader: 'eslint'
行,它将无法编译,与将其设置为空字符串相同。我知道我可以ESLint
在初始化阶段选择退出,但如何在我的项目创建后禁用它?
采纳答案by ceejayoz
Vue's starter projects are themselves built with a templating language.
Vue 的入门项目本身是用模板语言构建的。
Looking at the templates(the {{#lint}}
bits) it appears you can remove the entire preLoaders
block.
查看模板({{#lint}}
位),您可以删除整个preLoaders
块。
回答by Akash
As of 2019, March
:
截至2019, March
:
In the vue.config.js
:
在vue.config.js
:
module.exports = {
...
lintOnSave: false
...
}
Good Luck...
祝你好运...
回答by Wossname
There are some out-of-date answers here.
这里有一些过时的答案。
Because vue-cli 3 is using a zero configuration approach, the way to disable it is to just uninstall the module:
因为 vue-cli 3 使用的是零配置的方式,禁用它的方法就是卸载模块:
npm remove @vue/cli-plugin-eslint
回答by Eric Grotke
As of the current version (^3.0?) you can just set:
从当前版本 (^3.0?) 开始,您可以设置:
useEslint: false,
使用Eslint:假,
in config/index.js
在 config/index.js 中
回答by Felix Jr
回答by reverie_ss
There's a hell lot of solutions here: https://github.com/vuejs-templates/webpack/issues/73
这里有很多解决方案:https: //github.com/vuejs-templates/webpack/issues/73
However the best one is :
To add a line of **/*
to .eslintignore, which will ignore all files.
And then re-run, if it's a web app!
但是最好的方法是:
在**/*
.eslintignore 中添加一行,这将忽略所有文件。然后重新运行,如果它是一个网络应用程序!
回答by Panayiotis Hiripis
Go inside file "tslint.json" and exclude all files in linterOptions. Default settings only excludes folder node_modules. You may also set "strict": false, inside tsconfig.json
进入文件“tslint.json”并排除 linterOptions 中的所有文件。默认设置仅排除文件夹 node_modules。你也可以在 tsconfig.json 中设置 "strict": false
"linterOptions": {
"exclude": [
"*/**"
]
},
instead of
代替
"linterOptions": {
"exclude": [
"node_modules/**"
]
},
回答by Santosh P
回答by xgqfrms
One of the most simple way is just setting an .eslintignore
file with you want to disabled folders & files.
最简单的方法之一就是设置一个.eslintignore
文件,你想禁用文件夹和文件。
demo
演示
/build/
/config/
/dist/
/*.js
/test/unit/coverage/
/000-xyz/
Ref: https://github.com/vuejs-templates/webpack/issues/73#issuecomment-355149342
参考:https: //github.com/vuejs-templates/webpack/issues/73#issuecomment-355149342
回答by ZWHmepsy
setEslint: false
work for me!
setEslint: false
为我工作!
module.exports = {
dev: {
...
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: false,
...
},
}