update naming convention in AGENTS.md

This commit is contained in:
jtl959
2026-08-20 10:57:58 +08:00
parent b040abacae
commit 0042b52935
2 changed files with 8 additions and 81 deletions

View File

@@ -25,15 +25,15 @@
- 总是尽量采用有意义的完整单词,而不是 A, B, i, k 这样的单个字母。 - 总是尽量采用有意义的完整单词,而不是 A, B, i, k 这样的单个字母。
- 类名、模块名、仓库名、等等较大范围名称CamelCase, 例如 `Creation`, `CommonTools` - 类名、模块名、仓库名、等等较大范围名称CamelCase, 例如 `Creation`, `CommonTools`
- 属性名、变量名、等等较小范围名称camelCase, 例如 `weight`, `countRead`, `userPhoneVerified`, `commonTools = require('CommonTools')` - 属性名、变量名、等等较小范围名称camelCase, 例如 `weight`, `countRead`, `userPhoneVerified`, `commonTools = require('CommonTools')`
- 常量名UPPERCASE_SEPERATED_BY_UNDERSCORE例如 `ERROR_USER_OFFLINE` - 常量名UPPERCASE_SEPARATED_BY_UNDERSCORE例如 `ERROR_USER_OFFLINE`
- 方法、函数名:do_something(),即小写动词开头+下划线分隔,例如 `update_user_avatar()`。可以使用 camelCase 作为组成部分,例如 `get_userName()` 以和 变量名 `userName` 保持一致 - 方法、函数名:动词开头的 camelCase,例如 `updateUserAvatar()`, `getUserName()`
- HTML/CSS 的 class、id 名kebab-casedash 分隔),例如 `user-center`, `card-header`JS 中通过 CSS Modules 访问样式时仍用 camelCase`styles.userCenter`),两者由工具自动转换。
- 目录和文件名: - 目录和文件名:
- 首先,如果用来绑定某个名称的具体内容,目录或文件名应当跟随这个名称本身。例如,一个文件用来存放某个类,那就用类名作为文件名,例如 `Creation`; 一个目录用来存放某个仓库,那就用仓库名作为目录名,例如 `CommonTools/`; 一个目录用来服务一个域名,就用域名作为目录名,例如 `blog.tic.cc`; 一个文件用来记录某个日期,就用日期作为目录名,例如 `20260801` - 首先,我的主规则是用 camelCase 命名目录或文件,例如 `source`, `frontend`, `userCenter.vue`
- 其次,如果已有流行的规范或惯例,就遵循这种命名格式。例如,`AGENTS.md`, `.gitignore`, `blog` - 其次,如果用来绑定某个名称的具体内容,目录或文件名应当跟随这个名称本身。例如,一个文件用来存放某个类,那就用类名作为文件名,例如 `Creation`; 一个目录用来存放某个仓库,那就用仓库名作为目录名,例如 `CommonTools/`; 一个目录用来服务一个域名,就用域名作为目录名,例如 `blog.tic.cc`; 一个文件用来记录某个日期,就用日期作为文件名,例如 `20260801`
- 最后,如果上述规则都不适用,就遵循 camelCase 格式来命名目录或文件,例如 `source`, `frontend`, `userCenter.html` - 最后,当与流行的规范或惯例有强烈冲突时,遵循该流行惯例。例如`AGENTS.md`, `.gitignore`
- 上述规则是特意不使用 - 或 \_ 来分隔,因为 - 注意,目录、文件名仅大小写不同的(如 `userCenter``usercenter`)禁止在同一层级同时出现,以避免跨平台冲突,。
- abc-xyz 在编辑器中双击不会被识别成一整个名称,并且有时在命名了文件后,又发现需要把文件和某个名称绑定起来,而这个名称通常是不应该含有 `-` - 存量代码保持既有命名,不强制迁移;新增代码遵循本规范
- abc_xyz 虽然容易目视识别,但是大幅度增加了名称长度。
## 主动交互 ## 主动交互

View File

@@ -1,73 +0,0 @@
{
"name": "dcloud-renew",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dcloud-renew",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"dotenv": "^17.4.2",
"playwright": "^1.62.0"
}
},
"node_modules/dotenv": {
"version": "17.4.2",
"resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-17.4.2.tgz",
"integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/playwright": {
"version": "1.62.0",
"resolved": "https://registry.npmmirror.com/playwright/-/playwright-1.62.0.tgz",
"integrity": "sha512-Z14dG305dgaLu6foB1TXQagFiW8JfSUIUaUuPaKQ6NtBPKF1P/qXcqfh6c6K/icPqdy37JmjbiBXf6JNg6Sylw==",
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.62.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=20"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.62.0",
"resolved": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.62.0.tgz",
"integrity": "sha512-nsNRyq0r2zsG8AcRHWknc9QRA5XCueC7gWMrs+Gx2tlZn9hcl8zudfh00lhJPY1DE7NmZ6bDsT9g2yey8mXljA==",
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=20"
}
}
}
}