如何在vue-cli中禁用ESLint?

问题描述 投票:28回答:9

如何在ESlint生成的项目中禁用vue-cli

preLoaders: [
  {
    test: /\.vue$/,
    loader: 'eslint',
    include: projectRoot,
    exclude: /node_modules/
  },
  {
    test: /\.js$/,
    loader: 'eslint',
    include: projectRoot,
    exclude: /node_modules/
  }
]

如果我删除loader: 'eslint'行,它将无法编译,同样将其设置为空字符串。我知道我可以在初始化阶段退出ESLint,但是如何在创建项目后禁用它?

javascript webpack vue.js vue-cli
9个回答
12
投票

Vue的初学者项目本身就是用模板语言构建的。

看看the templates{{#lint}}位)看来你可以删除整个preLoaders块。


22
投票

从当前版本(^ 3.0?)开始,您可以设置:

useEslint:false,

在config / index.js中


15
投票

As of 2019, March :

vue.config.js

module.exports = {
  ...
  lintOnSave: false
  ...
}

祝好运...


2
投票

在最新版本中,打开“.eslintrc.js”文件,并设置“root:false”.enter image description here


2
投票

这里有一些过时的答案。

因为vue-cli 3使用的是零配置方法,所以禁用它的方法就是卸载模块:

npm remove @vue/cli-plugin-eslint

1
投票

这里有很多解决方案:https://github.com/vuejs-templates/webpack/issues/73

然而最好的是: 要添加一行**/*到.eslintignore,它将忽略所有文件。然后重新运行,如果它是一个Web应用程序!


1
投票

useEslint: false,设置config/index.js

see this image


1
投票

转到文件“tslint.json”并排除linterOptions中的所有文件。默认设置仅排除文件夹node_modules。您也可以在tsconfig.json中设置“strict”:false

  "linterOptions": {
    "exclude": [
      "*/**"
    ]
  },

代替

  "linterOptions": {
    "exclude": [
      "node_modules/**"
    ]
  },

0
投票

最简单的方法之一就是设置一个.eslintignore文件,你想要禁用文件夹和文件。

演示

/build/
/config/
/dist/
/*.js
/test/unit/coverage/

/000-xyz/

参考:https://github.com/vuejs-templates/webpack/issues/73#issuecomment-355149342

© www.soinside.com 2019 - 2024. All rights reserved.