From b0e0b52f5fd31d498befc44b316f84b5956db230 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Thu, 16 Jul 2026 18:10:12 +0200 Subject: [PATCH] Speed up pre commit checks --- .github/copilot-instructions.md | 4 ++-- .husky/pre-commit | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 0c48ce8f75..45172ddcd1 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -20,8 +20,8 @@ - **Commands**: When adding a new command, consider whether it should be available in the command palette, context menus, or both. Add the appropriate menu entries in `package.json` to ensure the command is properly included, or excluded (command palette), from menus. ## Pull Request Guidelines -- Never touch the yarn.lock file. -- Run `yarn run lint` and also `npm run hygiene` and fix any errors or warnings before committing. +- Never touch the package-lock.json file. +- Run `npm run lint` and also `npm run hygiene` and fix any errors or warnings before committing. ## Testing - Use `describe` and `it` blocks from Mocha for structuring tests. diff --git a/.husky/pre-commit b/.husky/pre-commit index 17c0786299..1e24795ff3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,37 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run hygiene +# Hygiene reads staged contents while ESLint checks the working tree, so they can run concurrently. +node ./build/hygiene.js & +hygiene_pid=$! +lint_pid='' # Lint only staged TS/TSX files instead of the whole repo (much faster). # Stream a NUL-delimited list directly to xargs -0 so paths with spaces/newlines # are handled safely (command substitution would strip NUL bytes). if git diff --cached --name-only --diff-filter=ACMR -- '*.ts' '*.tsx' | grep -q .; then - git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 npx eslint --fix --cache + git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 node ./node_modules/eslint/bin/eslint.js --fix --cache & + lint_pid=$! fi + +hygiene_status=0 +if wait "$hygiene_pid"; then + : +else + hygiene_status=$? +fi + +lint_status=0 +if [ -n "$lint_pid" ]; then + if wait "$lint_pid"; then + : + else + lint_status=$? + fi +fi + +if [ "$hygiene_status" -ne 0 ]; then + exit "$hygiene_status" +fi + +exit "$lint_status"