Git Hooks/Pre-commit lint script

Run linting before commit and fail on error.

Section: Hook Snippets

Pre-commit lint script

sh
bash
#!/usr/bin/env sh
npm run lint

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Hook Snippets
Pre-commit test script
Run tests before commit.
OpenIn sheetshsame section
Commit-msg conventional commits validator
Reject non-conforming commit messages.
OpenIn sheetshsame section
Block direct pushes to main
Prevent accidental pushes to main.
OpenIn sheetshsame section
Post-checkout regenerate assets
Run setup after checkout when needed.
OpenIn sheetshsame section
Pre-commit hook path
Default path for pre-commit hook script.
OpenIn sheetsh2 tag match
Show hooksPath
See whether Git uses a non-default hook directory.
OpenIn sheetbash1 tag match