Warn if console.log appears in staged changes (Husky pre-commit).
npm install detect-console-logA tiny CLI to warn about console.log in staged changes during Git commits. Designed to work with Husky pre-commit hooks.
Install packages
``bash
npm install --save-dev detect-console-log husky
npx husky init
Add this line to
.husky/pre-commit`bash
npm exec detect-console-logor with yarn
yarn detect-console-log
`Optional flags:
-
--fail-on-found`: always fail commit if console.log is found.---
Notes
- Scans only staged changes (git diff --cached), not your entire repo.
- Ignores files removed from commit
- Compatible with Node.js v14+