如何在 vue-cli 中禁用 ESLint?

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

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

如果我删除 loader: 'eslint'行,它将不会编译,这与将其设置为空字符串是一样的。我知道在初始化阶段我可以选择不使用 ESLint,但是在我的项目创建之后我怎样才能禁用它呢?

173330 次浏览

Vue 的启动项目本身就是使用模板语言构建的。

看看 模板(\{\{#lint}}位) ,似乎你可以删除整个 preLoaders块。

在当前版本(^ 3.0?)中,只需设置:

useEslint: false,

config/index.js

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

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

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

config/index.js中的 useEslint: false,

看这个图像

这里有一些过时的答案。

Because vue-cli 3 is using a zero configuration approach, the way to disable it is to just uninstall the module:

npm remove @vue/cli-plugin-eslint

进入文件“ tslint.json”并排除 linterOptions 中的所有文件。默认设置仅排除文件夹 node _ module。您还可以在 tsconfig.json 中设置“ strong”: false

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

而不是

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

2019, March开始:

vue.config.js:

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

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

小样

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


/000-xyz/


档号: https://github.com/vuejs-templates/webpack/issues/73#issuecomment-355149342

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,
...
},
}

转到 .eslintrc.js并添加以下内容:

dev: {
useEslint: false
},

package.json中更改构建步骤:

...
"scripts": {
"build": "vue-cli-service build --skip-plugins @vue/cli-plugin-eslint",
...
},

对于 vue3用户,只需在 eslintrc.js 文件中注释掉 parserOptions。这对我很有用,因为有时候起绒会让人沮丧

module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended'
],
// parserOptions: {
//   parser: 'babel-eslint'
// },
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}

在 vueCli 中,转到包 json 将 eslint 从最后的依赖关系中移除,您的包 json 必须如下所示

{
"name": "vuecompesation",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"


},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0"
  

},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

首先,您需要创建一个文件名为

Vue.config.js

然后写下风箱线

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

这个过程对我很有效,谢谢

这个应该可以

Vue.config.js中加上这个

module.exports = {
lintOnSave: false
}

对于 Vue cli v4和使用 eslint 特性创建的项目,package.json 中有一个 eslintConfig属性:

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

extends 指定一些规则预设置,默认值为 plugin:vue/vue3-essentialeslint:recommended。像未使用的变量或未使用的导入这样的常见规则在 eslint:recommended中。如果你想禁用这样的规则,只需删除 eslintConfig中的 eslint:recommended并重新启动项目,但不要删除 plugin:vue/vue3-essential,否则 linter 将无法识别 .vue文件。

使用以下命令轻松地卸载

npm remove @vue/cli-plugin-eslint
yarn remove @vue/cli-plugin-eslint

.eslintignore中,添加

/*/

林特不会再抱怨了

我个人为了克服这个问题,创建了一个新的项目,并从设置中手动发出 Linter/Formatter 选项

我不解决问题,我只是尽量避免它。 Hope this helps someone

您可以使用以下命令删除它

npm remove @vue/cli-plugin-eslint

或者在特定文件的 script 标记中使用下面的命令禁用它

/* eslint-disable */

要为 一句台词禁用 Eslint,可以在要禁用 Eslint check 的行上方放置一条注释。

// eslint-disable-next-line

要禁用 整个档案的 Eslint,可以在文件顶部写下注释。

/* eslint-disable */

要禁用 一个特定的文件或文件夹的 Eslint,可以将其包含到 .eslintignore中。

。 eslintignore

/src/components

同样的方式,如果你想禁用在 整个项目的伊斯林特只是设置下面的路径。

.eslintignore

**/*

要禁用一些 具体规则检查,你可以在 .eslintrc.js中“关闭”它。

. eslintrc.js

module.exports = {
rules: {
"no-console": "off",
},
}

使用 console.log 时,no-console规则将禁用警告,您可以在 埃斯林特Vue Esint 插件文档中找到所有可用的规则。