markdowneditor

Coding Standards: [project]

Style/conventions doc – rules with reasons

软件与工程标准codingstandards

使用方法: When the same PR comments repeat. Rules need reasons; automate what's lintable and delete the rest.

预览

Coding Standards: [project]

The conventions reviewers enforce. Write the rule once here instead of a hundred times in PR comments.

FieldValue
Applies to[repo / language]
Owner@name
Last reviewYYYY-MM-DD
StatusActive

Principles

  1. [e.g. Clarity beats cleverness]
  2. [e.g. Match the codebase's existing style before this document]
  3. [e.g. A rule that cannot be linted needs a reason in review]

Formatting (automated)

RuleToolConfig
Formatting[prettier / ruff / gofmt][config file]
Linting[eslint / clippy][config file]
Type checking[tsc / mypy]strict

Run everything: [command]. CI enforces it; do not rely on memory.

Naming

ThingConventionExample
Fileskebab-caseuser-service.ts
Types / classesPascalCaseUserService
FunctionscamelCase verb phrasefetchUser
ConstantsSCREAMINGMAX_RETRIES

Code structure

  • Functions: [one level of abstraction / max N lines]
  • Modules: [allowed dependency direction]
  • Errors: [throw vs Result type; never swallow silently]
  • Comments: [explain why, not what]

Testing

  • New code ships with tests; coverage floor: [N%]
  • Test names describe behavior: returns 404 when user is missing
  • Flaky tests get fixed or deleted – never muted

Reviews

  • Max PR size: [~N lines; one concern per PR]
  • All checks green before requesting review
  • Prefix comments: blocking vs nit:

Prohibited

  • [e.g. no unchecked casts / no new deps without an ADR / no stray logs]

Exceptions

Breaking a rule is allowed when the reason is documented inline. Silent rule-breaking is not.

相关模板