Files
bypass-paywalls-firefox-clean/.claude/hooks/lint-file.sh
T
dasemuandClaude Sonnet 5 980f9ffe17 chore: bootstrap Claude setup
Add root CLAUDE.md, docs/architecture.md, LESSONS.md, .env.example, VERSION,
.claude/settings.json hooks (syntax/JSON checks since no linter/tests exist
yet), and CI/version-bump GitHub workflows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-18 11:42:56 +02:00

33 lines
804 B
Bash
Executable File

#!/usr/bin/env bash
# PostToolUse hook (Edit/Write): quick syntax check on the file that was just changed.
# No linter/formatter is configured for this project, so this only catches
# JS syntax errors and invalid JSON.
set -euo pipefail
input=$(cat)
file_path=$(echo "$input" | node -e "
let d='';
process.stdin.on('data', c => d += c);
process.stdin.on('end', () => {
try {
const j = JSON.parse(d);
process.stdout.write(j.tool_input?.file_path || '');
} catch { process.stdout.write(''); }
});
" <<< "$input")
[ -z "$file_path" ] && exit 0
[ -f "$file_path" ] || exit 0
case "$file_path" in
*.js)
node --check "$file_path"
;;
*.json)
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$file_path"
;;
*)
exit 0
;;
esac