From b9c122e7f4eed16d701a0d38a5d9df0fe0ff137f Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:19:31 +0800 Subject: [PATCH] fix: simplify pre-commit hook flow (#34637) --- .github/pull_request_template.md | 2 +- .vite-hooks/pre-commit | 26 -------------------------- web/docs/lint.md | 2 +- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 50dbde2aee..a069b6cbc7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -20,4 +20,4 @@ - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. -- [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods +- [x] I ran `make lint` and `make type-check` (backend) and `cd web && pnpm exec vp staged` (frontend) to appease the lint gods diff --git a/.vite-hooks/pre-commit b/.vite-hooks/pre-commit index a4b5531ab1..db5c504606 100755 --- a/.vite-hooks/pre-commit +++ b/.vite-hooks/pre-commit @@ -95,31 +95,5 @@ if $web_modified; then exit 1 fi - echo "Running unit tests check" - modified_files=$(git diff --cached --name-only -- utils | grep -v '\.spec\.ts$' || true) - - if [ -n "$modified_files" ]; then - for file in $modified_files; do - test_file="${file%.*}.spec.ts" - echo "Checking for test file: $test_file" - - # check if the test file exists - if [ -f "../$test_file" ]; then - echo "Detected changes in $file, running corresponding unit tests..." - pnpm run test "../$test_file" - - if [ $? -ne 0 ]; then - echo "Unit tests failed. Please fix the errors before committing." - exit 1 - fi - echo "Unit tests for $file passed." - else - echo "Warning: $file does not have a corresponding test file." - fi - - done - echo "All unit tests for modified web/utils files have passed." - fi - cd ../ fi diff --git a/web/docs/lint.md b/web/docs/lint.md index 0203964621..4f1e819a03 100644 --- a/web/docs/lint.md +++ b/web/docs/lint.md @@ -38,7 +38,7 @@ Treat this as an escape hatch—fix these errors when time permits. ### The Auto-Fix Workflow and Suppression Strategy To streamline your development process, we recommend configuring your editor to automatically fix lint errors on save. -As a fallback, any remaining autofixable errors will be corrected automatically when you commit. +As a fallback, the commit hook runs `vp staged`, which applies autofixable ESLint changes to staged files before the commit continues. To prevent workflow disruptions, these commit hooks are intentionally bypassed when you are merging branches, rebasing, or cherry-picking. Additionally, we currently track many existing legacy errors in eslint-suppressions.json.