Files
bigwo/dev-assistant-mcp/dist/resources/codingStandards.js
2026-03-12 12:47:56 +08:00

35 lines
1.3 KiB
JavaScript
Raw Permalink 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.

export const codingStandardsResource = {
uri: "devassistant://resources/coding-standards",
name: "编码规范",
description: "各主流语言的编码最佳实践和规范",
mimeType: "text/markdown",
};
export function getCodingStandards() {
return `# 编码规范速查
## TypeScript / JavaScript
- 使用 \`const\` 优先,\`let\` 次之,禁用 \`var\`
- 函数和变量使用 camelCase类和接口使用 PascalCase
- 优先使用 \`async/await\` 而非回调和 \`.then()\`
- 使用严格类型,避免 \`any\`
- 错误处理:始终 catch 异步操作的异常
- 单个函数不超过 50 行,单个文件不超过 300 行
## Python
- 遵循 PEP 8 规范
- 函数和变量使用 snake_case类使用 PascalCase
- 使用 type hints 标注参数和返回值
- 使用 f-string 格式化字符串
- 使用 \`with\` 语句管理资源
- 使用 \`pathlib\` 替代 \`os.path\`
## 通用原则
- **DRY** — Don't Repeat Yourself消除重复代码
- **KISS** — Keep It Simple, Stupid保持简单
- **单一职责** — 每个函数/类只做一件事
- **提前返回** — 用 guard clause 减少嵌套
- **有意义的命名** — 变量名应表达意图,不用缩写
- **最小暴露** — 只暴露必要的公开接口
`;
}
//# sourceMappingURL=codingStandards.js.map