π OpenHands: AI-Driven Development
Add make lint to pre-commit hook (#9795)
Xingyao Wang58ea7b5248ab
diff --git a/.openhands/pre-commit.sh b/.openhands/pre-commit.shindex ba260d3476..05c335db18 100755--- a/.openhands/pre-commit.sh+++ b/.openhands/pre-commit.sh@@ -1,29 +1,32 @@#!/bin/bashecho "Running OpenHands pre-commit hook..."+echo "This hook runs 'make lint' to ensure code quality before committing."# Store the exit code to return at the end# This allows us to be additive to existing pre-commit hooksEXIT_CODE=0+# Run make lint to check both frontend and backend code+echo "Running linting checks with 'make lint'..."+make lint+if [ $? -ne 0 ]; then+ echo "Linting failed. Please fix the issues before committing."+ EXIT_CODE=1+else+ echo "Linting checks passed!"+fi+# Check if frontend directory has changedfrontend_changes=$(git diff --cached --name-only | grep "^frontend/")if [ -n "$frontend_changes" ]; then- echo "Frontend changes detected. Running frontend checks..."+ echo "Frontend changes detected. Running additional frontend checks..."# Check if frontend directory existsif [ -d "frontend" ]; then# Change to frontend directorycd frontend || exit 1- # Run lint:fix- echo "Running npm lint:fix..."- npm run lint:fix- if [ $? -ne 0 ]; then- echo "Frontend linting failed. Please fix the issues before committing."- EXIT_CODE=1- fi-# Run buildecho "Running npm build..."npm run build@@ -50,7 +53,7 @@ if [ -n "$frontend_changes" ]; thenecho "Frontend directory not found. Skipping frontend checks."fielse- echo "No frontend changes detected. Skipping frontend checks."+ echo "No frontend changes detected. Skipping additional frontend checks."fi# Run any existing pre-commit hooks that might have been installed by the user