From c5a1b1cd9cbc4e0845ba97a109e711bffcba9475 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Tue, 3 Jun 2025 18:44:23 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=20husky=20=E5=B9=B6?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20pre-commit=20=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 husky 依赖用于 Git 钩子管理 - 配置 pre-commit 钩子自动执行 eslint 检查 - 在 package.json 中添加 prepare 脚本自动安装 husky --- .husky/pre-commit | 2 ++ package.json | 4 +++- pnpm-lock.yaml | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..1525982 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" diff --git a/package.json b/package.json index f539ee4..8076be6 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", "build:quickapp-webview-union": "uni build -p quickapp-webview-union", "type-check": "vue-tsc --noEmit", - "openapi-ts-request": "openapi-ts" + "openapi-ts-request": "openapi-ts", + "prepare": "husky" }, "lint-staged": { "**/*.{html,vue,ts,cjs,json,md}": [ @@ -134,6 +135,7 @@ "@vue/runtime-core": "^3.4.21", "@vue/tsconfig": "^0.1.3", "autoprefixer": "^10.4.20", + "husky": "^9.1.7", "lint-staged": "^15.2.10", "openapi-ts-request": "^1.1.2", "oxlint": "^0.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99811ab..d2aebfa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -159,6 +159,9 @@ importers: autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.49) + husky: + specifier: ^9.1.7 + version: 9.1.7 lint-staged: specifier: ^15.2.10 version: 15.2.10 @@ -3391,6 +3394,11 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} + husky@9.1.7: + resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} + engines: {node: '>=18'} + hasBin: true + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -9630,6 +9638,8 @@ snapshots: human-signals@5.0.0: {} + husky@9.1.7: {} + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2