#!/bin/bash

# Read JSON from stdin and extract file path
FILE_PATH=$(jq -r '.tool_input.file_path' 2>/dev/null)

# Only run ESLint if file is in client/ and is a JS/TS file
if [[ "$FILE_PATH" == */client/* ]] && [[ "$FILE_PATH" =~ \.(ts|tsx|js|jsx)$ ]]; then
  cd client && bunx eslint --fix "$FILE_PATH"
fi

exit 0
