Overview
Pre-commit hooks are the first line of defense in a 'shift-left' strategy. They allow teams to catch simple errors and style violations before the code even leaves the developer's machine.
Common Checks
- Linting: Ensuring code follows the style guide.
- Formatting: Automatically fixing whitespace and indentation (e.g., with Prettier).
- Secret Scanning: Checking for accidentally committed API keys or passwords.
- Unit Testing: Running a small subset of fast tests.
Popular Tools
- pre-commit (framework): A multi-language framework for managing and maintaining multi-language pre-commit hooks.
- Husky: A popular tool for managing Git hooks in JavaScript projects.