前端-规范-elint代码格式化
eslint配置文件
// .eslintignore文件
// 不检测iconfont.js文件
**/iconfont.js
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
常见命令
- 自动格式化修复src文件夹下文件:
eslint --fix src
- 自动检测并罗列不符合的格式:
eslint src
- 检测指定文件夹下的.js和.vue文件:
eslint --ext .js,.vue src
- 根据配置文件检测指定类型文件:
eslint --config .eslintrc.js --ext .js,.vue src
设置代码跳过eslint检测
- 不检测当行:
// eslint-disable-line
- 不检测下一行:
// eslint-disable-next-line
- 整个文件不检测:头部放
/* eslint-disable */
跳过多行:
/* eslint-disable */ function a() { return this; } /* eslint-enable */
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。