stack/.cursor/hooks/lint-file.sh
2026-01-30 22:39:17 -08:00

20 lines
450 B
Bash
Executable File

#!/bin/bash
# Cursor hook: afterFileEdit
# Runs lint --fix on JS/TS files after they are edited by the agent
# Read JSON input from stdin
input=$(cat)
# Extract file_path from the input
file_path=$(echo "$input" | jq -r '.file_path')
# If file is a JS/TS file, run lint --fix on it from the folder of the file
if [[ "$file_path" =~ \.(js|jsx|ts|tsx)$ ]]; then
cd "$(dirname "$file_path")"
pnpm run lint --fix "$file_path" || true
fi
exit 0