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
34 changes: 34 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# Pre-commit hook: auto-format and lint the project with Biome.
# Aborts the commit if unfixable lint errors remain after auto-fix.

STAGED=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(ts|js|json|html)$')

if [ -z "$STAGED" ]; then
exit 0
fi

echo "Running Biome fix on staged files..."

# Run biome fix on staged files only (using node_modules binary so npm scripts are not needed)
BIOME="./node_modules/.bin/biome"
if [ ! -x "$BIOME" ]; then
echo "Biome not found in node_modules. Run 'npm install' first."
exit 1
fi

echo "$STAGED" | xargs "$BIOME" check --write --no-errors-on-unmatched

STATUS=$?

# Re-stage the files that were originally staged (biome may have modified them)
echo "$STAGED" | xargs git add

if [ $STATUS -ne 0 ]; then
echo ""
echo "Biome reported errors that could not be auto-fixed."
echo "Please fix the issues above and try committing again."
exit 1
fi

exit 0
34 changes: 34 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# Pre-push hook: run full lint and type-check before pushing.
# Blocks the push if there are lint errors or type errors.

BIOME="./node_modules/.bin/biome"
TSC="./node_modules/.bin/tsc"

if [ ! -x "$BIOME" ] || [ ! -x "$TSC" ]; then
echo "Required tools not found in node_modules. Run 'npm install' first."
exit 1
fi

echo "Running Biome lint check..."
"$BIOME" lint .
LINT_STATUS=$?

if [ $LINT_STATUS -ne 0 ]; then
echo ""
echo "Lint errors found. Run 'npm run fix' to auto-fix, then commit and push again."
exit 1
fi

echo "Running TypeScript type check..."
"$TSC" --noEmit
TSC_STATUS=$?

if [ $TSC_STATUS -ne 0 ]; then
echo ""
echo "TypeScript errors found. Fix the errors above before pushing."
exit 1
fi

echo "All checks passed."
exit 0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"watch": "tsc --watch",
"clean": "rm -rf dist",
"generate-svg-icon": "tsx scripts/bouncingBallToSVG.ts",
"icons": "npm run generate-svg-icon && tsx scripts/generate-icons.ts"
"icons": "npm run generate-svg-icon && tsx scripts/generate-icons.ts",
"prepare": "git config core.hooksPath .githooks"
},
"dependencies": {
"@ffmpeg/core": "^0.12.10",
Expand Down