eslint-config-fx
v0.1.5
Published
Fx ESLint 规则集
Downloads
7
Readme
Fx ESLint Config
状态
| 完成版本 | 规则集 | 文档级别 | |---------|----------------------------------|------------| | v0.1.0 | 标准 JavaScript 项目规则集 | af16ebcfbb |
使用方法
- 安装 ESLint 依赖及规则集
eslint-config-fx
npm install --save-dev eslint babel-eslint eslint-config-fx
- 创建
.eslintrc.js
或将已有规则集指明为fx
module.exports = {
...
extends: [
'fx', // 指明规则集
]
...
};
使用 ESLint 提高代码质量
本套 ESLint Config 在遵循 ESLint 设计哲学 的原则上,考虑如下几点:
- 显式包含全部规则:显式声明全部规则,使得在使用中不必考虑默认值问题
- 善用 autofix 解决风格冲突:可以充分利用自动修复功能,调配项目成员间的不一致,因此包含尽量多的风格规则
- 配置应当合理:考虑前端多项目、架构交互情况,酌情去除不适合的规则(如强制使用 camelCase 等)
ESLint 哲学
https://eslint.org/docs/about/#philosophy
一切都是可插拔的
- 规则 API 均可被成型的或自定义的规则集使用
- 格式化工具 API 均可被成型的或自定义的格式化工具集使用
- 额外的规则或格式化工具可以被在运行时添加
- 规则或格式化工具都不必须被绑定在一起使用
每条规则
- 均是独立的
- 可以被打开或关闭的 (没有什么规则可以被看作"太重要以致于不能被关闭")
- 可以被单独设定为警告或错误两种级别
另外
- 规则是风格中立的 - ESLint 不特别提升任何一种编程风格
- 所有规则集都是通用的
这个项目
- 赋予文档价值并降低沟通成本
- 尽可能的透明
- 相信测试的重要性