eslint验证
eslint验证
【eslint验证】使用:yarn lint或npm run lint
eslint自动修复
yarn lint --fix
格式
rules: {
"规则名": [规则值, 规则配置]
}
规则值
"off"或者0//关闭规则
"warn"或者1//在打开的规则作为警告(不影响退出代码)
"error"或者2//把规则作为一个错误(退出代码触发时为1)
.eslinrc.js
官方参考
module.exports = {
root: true,
env: {
node: true,
es6: true, // 额外支持新的 ES6 全局变量
browser: true // 在代码中可以放心使用宿主环境给你提供的全局变量
},
'extends': [
'plugin:vue/essential',
'@vue/standard'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 自定义
'indent': ['error', 4],
'space-infix-ops': 'error', // 要求操作符周围有空格
'comma-spacing': 'error', // 逗号后面加空格
'arrow-spacing': 'error', // 使用 => 前后空格
'spaced-comment': 'warn', // 注释风格,前后留一个空格
'no-irregular-whitespace': 'error', // 不能有不规则的空格
'no-mixed-spaces-and-tabs': 'error', // 不能混用空格和tab
'no-multiple-empty-lines': 'error', // 不能有多余的空行
'no-var': 'error', // 不能使用var
'no-new': 'off',
'new-cap': 'off', // 不要求构造函数首字母大写
'eqeqeq': 'error', // 使用全等
'quotes': [1, 'single'], // 引号类型,使用单引号
'camelcase': 'off'
},
parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 6, // 启用 ES6 语法支持
sourceType: 'module'
},
globals: { // 声明在代码中自定义的全局变量
$jsBridge: true
}
}
.eslintignore
/build/
/config/
/dist/
推荐阅读
- 整理大部分Eslint规则
- Pytorch学习|sklearn-SVM 模型保存、交叉验证与网格搜索
- 人工智能|【机器学习】深度盘点(详细介绍 Python 中的 7 种交叉验证方法!)
- 解决|解决 win 10 远程桌面身份验证错误问题
- macOS系统上,安装包安装权限不足或验证不过问题
- IC|数字IC后端真的不如前端设计和验证吗()
- RF接口返回数据验证举例
- Python【习题】(随机生成激活码、优惠码、验证码)
- 这样能活(那就用一生去验证它!)
- 331.|331. 验证二叉树的前序序列化