-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit hook for linting and formatting
- Loading branch information
Showing
5 changed files
with
13,605 additions
and
13,535 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CHANGED_FILES=$(git diff --cached --name-only) | ||
|
||
LINT_FRONTEND=false | ||
LINT_BACKEND=false | ||
|
||
for FILE in $CHANGED_FILES; do | ||
if [[ $FILE =~ ^frontend/ ]]; then | ||
LINT_FRONTEND=true | ||
elif [[ $FILE =~ ^backend/ ]]; then | ||
LINT_BACKEND=true | ||
fi | ||
done | ||
|
||
if [ "$LINT_FRONTEND" = true ]; then | ||
echo "Changes detected in the frontend. Linting & Formatting frontend..." | ||
cd frontend && npm run lint && npm run format:check | ||
EXIT_CODE=$? | ||
cd .. | ||
if [ $EXIT_CODE -ne 0 ]; then | ||
echo "Frontend linting failed. Commit aborted." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [ "$LINT_BACKEND" = true ]; then | ||
echo "Changes detected in the backend. Linting & Formatting backend..." | ||
cd backend && npm run lint && npm run format | ||
EXIT_CODE=$? | ||
cd .. | ||
if [ $EXIT_CODE -ne 0 ]; then | ||
echo "Backend linting failed. Commit aborted." | ||
exit 1 | ||
fi | ||
fi |
Oops, something went wrong.