File tree Expand file tree Collapse file tree
docs/examples/claude-code-hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242EDITED_FILES=$( awk ' {print $2}' " $LOG_FILE " | sort -u)
4343
4444# Filter staged files to src/ and tests/ that were edited in this session
45- FILES_TO_LINT=" "
45+ declare -a FILES_TO_LINT=()
4646while IFS= read -r file; do
4747 case " $file " in
4848 src/* .js|src/* .ts|src/* .tsx|tests/* .js|tests/* .ts|tests/* .tsx) ;;
4949 * ) continue ;;
5050 esac
5151 if echo " $EDITED_FILES " | grep -qxF " $file " ; then
52- FILES_TO_LINT= " ${FILES_TO_LINT : + $FILES_TO_LINT } $ file"
52+ FILES_TO_LINT+=( " $ file" )
5353 fi
5454done <<< " $STAGED"
5555
56- if [ -z " $ FILES_TO_LINT" ]; then
56+ if [ " ${ # FILES_TO_LINT[@]} " -eq 0 ]; then
5757 exit 0
5858fi
5959
6060# Run biome check on the specific files.
6161# Intentional fail-open: if biome crashes or OOMs (non-zero exit with no output),
6262# the commit is allowed through. We only block when there is actionable lint output.
6363cd " $WORK_ROOT " || exit 0
64- # shellcheck disable=SC2086
65- LINT_OUTPUT=$( npx biome check --no-errors-on-unmatched $FILES_TO_LINT 2>&1 ) || LINT_EXIT=$?
64+ LINT_OUTPUT=$( npx biome check --no-errors-on-unmatched " ${FILES_TO_LINT[@]} " 2>&1 ) || LINT_EXIT=$?
6665
6766if [ " ${LINT_EXIT:- 0} " -ne 0 ] && [ -n " $LINT_OUTPUT " ]; then
6867 # Truncate output to first 30 lines to keep denial message readable
Original file line number Diff line number Diff line change 4242EDITED_FILES=$( awk ' {print $2}' " $LOG_FILE " | sort -u)
4343
4444# Filter staged files to src/ and tests/ that were edited in this session
45- FILES_TO_LINT=" "
45+ declare -a FILES_TO_LINT=()
4646while IFS= read -r file; do
4747 case " $file " in
4848 src/* .js|src/* .ts|src/* .tsx|tests/* .js|tests/* .ts|tests/* .tsx) ;;
4949 * ) continue ;;
5050 esac
5151 if echo " $EDITED_FILES " | grep -qxF " $file " ; then
52- FILES_TO_LINT= " ${FILES_TO_LINT : + $FILES_TO_LINT } $ file"
52+ FILES_TO_LINT+=( " $ file" )
5353 fi
5454done <<< " $STAGED"
5555
56- if [ -z " $ FILES_TO_LINT" ]; then
56+ if [ " ${ # FILES_TO_LINT[@]} " -eq 0 ]; then
5757 exit 0
5858fi
5959
6060# Run biome check on the specific files.
6161# Intentional fail-open: if biome crashes or OOMs (non-zero exit with no output),
6262# the commit is allowed through. We only block when there is actionable lint output.
6363cd " $WORK_ROOT " || exit 0
64- # shellcheck disable=SC2086
65- LINT_OUTPUT=$( npx biome check --no-errors-on-unmatched $FILES_TO_LINT 2>&1 ) || LINT_EXIT=$?
64+ LINT_OUTPUT=$( npx biome check --no-errors-on-unmatched " ${FILES_TO_LINT[@]} " 2>&1 ) || LINT_EXIT=$?
6665
6766if [ " ${LINT_EXIT:- 0} " -ne 0 ] && [ -n " $LINT_OUTPUT " ]; then
6867 # Truncate output to first 30 lines to keep denial message readable
You can’t perform that action at this time.
0 commit comments