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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 21:48:48  来源:igfitidea点击:

How to disable ESLint in vue-cli?

javascriptwebpackvue.jsvue-cli

提问by Mahmud Adam

How do I go about disabling ESlintin 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 ESLintduring 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 preLoadersblock.

查看模板{{#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

In the latest version, open the ".eslintrc.js" file, and set "root: false".enter image description here

在最新版本中,打开“.eslintrc.js”文件,并设置“root:false”。在此处输入图片说明

回答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

Set useEslint: false,in config/index.js

设置 useEslint: false,config/index.js

see this image

看到这张图片

回答by xgqfrms

One of the most simple way is just setting an .eslintignorefile 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: falsework 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,
    ...
  },
}