fix: 更新代码注释规范,强调注释应解释逻辑和设计意图,禁止描述代码状态或历史

This commit is contained in:
严浩
2025-04-01 18:00:18 +08:00
parent 21660cd9fa
commit 13681003fb

View File

@ -15,6 +15,7 @@ This document outlines the core technical choices, coding conventions, and confi
* All comments within the codebase **must be written in Chinese**. (代码中的所有注释**必须使用中文**。)
* **注释应解释代码的“为什么”(设计意图、选择某方案的原因)或复杂逻辑/算法的“如何”,而不是解释“是什么”(重复代码功能)或“在哪里”(描述定义位置)。**
* **严禁添加仅说明代码被移动、重构或提取到其他文件的注释。** 例如,避免 `// XxxState 接口已移至 types.ts``// 提取为 useXYZ composable` 这样的注释。依赖代码结构、类型系统和 IDE 功能(如 Go To Definition来理解这些信息而不是通过注释。Focus comments on the *logic* itself, not its location or history.
* **同样地,严禁添加描述代码是“新增”、“修改”、“临时”或标记其开发状态的注释。** 例如,避免 `// 新增功能``// (新增)``// 临时修复``// TODO: 优化`(除非 TODO 指向具体的技术债务或未完成的逻辑,而不仅仅是标记状态)等注释。注释的目标是解释代码的内在逻辑或设计决策,而不是其变更历史或当前状态。
## 📦 UI Libraries & Components
@ -44,9 +45,9 @@ This document outlines the core technical choices, coding conventions, and confi
* **Always** use `<script setup lang="ts">`.
* Composition API is the **only** accepted style.
* Code comments **must be in Chinese** and explain **why/how (logic, intent)**, **strictly avoiding** comments that explain **what (code repetition), where (definition location), refactoring history, or auto-import mechanisms.**
* Code comments **must be in Chinese** and explain **why/how (logic, intent)**, **strictly avoiding** comments that explain **what (code repetition), where (definition location), refactoring history, code status (e.g., 'new', 'modified'), or auto-import mechanisms.**
* Vue 3 Composition API, Pinia, Vue Router (auto), VueUse functions, `consola`, and exports from `src/stores` & `src/utils` are globally available via auto-import; **do not** import them explicitly.
* Ant Design Vue, PrimeVue, and local `src/components` components are auto-imported; use them directly in templates without explicit imports.
* **Crucially: Do not add comments solely to explain that an API or component is auto-imported OR where code has been moved/refactored.** Trust the auto-import setup and IDE navigation.
* **Crucially: Do not add comments solely to explain that an API or component is auto-imported OR where code has been moved/refactored OR the status of the code (e.g., 'new').** Trust the auto-import setup and IDE navigation. Focus on logic.
* Use custom SVG icons via the `<icon-name />` syntax.
* Maintain the specified SFC structure: `<script setup>`, `<template>`, `<style>`.
* Maintain the specified SFC structure: `<script setup>`, `<template>`, `<style>`.