Eslint
忽略html(例如vue中的template的标签闭合警告)
例如使用Element-ui的标签
// 下面的使用方法会出现警告 warning: Require self-closing on Vue.js custom components
// 要你改写成<el-table-column type="selection" width="55" />
<el-table-column type="selection" width="55"></el-table-column>
在.eslintrc.js中新增配置
"vue/html-self-closing": ["error",{
"html": {
"void": "never",
"normal": "any",
"component": "any"
},
"svg": "always",
"math": "always"
}]
使用/* eslint-disable*/进行独立设置
取消整个文件的检查
// 直接写上
/* eslint-disable */
对单独代码片段进行忽略设置
/* eslint-disable */
// 或略此区间内的代码审查
console.log('代码片段')
/* eslint-enable */
临时在一段代码中取消个别规则的检查(如no-alert, no-console)
// 取消检查alert和console(多种限制逗号隔开)
/* eslint-disable no-alert, no-console */
console.log('代码片段')
/* eslint-enable no-alert, no-console */
针对某一行禁用eslint检查
alert(‘aaaa’); // eslint-disable-line
// eslint-disable-next-line
alert(‘aaaa’);
针对某一行的某一具体规则禁用eslint检查
alert(‘aaaa’); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert(‘aaaa’);
针对某一行禁用多项具体规则的检查
alert(‘aaaa’); // eslint-disable-line no-alert, quotes
// eslint-disable-next-line no-alert, quotes
alert(‘aaaa’);