#!/bin/bash # Block modifications to linter/formatter configuration files # Event: PreToolUse | Matcher: Edit|Write # Profile: standard # Exit 2 = block, Exit 0 = allow INPUT=$(cat) FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') if [ -z "$FILE_PATH" ]; then exit 0 fi # Protected config files (linters, formatters, build configs) PROTECTED_CONFIGS=( ".eslintrc" ".eslintrc.js" ".eslintrc.json" ".eslintrc.yml" "eslint.config.js" "eslint.config.mjs" ".prettierrc" ".prettierrc.js" ".prettierrc.json" "prettier.config.js" "biome.json" "biome.jsonc" ".editorconfig" "tsconfig.json" "tsconfig.base.json" ) FILENAME=$(basename "$FILE_PATH") for config in "${PROTECTED_CONFIGS[@]}"; do if [ "$FILENAME" = "$config" ]; then echo "Blocked: modifying config file '$FILENAME'. These files affect the entire project." >&2 echo "If this change is intentional, disable this hook: CLAUDE_DISABLED_HOOKS=config-protection.sh" >&2 exit 2 fi done exit 0