32 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Coding-Style-Guide
统一的代码规范仓库,旨在保障各语言项目代码的可读性、易维护性和编码安全性。
## 规范目录
| 语言 | 文档 | 参考基础 |
| --- | --- | --- |
| Golang | [go/hello_go.md](./go/hello_go.md) | [Google Golang 代码规范](https://github.com/golang/go/wiki/CodeReviewComments) |
| JavaScript | [javascript/hello_javascript.md](./javascript/hello_javascript.md) | [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) |
| Python | [python/hello_python.md](./python/hello_python.md) | [PEP 8](https://www.python.org/dev/peps/pep-0008/) |
## 规范等级
各语言规范中的每一条规则均标注了要求等级,含义一致:
- **必须(Mandatory)**:必须采用,代码扫描工具将其视为错误;
- **推荐(Preferable)**:理应采用,特殊情况可以不采用,不计为错误;
- **可选(Optional)**:仅供参考,自行决定是否采用。
## 配套工具
- **Go**:`gofmt` / `goimports` / `go vet` / `golint`
- **JavaScript**:ESLint(规则包 + CI 增量/全量检查),可与 Prettier 配合
- **Python**:`flake8` / `pylint` / `black` / EditorConfig
## 使用建议
1. 新项目启动时,按所用语言选取对应规范作为团队约定基线;
2. 将规范接入代码扫描 / CI 流程,`必须` 级别规则以工具强制落地;
3. 未尽事宜以文件内已有风格、项目风格为准,保持一致性优先。