Browse Source

📝 docs(coding): add coding standards documentation

- 创建编码规范文档,包含命名约定、文件结构、导入导出规则等9个主要部分
- 定义了不同代码元素的命名规范,如kebab-case文件名、PascalCase类名等
- 提供了错误处理、日志记录和测试相关的编码指南

🔧 chore(config): add .gitignore file

- 创建.gitignore文件,添加bmad-minimal到忽略列表
yourname 2 tháng trước cách đây
mục cha
commit
67f344e829
2 tập tin đã thay đổi với 72 bổ sung0 xóa
  1. 1 0
      .gitignore
  2. 71 0
      docs/coding-standards.md

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+bmad-minimal

+ 71 - 0
docs/coding-standards.md

@@ -0,0 +1,71 @@
+# Coding Preferences
+
+Use this document to capture coding conventions only. Do not duplicate technology choices or platform constraints — those live in the Architecture documents.
+
+## 1) Naming Conventions
+
+| Element           | Convention       | Example              |
+| ----------------- | ---------------- | -------------------- |
+| Files             | kebab-case       | user-profile.service |
+| Classes/Types     | PascalCase       | UserProfile          |
+| Functions/Methods | camelCase        | getUserProfile       |
+| Constants         | UPPER_SNAKE_CASE | MAX_RETRY_ATTEMPTS   |
+| Env vars          | UPPER_SNAKE_CASE | API_BASE_URL         |
+
+## 2) Files & Directories
+
+-  Source roots and common module folders (e.g., `src/components`, `src/services`):
+-  Public vs internal modules (what is exported from where):
+-  Path aliases/barrels (e.g., `@app/*`) and when to use them:
+
+## 3) Imports & Exports
+
+-  Prefer named vs default exports (policy):
+-  Import ordering (builtin → external → internal):
+-  Relative vs absolute imports (policy and thresholds):
+
+## 4) Error Handling
+
+-  Approved patterns (exception vs result-type) and when:
+-  Standard error shapes/codes (reference arch doc if defined):
+-  Retry/timeout/circuit-breaker usage (reference arch doc if defined):
+
+## 5) Logging
+
+-  Logger usage (avoid `console.log`):
+-  Log levels and guidance (info/warn/error only where meaningful):
+-  Structured fields to include (e.g., requestId, userId) and redaction rules:
+
+## 6) Testing Conventions
+
+-  Test file naming/location (e.g., `*.spec.ts` next to source):
+-  Minimum coverage target (%):
+-  Mocking/stubbing guidance (what to mock and where):
+
+## 7) Security & Privacy
+
+-  Secrets: never commit; use env/config only (reference secret manager in arch doc):
+-  PII: do not log/store unnecessarily; redact in logs:
+-  Input validation: apply at trust boundaries (reference arch doc schemas):
+
+## 8) Git & PR Process
+
+-  Commit convention (e.g., Conventional Commits):
+-  Branch naming scheme:
+-  Required CI checks for merge:
+-  PR checklist location (copy or link):
+
+## 9) Code Review Checklist (paste into PR template if helpful)
+
+-  [ ] Code follows naming and directory conventions
+-  [ ] Public API surface is minimal and documented where needed
+-  [ ] Errors use approved patterns; user-facing messages are appropriate
+-  [ ] Logging is structured and redacted; no secrets/PII
+-  [ ] Input validation at boundaries where required
+-  [ ] Tests cover happy-path and edge cases; coverage target met
+-  [ ] No unnecessary dependencies or duplication
+-  [ ] Changes align with architecture decisions (link to section if relevant)
+
+-  Primary language(s):
+-  Runtime(s)/VM(s) and versions:
+-  Target platforms (OS/CPU/Accel):