Files
as-partner-frontend/.cursor/rules/camelcase-identifiers.mdc
2026-07-26 12:54:46 +08:00

28 lines
1.4 KiB
Plaintext
Executable File
Raw 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.

---
description: 使用 AI 编写/修改代码时,标识符命名统一为小驼峰(camelCase)。
alwaysApply: true
---
在本仓库中由 AI 生成或修改的代码须遵守以下命名约定:
## 小驼峰(camelCase)— 必须使用
- **变量**(`let` / `const` / `ref` / `reactive` 字段等)
- **函数**、**方法**
- **普通对象属性**(TypeScript 接口/类型中的字段名、请求体与前端模型字段,优先 camelCase)
- **函数参数**与**回调形参**
禁止使用蛇形命名(`snake_case`)作为上述标识符,除非下文「例外」另有说明。
## 命名例外(不按小驼峰)
- **类型 / 接口 / 枚举名**:使用 PascalCase(如 `OrgInfo`、`UserStatus`)。
- **Vue 单文件组件文件名**:PascalCase(如 `OrgAddOrUpdate.vue`)。
- **常量**:若项目已有约定,可使用全大写下划线(如 `MAX_RETRY`);新建常量优先与现有文件保持一致。
- **与外部协议强绑定且无法改名的字段**:仅在访问边界做映射,内部仍用 camelCase 变量承接(例如 `const userId = raw.user_id` 再避免把 `user_id` 传满业务层)。
## AI 行为要求
- 新增代码默认全部小驼峰;不要为「对齐后端蛇形」而在业务层引入蛇形变量名。
- 与现有文件风格冲突时,以**当前文件**已有风格为准,但新增标识符仍优先 camelCase。