Summary
The generated pre-commit hook captures output into a temp file, deletes the file, and then continues without exiting non-zero. As a result, commits can still succeed even when React Doctor reports blocking errors.
Current Behavior
react_doctor_output=$(mktemp "${TMPDIR:-/tmp}/react-doctor-hook.XXXXXX")
if react_doctor_scan_staged_files > "$react_doctor_output" 2>&1; then
rm -f "$react_doctor_output"
else
rm -f "$react_doctor_output"
printf '%s\n' "React Doctor found staged regressions." "Run react-doctor --staged --blocking warning to inspect." "Want them fixed? Ask your agent to run that command and resolve the findings." >&2
fi
- on failure the output is deleted before printing it
- only prints a generic message and still allows the commit
Suggested Fix
avoid capturing output and fail
if ! react_doctor_scan_staged_files; then
printf '%s\n' "React Doctor found staged regressions." "Run react-doctor --staged --blocking warning to inspect." >&2
exit 1
fi
or capture output before deleting
react_doctor_output=$(mktemp "${TMPDIR:-/tmp}/react-doctor-hook.XXXXXX")
if ! react_doctor_scan_staged_files > "$react_doctor_output" 2>&1; then
cat "$react_doctor_output" >&2
rm -f "$react_doctor_output"
printf '%s\n' "React Doctor found staged regressions." >&2
exit 1
fi
rm -f "$react_doctor_output"
Summary
The generated pre-commit hook captures output into a temp file, deletes the file, and then continues without exiting non-zero. As a result, commits can still succeed even when React Doctor reports blocking errors.
Current Behavior
Suggested Fix
avoid capturing output and fail
or capture output before deleting