Problem
Currently, linting and test failures are only caught in CircleCI/GitHub Actions after code is pushed. This leads to:
- Failed CI/CD builds that could have been prevented locally
- Wasted time waiting for CI feedback
- Additional commits to fix simple linting errors
- Broken master/release branches if checks are bypassed
Recent example: Issue #80 had ESLint errors that passed locally but failed in CircleCI due to unused imports and variables.
Solution
Implement Option 2: Husky with Full Test Suite - run comprehensive checks before every commit.
Pre-Commit Hook Configuration
.husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
echo "🔍 Running pre-commit checks..."
# Run linting
echo "📝 Running ESLint..."
npm run lint || exit 1
# Run tests with coverage
echo "🧪 Running tests with coverage..."
npm run test:coverage || exit 1
# Check coverage threshold
echo "📊 Verifying 100% coverage..."
npx nyc check-coverage --lines 100 --branches 100 --functions 100 --statements 100 || exit 1
echo "✅ All pre-commit checks passed!"
Installation Steps
# Install Husky
npm install --save-dev husky
# Initialize Husky
npx husky init
# Create pre-commit hook (content above)
package.json update:
{
"scripts": {
"prepare": "husky install"
}
}
Benefits
✅ Catch errors immediately - Before they reach CI/CD
✅ Maintain 100% coverage - Enforced on every commit
✅ Consistent code quality - ESLint rules applied automatically
✅ Faster CI/CD - Fewer failed builds
✅ Team alignment - Everyone runs the same checks
Considerations
⚠️ Slower commits - May take 30-60 seconds per commit (acceptable for quality)
⚠️ Can be bypassed - Developers can use git commit --no-verify (document when this is acceptable)
⚠️ Local setup required - Team must run npm install after pulling
Acceptance Criteria
Related
Implementation Notes
- Consider adding
commitlint in future for commit message standards
- Could add
lint-staged later for faster staged-file-only checks
- May want to add TypeScript type checking (
tsc --noEmit) to hook
Problem
Currently, linting and test failures are only caught in CircleCI/GitHub Actions after code is pushed. This leads to:
Recent example: Issue #80 had ESLint errors that passed locally but failed in CircleCI due to unused imports and variables.
Solution
Implement Option 2: Husky with Full Test Suite - run comprehensive checks before every commit.
Pre-Commit Hook Configuration
.husky/pre-commit:Installation Steps
package.jsonupdate:{ "scripts": { "prepare": "husky install" } }Benefits
✅ Catch errors immediately - Before they reach CI/CD
✅ Maintain 100% coverage - Enforced on every commit
✅ Consistent code quality - ESLint rules applied automatically
✅ Faster CI/CD - Fewer failed builds
✅ Team alignment - Everyone runs the same checks
Considerations
git commit --no-verify(document when this is acceptable)npm installafter pullingAcceptance Criteria
--no-verifyfor WIP)Related
.circleci/config.ymlpackage.json(eslintConfig)Implementation Notes
commitlintin future for commit message standardslint-stagedlater for faster staged-file-only checkstsc --noEmit) to hook