Skip to content

pre-commit hook swallows diagnostics and does not block commits #969

Description

@drewradcliff

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions