Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 28 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -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"