chore: add pre-commit code formatting

This commit is contained in:
YBF
2026-08-25 15:49:08 +08:00
parent 319f17e0eb
commit b77ed3cb66
7 changed files with 304 additions and 12 deletions
+1
View File
@@ -0,0 +1 @@
pnpm exec lint-staged
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": [".agents/**", ".codex/**", ".trellis/**", "AGENTS.md", "pnpm-lock.yaml"]
}
@@ -4,7 +4,8 @@
- 包管理器是 pnpm `11.7.0`Node.js 版本范围是 `>=22.22.2 <23`
- 共享 TypeScript 配置开启 `strict: true``forceConsistentCasingInFileNames: true`,模块目标是 `NodeNext`
- 根级脚本提供 `pnpm dev``pnpm build``pnpm typecheck``pnpm test`,并通过 `--if-present` 调用各包同名脚本。
- 根级脚本提供 `pnpm dev``pnpm build``pnpm typecheck``pnpm test``pnpm format``pnpm format:check`;业务命令通过 `--if-present` 调用各包同名脚本。
- 仓库统一使用 Oxfmtlint-staged 只格式化暂存文件,Husky 在 `pre-commit` 阶段触发该检查。
- 扩展包使用 Vite `6.x` 和 TypeScript `5.7.x``typecheck` 执行 `tsc -p tsconfig.json --noEmit``build` 先检查类型再执行 `vite build`;尚无 lint 和测试脚本。
- Vite 依赖的 `esbuild` 安装脚本在根 `pnpm-workspace.yaml``allowBuilds` 中显式允许。
@@ -25,6 +26,7 @@
## 验证命令
```bash
pnpm format:check
pnpm typecheck
pnpm build
pnpm test
@@ -4,7 +4,8 @@
- 使用 pnpm `11.7.0` 和 Node.js `>=22.22.2 <23`
- 根 [`tsconfig.base.json`](../../../../tsconfig.base.json) 开启严格类型检查,并使用 `NodeNext` 模块解析。
- 根级脚本提供 `pnpm dev``pnpm build``pnpm typecheck``pnpm test`通过 workspace filter 调用子包脚本。
- 根级脚本提供 `pnpm dev``pnpm build``pnpm typecheck``pnpm test``pnpm format``pnpm format:check`;业务命令通过 workspace filter 调用子包脚本。
- 仓库统一使用 Oxfmtlint-staged 只格式化暂存文件,Husky 在 `pre-commit` 阶段触发该检查。
- 服务端 `package.json` 当前没有声明这些脚本,也没有 lint 或测试框架;当前不能声称已有 API 测试或 lint 通过。
## 必须遵守
@@ -24,6 +25,7 @@
## 验证命令
```bash
pnpm format:check
pnpm typecheck
pnpm build
pnpm test
@@ -4,6 +4,7 @@
- 使用 pnpm `11.7.0`、Node.js `>=22.22.2 <23` 和根级严格 TypeScript 配置。
- 根级 `dev``build``typecheck``test` 命令只调用实际存在的子包脚本;服务端目前没有前端脚本。
- 根级 `format``format:check` 使用 Oxfmtlint-staged 只格式化暂存文件,Husky 在 `pre-commit` 阶段触发该检查。
- 当前没有 lint、组件测试、端到端测试或浏览器构建工具,不能把这些能力写成已经启用的检查项。
## 必须遵守
@@ -23,6 +24,7 @@
## 验证命令
```bash
pnpm format:check
pnpm typecheck
pnpm build
pnpm test
+17 -8
View File
@@ -1,22 +1,31 @@
{
"name": "trade-message-center",
"private": true,
"version": "0.1.0",
"type": "module",
"packageManager": "pnpm@11.7.0",
"private": true,
"workspaces": [
"apps/*"
],
"engines": {
"node": ">=22.22.2 <23"
},
"type": "module",
"scripts": {
"dev": "pnpm --parallel --filter @trade-message-center/server --filter @trade-message-center/chrome-extension --if-present run dev",
"build": "pnpm --filter @trade-message-center/server --filter @trade-message-center/chrome-extension --if-present run build",
"typecheck": "pnpm --filter @trade-message-center/server --filter @trade-message-center/chrome-extension --if-present run typecheck",
"test": "pnpm --filter @trade-message-center/server --filter @trade-message-center/chrome-extension --if-present run test"
"test": "pnpm --filter @trade-message-center/server --filter @trade-message-center/chrome-extension --if-present run test",
"format": "oxfmt",
"format:check": "oxfmt --check",
"prepare": "husky"
},
"devDependencies": {
"husky": "^9.1.7",
"lint-staged": "^17.3.0",
"oxfmt": "^0.64.0",
"typescript": "^5.7.3"
}
},
"lint-staged": {
"*": "oxfmt --no-error-on-unmatched-pattern"
},
"engines": {
"node": ">=22.22.2 <23"
},
"packageManager": "pnpm@11.7.0"
}
+274 -2
View File
@@ -8,6 +8,15 @@ importers:
.:
devDependencies:
husky:
specifier: ^9.1.7
version: 9.1.7
lint-staged:
specifier: ^17.3.0
version: 17.3.0
oxfmt:
specifier: ^0.64.0
version: 0.64.0
typescript:
specifier: ^5.7.3
version: 5.7.3
@@ -22,7 +31,7 @@ importers:
version: 5.7.3
vite:
specifier: ^6.0.7
version: 6.4.3(@types/node@22.20.1)
version: 6.4.3(@types/node@22.20.1)(yaml@2.9.0)
apps/server:
dependencies:
@@ -207,6 +216,128 @@ packages:
os: [linux]
libc: [glibc]
'@oxfmt/binding-android-arm-eabi@0.64.0':
resolution: {integrity: sha512-o6uzh/jTOQeAY5TdkAeXdqv7MBRcPxiRA08zrcBtkKj5cSu/FMu0Hl7Q6Fi1KCKyCWZ6lJVjBzdsJvsKltUsGQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
'@oxfmt/binding-android-arm64@0.64.0':
resolution: {integrity: sha512-jRGSUeeP7p3Gynw2YaCVtjBIA6ZxY6bEB/ES5i54OhqmRTyuVg7ZgstEtzgq6GOAJd+2QZ5pvf+bFfmW5Mp9cw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
'@oxfmt/binding-darwin-arm64@0.64.0':
resolution: {integrity: sha512-JINwtU2lW7nOFSqi+H2qplipNUqah9Gc1jgGmB82kTD4UnZrZIVxCJ9qEmFiKfjNq27gYLFhrUb0to86aCwMjw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
'@oxfmt/binding-darwin-x64@0.64.0':
resolution: {integrity: sha512-gCmuswrgrOSajV4HCRFkVCGIruPq8bjYuPYgSE2WQB3mD6XrdyZ3JMSRZCkQ8zCxOyGWriBo6QoZ5nmMHQ1BfA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
'@oxfmt/binding-freebsd-x64@0.64.0':
resolution: {integrity: sha512-Ab8g7a38pT0MMImjh7anRSTve6buWBIlcXIFBYa5xl4s6UxEgKSc2xOOhbGtLwvXnEi2PsEDGoJh3oUU7xkehQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
'@oxfmt/binding-linux-arm-gnueabihf@0.64.0':
resolution: {integrity: sha512-BgvS3CoQ+Xy2deoZqEN8JVKabcCZi2RxA3yant8G9OAv9KuPJ9TCjHkqigzdHUVwErZxEP5d2bzLIEyKYyBDLg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@oxfmt/binding-linux-arm-musleabihf@0.64.0':
resolution: {integrity: sha512-QXpNxwoMj0YvnceCNZadNSden3bIcnvjn/sDp/rwZhRoZoZYGpHvtPyhGsdJz9uvT9GkaMW7SsLddurU56dt8w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@oxfmt/binding-linux-arm64-gnu@0.64.0':
resolution: {integrity: sha512-BBgH3I1ppDsI5pZ4Pdhw0ceYxwVCfbU/bZEBCeZ6caRS9x0ZabErxubP7riGUn11PXZBhe8DYdjkDKP1FlVQ5w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-arm64-musl@0.64.0':
resolution: {integrity: sha512-v19HSjC/BGXdt26qEvKZtwAHgGmQ2Agcap2kQP+KIqoRZqivVzYth3ui2dJA1i+6/fjpjga85lIOaJJjQ/bOOw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [musl]
'@oxfmt/binding-linux-ppc64-gnu@0.64.0':
resolution: {integrity: sha512-PElLnOo4xFTBZrxPhgTIj0eHqZXwEBQoNWtb7facUV170T0B0FRET0iNbb3LUeLWTybkUW+vsdyv4ihOdyXGyw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-riscv64-gnu@0.64.0':
resolution: {integrity: sha512-Qzsg15n4F5CH+MorcRW4MkAEMiLzXmeG+DiDSbP/bBTqCmWOH3K9DHryNrve+JHlV0txS+B6Z9P5Xz+cmWeL+g==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-riscv64-musl@0.64.0':
resolution: {integrity: sha512-/GZ358wnQ/Ez4UVnCcZIi56JkY0sOdZ+B108pqXKqZz3jLS59F4KEAB1Qv3fRlObrFEk+3L2vUQ/xoPx+3vjXw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@oxfmt/binding-linux-s390x-gnu@0.64.0':
resolution: {integrity: sha512-/C9We3DXegowfLXtVCYHeNiU9azwCDr5cQkEtCVlc74vyn+lLQSPApJ1CZmxAduqeq/Oi3gQ+IVptyhCaTMtkQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-x64-gnu@0.64.0':
resolution: {integrity: sha512-91KM2CeRWscIEHlj1NsW2WSnzGeq1Ehq+39bfDowTdkn+fcvK/x4Y1RcyqT7glyBjZio0ldkeCG6Usj3v7ASog==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [glibc]
'@oxfmt/binding-linux-x64-musl@0.64.0':
resolution: {integrity: sha512-gw7uEk9I+7zoT1EYLra1eWArIzNcz8e3jkv+Noo2+o2T7wPvsNSQbfoa4DSfZlvn1i6mJ05RiZ4/omaXPDNhQg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [musl]
'@oxfmt/binding-openharmony-arm64@0.64.0':
resolution: {integrity: sha512-HYHFf616FHSPSO07c09mjmXBfQ73wIVM3m0txOiooa5XZkGoxFd6B14PVj0LB0DXIqJ6wAO/dDR/NX/5UUaqnw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
'@oxfmt/binding-win32-arm64-msvc@0.64.0':
resolution: {integrity: sha512-uQjFp081IZSWD6VAofX2iO2z01awAdHmfC+NrieWIPKrT2hZKQDyq/U18M7ifC0sm0Wz8aHY/p6+FDYIzs/CrQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
'@oxfmt/binding-win32-ia32-msvc@0.64.0':
resolution: {integrity: sha512-lNM6byTAQ881jugzFu8juJTbNRgsUTlswMA6pJmwi1XDvmIqnnb49lcUAs5gz94fCJLrVN+/X3s3jOKqx23WIQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ia32]
os: [win32]
'@oxfmt/binding-win32-x64-msvc@0.64.0':
resolution: {integrity: sha512-BtmbtL/QjMtF1a6C3CqoDluH2IfB6fJt62E+B9RFfUPtFk4Iz9PFS6+y/SzzOvSxc7aUk2Kphwg7Dh8lMbwu6g==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
'@pinojs/redact@0.4.0':
resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==}
@@ -430,6 +561,11 @@ packages:
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
husky@9.1.7:
resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==}
engines: {node: '>=18'}
hasBin: true
ipaddr.js@2.5.0:
resolution: {integrity: sha512-aq+t5NAc+cS6rZQQVWC2x98CPqGtKKTMDd4Gaodv0wShnItdKg/51djkGJ1hqH+Oy0ivDftCbSLCQob8zso01w==}
engines: {node: '>= 10'}
@@ -443,6 +579,11 @@ packages:
light-my-request@6.6.0:
resolution: {integrity: sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A==}
lint-staged@17.3.0:
resolution: {integrity: sha512-woZS3vNe3UKqBaLPvbLOtKRY4tLANpWQhom12MGWqC8Mh1lCOO+WgSwmX2amjJAqTY9BkXYW87fCUH5H9Ph6xw==}
engines: {node: '>=22.22.1'}
hasBin: true
nanoid@3.3.18:
resolution: {integrity: sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@@ -452,6 +593,19 @@ packages:
resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==}
engines: {node: '>=14.0.0'}
oxfmt@0.64.0:
resolution: {integrity: sha512-XZ4GFBN/PLbXKq+0zrgpQfPKYuJlUuj+nzZJY7UpIbFMNyefNLCdN9EwViycNqnYcv0wrn0jXcQLlqJp8RCKBg==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
svelte: ^5.0.0
vite-plus: '*'
peerDependenciesMeta:
svelte:
optional: true
vite-plus:
optional: true
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -539,14 +693,26 @@ packages:
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
engines: {node: '>= 10.x'}
string-argv@0.3.2:
resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==}
engines: {node: '>=0.6.19'}
thread-stream@4.2.0:
resolution: {integrity: sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==}
engines: {node: '>=20'}
tinyexec@1.3.0:
resolution: {integrity: sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==}
engines: {node: '>=18'}
tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
tinypool@2.1.0:
resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==}
engines: {node: ^20.0.0 || >=22.0.0}
toad-cache@3.7.4:
resolution: {integrity: sha512-m1TdR/rvT7kgGJZhspNtXdsdYk0fddFpJJFlG5s+UkPFo6lkLoZ3YLOaovPYjq1R75NP5JfeTlSHaOsE09peCg==}
engines: {node: '>=20'}
@@ -599,6 +765,11 @@ packages:
yaml:
optional: true
yaml@2.9.0:
resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==}
engines: {node: '>= 14.6'}
hasBin: true
snapshots:
'@esbuild/aix-ppc64@0.25.0':
@@ -702,6 +873,63 @@ snapshots:
'@napi-rs/lzma-linux-x64-gnu@1.5.1':
optional: true
'@oxfmt/binding-android-arm-eabi@0.64.0':
optional: true
'@oxfmt/binding-android-arm64@0.64.0':
optional: true
'@oxfmt/binding-darwin-arm64@0.64.0':
optional: true
'@oxfmt/binding-darwin-x64@0.64.0':
optional: true
'@oxfmt/binding-freebsd-x64@0.64.0':
optional: true
'@oxfmt/binding-linux-arm-gnueabihf@0.64.0':
optional: true
'@oxfmt/binding-linux-arm-musleabihf@0.64.0':
optional: true
'@oxfmt/binding-linux-arm64-gnu@0.64.0':
optional: true
'@oxfmt/binding-linux-arm64-musl@0.64.0':
optional: true
'@oxfmt/binding-linux-ppc64-gnu@0.64.0':
optional: true
'@oxfmt/binding-linux-riscv64-gnu@0.64.0':
optional: true
'@oxfmt/binding-linux-riscv64-musl@0.64.0':
optional: true
'@oxfmt/binding-linux-s390x-gnu@0.64.0':
optional: true
'@oxfmt/binding-linux-x64-gnu@0.64.0':
optional: true
'@oxfmt/binding-linux-x64-musl@0.64.0':
optional: true
'@oxfmt/binding-openharmony-arm64@0.64.0':
optional: true
'@oxfmt/binding-win32-arm64-msvc@0.64.0':
optional: true
'@oxfmt/binding-win32-ia32-msvc@0.64.0':
optional: true
'@oxfmt/binding-win32-x64-msvc@0.64.0':
optional: true
'@pinojs/redact@0.4.0': {}
'@rollup/rollup-android-arm-eabi@4.62.5':
@@ -893,6 +1121,8 @@ snapshots:
fsevents@2.3.3:
optional: true
husky@9.1.7: {}
ipaddr.js@2.5.0: {}
json-schema-ref-resolver@3.0.0:
@@ -907,10 +1137,42 @@ snapshots:
process-warning: 4.0.0
set-cookie-parser: 2.6.0
lint-staged@17.3.0:
dependencies:
picomatch: 4.0.5
string-argv: 0.3.2
tinyexec: 1.3.0
optionalDependencies:
yaml: 2.9.0
nanoid@3.3.18: {}
on-exit-leak-free@2.1.2: {}
oxfmt@0.64.0:
dependencies:
tinypool: 2.1.0
optionalDependencies:
'@oxfmt/binding-android-arm-eabi': 0.64.0
'@oxfmt/binding-android-arm64': 0.64.0
'@oxfmt/binding-darwin-arm64': 0.64.0
'@oxfmt/binding-darwin-x64': 0.64.0
'@oxfmt/binding-freebsd-x64': 0.64.0
'@oxfmt/binding-linux-arm-gnueabihf': 0.64.0
'@oxfmt/binding-linux-arm-musleabihf': 0.64.0
'@oxfmt/binding-linux-arm64-gnu': 0.64.0
'@oxfmt/binding-linux-arm64-musl': 0.64.0
'@oxfmt/binding-linux-ppc64-gnu': 0.64.0
'@oxfmt/binding-linux-riscv64-gnu': 0.64.0
'@oxfmt/binding-linux-riscv64-musl': 0.64.0
'@oxfmt/binding-linux-s390x-gnu': 0.64.0
'@oxfmt/binding-linux-x64-gnu': 0.64.0
'@oxfmt/binding-linux-x64-musl': 0.64.0
'@oxfmt/binding-openharmony-arm64': 0.64.0
'@oxfmt/binding-win32-arm64-msvc': 0.64.0
'@oxfmt/binding-win32-ia32-msvc': 0.64.0
'@oxfmt/binding-win32-x64-msvc': 0.64.0
picocolors@1.1.1: {}
picomatch@4.0.5: {}
@@ -1011,22 +1273,28 @@ snapshots:
split2@4.2.0: {}
string-argv@0.3.2: {}
thread-stream@4.2.0:
dependencies:
real-require: 1.0.0
tinyexec@1.3.0: {}
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.5)
picomatch: 4.0.5
tinypool@2.1.0: {}
toad-cache@3.7.4: {}
typescript@5.7.3: {}
undici-types@6.21.0: {}
vite@6.4.3(@types/node@22.20.1):
vite@6.4.3(@types/node@22.20.1)(yaml@2.9.0):
dependencies:
esbuild: 0.25.0
fdir: 6.5.0(picomatch@4.0.5)
@@ -1037,3 +1305,7 @@ snapshots:
optionalDependencies:
'@types/node': 22.20.1
fsevents: 2.3.3
yaml: 2.9.0
yaml@2.9.0:
optional: true