From 67cd05934010bba406292c7f6f2aca73cf3c5a2d Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 20 May 2026 20:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20chore:=20replace=20husky=20with?= =?UTF-8?q?=20native=20git=20hooks=20(#14941)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {.husky => .githooks}/pre-commit | 10 +++++++++- .gitignore | 2 +- .prettierignore | 4 ++-- docs/development/basic/contributing-guidelines.mdx | 2 +- .../basic/contributing-guidelines.zh-CN.mdx | 2 +- package.json | 3 +-- scripts/vercelIgnoredBuildStep.js | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) rename {.husky => .githooks}/pre-commit (51%) diff --git a/.husky/pre-commit b/.githooks/pre-commit similarity index 51% rename from .husky/pre-commit rename to .githooks/pre-commit index 67538d4f4a..f929d3039a 100755 --- a/.husky/pre-commit +++ b/.githooks/pre-commit @@ -1,5 +1,13 @@ +#!/usr/bin/env sh +set -e + +[ "${HUSKY-}" = "0" ] && exit 0 + +export PATH="node_modules/.bin:$PATH" + BRANCH=$(git branch --show-current) if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "main" ]; then npm run type-check fi -npx --no-install lint-staged + +lint-staged diff --git a/.gitignore b/.gitignore index 798a09c7b0..ffe4d294a4 100644 --- a/.gitignore +++ b/.gitignore @@ -96,7 +96,7 @@ sitemap*.xml robots.txt # Git hooks -.husky/prepare-commit-msg +.githooks/prepare-commit-msg # Documents and media *.pdf diff --git a/.prettierignore b/.prettierignore index ecdda4cd90..e96269b4bc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,7 +8,7 @@ .history .temp .env.local -.husky +.githooks .npmrc .gitkeep venv @@ -59,4 +59,4 @@ Dockerfile* # misc # add other ignore file below -.next \ No newline at end of file +.next diff --git a/docs/development/basic/contributing-guidelines.mdx b/docs/development/basic/contributing-guidelines.mdx index 0b4c1fb3bb..7ef4f64895 100644 --- a/docs/development/basic/contributing-guidelines.mdx +++ b/docs/development/basic/contributing-guidelines.mdx @@ -41,7 +41,7 @@ We utilize stylelint to standardize the style of our CSS code. In the configurat ### Style Checking -You don't need to manually run these checks. The project is configured with husky to automatically run lint-staged when you commit code, which will check if your committed files comply with the above standards. +You don't need to manually run these checks. The project is configured with Git hooks to automatically run lint-staged when you commit code, which will check if your committed files comply with the above standards. ## Contribution Process diff --git a/docs/development/basic/contributing-guidelines.zh-CN.mdx b/docs/development/basic/contributing-guidelines.zh-CN.mdx index 9ae620ee66..b512f11bf2 100644 --- a/docs/development/basic/contributing-guidelines.zh-CN.mdx +++ b/docs/development/basic/contributing-guidelines.zh-CN.mdx @@ -39,7 +39,7 @@ Prettier 负责代码格式化,以保证代码的一致性。您可以在 `.pr ### 风格检查 -你不需要手动运行这些检查,项目配置了 husky 会在您提交代码时自动运行 lint-staged 检查你提交的文件是否符合以上规范。 +你不需要手动运行这些检查,项目配置了 Git hooks 会在您提交代码时自动运行 lint-staged 检查你提交的文件是否符合以上规范。 ## 贡献流程 diff --git a/package.json b/package.json index 34b2c49b9a..cee1ef54b2 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix", "lint:ts": "eslint src/ tests/ --concurrency=auto", "lint:unused": "knip --include files,exports,types,enumMembers,duplicates", - "prepare": "husky", + "prepare": "git config core.hooksPath .githooks", "prettier": "prettier -c --write \"**/**\"", "pull": "git pull", "qstash": "pnpx @upstash/qstash-cli@latest dev", @@ -509,7 +509,6 @@ "fs-extra": "^11.3.3", "glob": "^13.0.0", "happy-dom": "^20.3.7", - "husky": "^9.1.7", "import-in-the-middle": "^2.0.5", "just-diff": "^6.0.2", "knip": "^5.82.1", diff --git a/scripts/vercelIgnoredBuildStep.js b/scripts/vercelIgnoredBuildStep.js index 1d85c9c780..dd6859c2eb 100644 --- a/scripts/vercelIgnoredBuildStep.js +++ b/scripts/vercelIgnoredBuildStep.js @@ -21,7 +21,7 @@ function shouldProceedBuild() { ":!./*.md" \ ":!./Dockerfile" \ ":!./.github" \ - ":!./.husky" \ + ":!./.githooks" \ ":!./scripts"'; execSync(diffCommand);