Squashed 'docs/standards/playbook/' changes from 8b75747..c3f8137
c3f8137 📦 deps(skills): sync superpowers 35e827d 📦 deps(skills): sync superpowers e546ffb 📦 deps(skills): sync superpowers f7f2c57 🔧 chore(ci): use ci-bot identity for superpowers sync commits fa247a7 📦 deps(skills): sync superpowers a97c333 🔧 chore(ci): add resilient upstream fetch fallback for superpowers update 484f9d3 🔧 chore(ci): automate thirdparty superpowers refresh and sync base c19e53e 📝 docs(playbook): refresh guidance and examples 52046b4 📝 docs(prompts): add code-review template and align docs flow 9ac8a4c 📝 docs(typescript): clarify ts and js support boundaries 1f46203 ✨ feat(typescript): add standards docs and sync rewrite coverage 872c1af 🔧 feat(skills): install to agents home git-subtree-dir: docs/standards/playbook git-subtree-split: c3f81371e24d63b603de9b6eb92bf7e4c453a2b4
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# TypeScript 命名规范
|
||||
|
||||
## 文件与目录
|
||||
|
||||
- 文件名:`kebab-case.ts` / `kebab-case.tsx` / `kebab-case.js` / `kebab-case.jsx`
|
||||
- 脚本/配置文件:`kebab-case.mjs` / `kebab-case.cjs`
|
||||
- 测试文件:`kebab-case.test.ts` / `kebab-case.spec.ts` / `kebab-case.test.js` / `kebab-case.spec.js`
|
||||
- 类型声明文件:`kebab-case.d.ts`
|
||||
- 目录名:`kebab-case/`
|
||||
|
||||
## 标识符
|
||||
|
||||
| 类别 | 风格 | 示例 |
|
||||
| ----------------- | -------------------------- | ------------------------------ |
|
||||
| 类(Class) | `PascalCase` | `UserService` |
|
||||
| 接口(Interface) | `PascalCase` | `UserProfile`(不加 `I` 前缀) |
|
||||
| 类型别名(Type) | `PascalCase` | `ApiResponse<T>` |
|
||||
| 枚举(Enum) | `PascalCase` | `HttpStatus` |
|
||||
| 枚举成员 | `UPPER_WITH_UNDER` | `NOT_FOUND` |
|
||||
| 函数/方法 | `camelCase` | `getUserById` |
|
||||
| 变量/参数 | `camelCase` | `userId` |
|
||||
| 常量(模块级) | `UPPER_WITH_UNDER` | `MAX_RETRY_COUNT` |
|
||||
| 私有成员 | `_camelCase` | `_cache` |
|
||||
| 泛型参数 | 单字母或 `T` 前缀 | `T`、`TItem`、`K`、`V` |
|
||||
| React 组件 | `PascalCase` | `UserCard` |
|
||||
| React Hook | `camelCase`,以 `use` 开头 | `useUserData` |
|
||||
|
||||
## 布尔值命名
|
||||
|
||||
布尔变量/属性以 `is`、`has`、`can`、`should` 开头:
|
||||
|
||||
```ts
|
||||
const isLoading = true
|
||||
const hasPermission = false
|
||||
```
|
||||
|
||||
## 避免
|
||||
|
||||
- 单字母变量(循环索引 `i`/`j` 除外)
|
||||
- 缩写(`usr`、`btn`);优先完整单词
|
||||
- 匈牙利命名法(`strName`、`nCount`)
|
||||
- 接口名加 `I` 前缀(`IUserService`)
|
||||
Reference in New Issue
Block a user