You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Check for staged files with unstaged modifications
7
+
MODIFIED_FILES=$(git diff --name-only)
8
+
9
+
# Find files that overlap between staged and modified without using process substitution
10
+
CONFLICTING_FILES=""
11
+
forfilein$STAGED_FILES;do
12
+
ifecho"$MODIFIED_FILES"| grep -qx "$file";then
13
+
CONFLICTING_FILES="$CONFLICTING_FILES$file\n"
14
+
fi
15
+
done
16
+
17
+
# Abort if there are conflicts
18
+
if [ -n"$CONFLICTING_FILES" ];then
19
+
echo"Error: The following staged files have unstaged modifications, which can cause issues with the pre-commit eslint fix and prettier rewrite execution:"
20
+
echo -e "$CONFLICTING_FILES"# Use -e for newline interpretation in echo
21
+
echo"Please stage the changes or reset them before committing."
22
+
echo"If this is a temporary local commit, you can also use the --no-verify flag to bypass the pre-commit test and linting. i.e. 'git commit --no-verify'"
23
+
exit 1 # Abort commit
24
+
fi
25
+
26
+
# Run tests and linting
1
27
npm test
2
28
npm run lint
29
+
30
+
# Re-stage files after lint fixes (only staged files)
0 commit comments