Skip to content

Commit d621ff1

Browse files
authored
Speed up pre commit checks (#8851)
1 parent 398f99e commit d621ff1

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
- **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.
2121

2222
## Pull Request Guidelines
23-
- Never touch the yarn.lock file.
24-
- Run `yarn run lint` and also `npm run hygiene` and fix any errors or warnings before committing.
23+
- Never touch the package-lock.json file.
24+
- Run `npm run lint` and also `npm run hygiene` and fix any errors or warnings before committing.
2525

2626
## Testing
2727
- Use `describe` and `it` blocks from Mocha for structuring tests.

.husky/pre-commit

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run hygiene
4+
# Hygiene reads staged contents while ESLint checks the working tree, so they can run concurrently.
5+
node ./build/hygiene.js &
6+
hygiene_pid=$!
7+
lint_pid=''
58

69
# Lint only staged TS/TSX files instead of the whole repo (much faster).
710
# Stream a NUL-delimited list directly to xargs -0 so paths with spaces/newlines
811
# are handled safely (command substitution would strip NUL bytes).
912
if git diff --cached --name-only --diff-filter=ACMR -- '*.ts' '*.tsx' | grep -q .; then
10-
git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 npx eslint --fix --cache
13+
git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 node ./node_modules/eslint/bin/eslint.js --fix --cache &
14+
lint_pid=$!
1115
fi
16+
17+
hygiene_status=0
18+
if wait "$hygiene_pid"; then
19+
:
20+
else
21+
hygiene_status=$?
22+
fi
23+
24+
lint_status=0
25+
if [ -n "$lint_pid" ]; then
26+
if wait "$lint_pid"; then
27+
:
28+
else
29+
lint_status=$?
30+
fi
31+
fi
32+
33+
if [ "$hygiene_status" -ne 0 ]; then
34+
exit "$hygiene_status"
35+
fi
36+
37+
exit "$lint_status"

0 commit comments

Comments
 (0)