4- Created a pre-commit
file in directory .git/hooks/pre-commit
and added the following rules like "NO trailing whitespace allowed" with this script
#!/bin/bash if git diff --cached --check; then : else echo "ERROR: Trailing whitespace detected. Please remove it before committing." exit 1 fi if git diff --cached | grep -E '^(+|-).*console\.log' -q; then echo "ERROR: Debugging statements (e.g., console.log) detected. Please remove them before committing." exit 1 fi exit 0