Vue项目禁用eslint

问题

代码不符合eslint规范时的终端报错:

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR in [eslint]
....(略)

方法

针对整个项目

在vue.config.js中添加:lintOnSave:false

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({ 
  lintOnSave:false
})

针对整个文件

对某个文件禁用eslint检查。

在script标签内任意位置添加一次注释:

/* eslint-disable */

针对某一行

可以对某一行禁用eslint。

方法1:在其上面一行添加注释:

//eslint-disable-next-line
let a= 0;//a并没有使用并且不想让其报错

方法2:在某一行末尾添加注释

let a = 0;// eslint-disable-line

参考,以及其他方法

https://worktile.com/kb/p/3654076
https://blog.csdn.net/qq_43687594/article/details/140420551

你可能感兴趣的:(前端,vue.js,eslint)