Husky
Git hooks for commit validation and linting
Installation
npm add -D husky lint-staged
npm exec husky initThis creates a .husky/ directory and adds a prepare script to package.json.
Commit Message Validation
Create .husky/commit-msg to enforce commit message format:
commit_msg=$(cat "$1")
if ! echo "$commit_msg" | grep -qE "^(fix|feat|chores|other):"; then
echo "Error: Commit message must start with one of: fix:, feat:, chores:, other:"
echo "Example: feat: add new feature"
echo ""
echo "Your message: $commit_msg"
exit 1
fiValid commit examples
git commit -m "fix: resolve login bug"
git commit -m "feat: add dark mode toggle"
git commit -m "chores: update dependencies"
git commit -m "other: misc cleanup"Pre-commit Linting
Create .husky/pre-commit to run linting on staged files:
npm exec lint-stagedConfigure lint-staged
Add to package.json:
{
"scripts": {
"lint": "eslint ."
},
"lint-staged": {
"*.{js,ts,vue}": "eslint --fix"
}
}This only lints files being committed and auto-fixes issues where possible.
How it works
When you run git commit:
- pre-commit hook runs
lint-stagedon staged files - ESLint checks and auto-fixes issues
- commit-msg hook validates the message format
- Commit succeeds or fails based on the checks
Manual linting
Run linting on the entire project:
npm run lintDocker templates
I've put together a collection of Docker Compose templates that I use for various projects. These are production-ready configurations that I've tested and refined over time.
Massgrave
You can activate Windows and Office products using Massgrave. This is a free and open-source tool that allows you to activate Windows and Office products without the need for a license key.