chore(tooling): 对齐协作规范与浏览器验收工具
验证:713 项单测、8 视口环境、代码及格式检查通过;未运行生产构建。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 统一开发与 Ant Design CRUD 规范
|
||||
|
||||
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-11 · 版本:v2.1
|
||||
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-17 · 版本:v2.2
|
||||
|
||||
新增与重构 CRUD 的编码规范:目录与命名、组件选择、请求、React 组件与状态、表单与弹层、权限、i18n,以及可直接复制的页面模板。外观取值见 `UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
@@ -290,6 +290,8 @@ pagination={{
|
||||
|
||||
## 12. 代码风格与提交前检查
|
||||
|
||||
### 12.1 检查与构建
|
||||
|
||||
- Prettier:`singleQuote`、`jsxSingleQuote`,换行 LF;规范类文档使用紧凑表格(`.prettierrc.mjs` 的 overrides)。
|
||||
- ESLint:许可证头、`no-undef`、未使用 import 报错、Hooks 规则、禁用 UI 库导入,`--max-warnings=0`。
|
||||
|
||||
@@ -301,9 +303,45 @@ npm run check:ui # 改依赖、图标或 UI 库导入时
|
||||
git diff --check
|
||||
```
|
||||
|
||||
构建验证需用户同意,输出到临时目录且不覆盖 `dist/`(见 `AGENTS.md` 第 7 节)。
|
||||
构建验证需用户同意,输出到临时目录且不覆盖 `dist/`(见当前 Agent 入口第 7 节,无需加载另一入口)。
|
||||
|
||||
提交前自检:
|
||||
纯文档改动只需检查变更文件的 Prettier、`git diff --check` 与涉及的链接、命令、公共规则一致性;上述全量代码检查适用于代码变更。`npm run check` 不含 Prettier,且最后执行默认输出到 `dist/` 的构建,不直接用于临时目录验收。
|
||||
|
||||
### 12.2 提交与暂存
|
||||
|
||||
- 只在用户要求时 commit / push;提交前检查 `git status --short`、`git diff` 与 `git diff --cached`,只暂存当前任务文件,不使用 `git add .` 混入其他修改。
|
||||
- 新提交使用 `type(scope): 中文说明`,scope 可省略;type 选 `feat`、`fix`、`docs`、`refactor`、`test`、`chore`、`perf`、`build`、`ci`、`revert`,例如 `docs(agent): 对齐公共规范与工具差异`。这是协作约定,`package.json` 未配置 commitlint;不假定本机另有 Git hook 强制校验。
|
||||
- 提交说明写变更原因与实际验证结果;不写未完成的验证。默认不 amend、不强推、不重置工作区,提交后核对提交内容与剩余改动。
|
||||
|
||||
### 12.3 Windows 执行约定
|
||||
|
||||
- 每条 PowerShell 命令开头显式设置 `[Console]::OutputEncoding=[Text.Encoding]::UTF8; $OutputEncoding=[Text.Encoding]::UTF8;`,包括 `-NoProfile` 子进程;读取 UTF-8 文件用 `Get-Content -Encoding UTF8`。通过 Bash 调用 PowerShell 同样处理;cmd 命令先运行 `chcp 65001 >nul`。Python 使用 `python -X utf8`,隔离模式使用 `python -I -X utf8`。
|
||||
- PowerShell 若拦截 `npm.ps1` / `npx.ps1`,改用 `npm.cmd` / `npx.cmd`;不修改执行策略或 Windows 安全设置,不自动确认或抑制脚本安全警告。
|
||||
- Windows PowerShell 5.1 的每个 `Invoke-WebRequest`(含别名)必须显式包含 `-UseBasicParsing -TimeoutSec 30`;优先使用完整命令名。原生 curl 仅用 `curl.exe --connect-timeout 10 --max-time 30`。执行已有下载脚本前检查调用,补齐参数;依赖旧 HTML DOM 的调用方应先迁移到合适的解析器,不擅自删除 DOM 依赖。不为验证下载而运行下载脚本,检查状态、内容或预期哈希。
|
||||
- CPU / 内存用 `Get-CimInstance Win32_Processor` / `Win32_OperatingSystem`,避免依赖本地化名称的 `Get-Counter`;提交内存不足或无法确认资源门槛时不启动重型任务。任务结束只清理本任务启动的进程,保留已运行服务和他人进程。
|
||||
- 调用 `reg.exe`、`netsh` 等原生程序前同样设置 UTF-8;使用 PowerShell 的 `&` 调用,不用 `cmd /c` 嵌套引号。内联 Node 脚本含引号时优先用 here-string 管道传入 `node`,避免 PowerShell 5.1 参数转义丢失。
|
||||
|
||||
### 12.4 Agent 入口一致性校验
|
||||
|
||||
PowerShell 校验成功输出 `公共规则一致`;不一致或缺少章节边界时退出码为 1:
|
||||
|
||||
```powershell
|
||||
[Console]::OutputEncoding=[Text.Encoding]::UTF8; $OutputEncoding=[Text.Encoding]::UTF8;
|
||||
@'
|
||||
const fs = require('node:fs');
|
||||
const common = (p) => {
|
||||
const s = fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n');
|
||||
const a = s.indexOf('\n## 0.');
|
||||
const b = s.indexOf('\n## 10.');
|
||||
if (a < 0 || b <= a) throw Error(p + ': missing section boundary');
|
||||
return s.slice(a, b);
|
||||
};
|
||||
if (common('AGENTS.md') !== common('CLAUDE.md')) throw Error('Common rules differ');
|
||||
console.log('公共规则一致');
|
||||
'@ | node
|
||||
```
|
||||
|
||||
### 12.5 提交前自检
|
||||
|
||||
- [ ] 改动的流程可只用键盘完成,焦点始终可见,纯图标按钮有 `aria-label`。
|
||||
- [ ] 新的异步界面同时实现了加载、空数据、失败三种状态。
|
||||
|
||||
Reference in New Issue
Block a user