代码检查工具
在vscode中安装ESLint和Stylelint,可以在保存代码时自动检查代码和格式化代码。
- eslint和stylelint的配置中所需的插件已经集成在脚手架中, 无需单独配置
- eslint和stylelint的vscode配置,已经保存在.vscode/settings.json中,无需单独配置
一、ESLint:JavaScript编码规范(含React)
1、使用eslint约束JavaScript的编写,集成以下插件规则:
- react/recommended:React规则
- react-hooks/recommended:React hooks规则
- standard:代码质量检查
- prettier/recommended:代码格式检查
2、以下规则和最佳实践,供参考:
- Google JavaScript Style Guide:https://google.github.io/styleguide/jsguide.html
- Airbnb JavaScript Style Guide:https://github.com/airbnb/javascript
- Airbnb React/JSX Style Guide:https://github.com/airbnb/javascript/tree/master/react
二、Stylelint:CSS编码规范
1、使用stylelint约束css的编写,集成以下插件规则:
- stylelint-config-standard:包含各种style编写规则
- stylelint-config-rational-order:约束css属性编写顺序
2、以下规则和最佳实践,供参考:
Airbnb CSS / Sass Styleguide:https://github.com/airbnb/css