running prettier for cleanup
This commit is contained in:
parent
fe7733aeb5
commit
d85cd58acd
151 changed files with 29158 additions and 27966 deletions
32
.githooks/pre-commit
Executable file
32
.githooks/pre-commit
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Pre-commit hook to run Prettier
|
||||
echo "Running Prettier format check..."
|
||||
|
||||
# Check if prettier is available
|
||||
if ! command -v prettier &> /dev/null; then
|
||||
echo "Prettier not found. Please install it with: bun add -d prettier"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run prettier check on staged files
|
||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|js|json)$')
|
||||
|
||||
if [[ -n "$STAGED_FILES" ]]; then
|
||||
echo "Checking format for staged files..."
|
||||
|
||||
# Check if files are formatted
|
||||
npx prettier --check $STAGED_FILES
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo ""
|
||||
echo "❌ Some files are not formatted correctly."
|
||||
echo "Please run 'npm run format' or 'bun run format' to fix formatting issues."
|
||||
echo "Or run 'npx prettier --write $STAGED_FILES' to format just the staged files."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ All staged files are properly formatted."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue