# Pre-commit and Code Quality Quick Reference ## ✅ What's Been Set Up Your project now has comprehensive code quality tools configured: ### 🔧 Tools Installed - **Pre-commit hooks** - Automatically run on every commit - **Prettier** - Code formatting for JS/TS/JSON/YAML/MD/CSS/SCSS/HTML - **ESLint** - JavaScript/TypeScript linting with React hooks and comprehensive rules - **TypeScript** - Type checking with strict configuration - **Hadolint** - Docker linting - **ShellCheck** - Shell script linting - **Markdownlint** - Markdown formatting and quality checks - **detect-secrets** - Security scanning to prevent secret commits - **EditorConfig** - Consistent coding styles across editors ### 🛡️ Environment File Security - **Never commit .env files** to version control, especially .env.production - Use .env.example as a template for new environment files - Add all .env files to .gitignore to prevent accidental commits - Use environment variables for configuration to maintain security and flexibility ### 📁 Configuration Files Created - `.pre-commit-config.yaml` - Comprehensive pre-commit hooks configuration - `.prettierrc` - Prettier formatting rules optimized for TypeScript/React - `.prettierignore` - Files excluded from formatting - `.editorconfig` - Editor configuration for consistent styles - `.markdownlint.json` - Markdown linting rules for documentation quality - `.secrets.baseline` - Security baseline for secret detection - `scripts/setup-pre-commit.sh` - Automated setup script - `docs/CODE_QUALITY.md` - Comprehensive documentation - Python virtual environment (`.venv/`) - Isolated Python tools environment ## 🚀 Quick Commands ```bash # Format all files bun run format # Check formatting (no changes) bun run format:check # Lint TypeScript/JavaScript bun run lint # Lint with auto-fix bun run lint:fix # Type check bun run type-check # Run lint-staged (pre-commit formatting) bun run pre-commit # Run all pre-commit hooks manually /home/will/Code/meds/.venv/bin/pre-commit run --all-files # Update pre-commit hook versions /home/will/Code/meds/.venv/bin/pre-commit autoupdate # Update secrets baseline /home/will/Code/meds/.venv/bin/detect-secrets scan --update .secrets.baseline ``` ## 🔄 How It Works 1. **On Commit**: Pre-commit hooks automatically run to: - Format code with Prettier - Lint with ESLint - Check TypeScript types - Scan for secrets - Lint Docker and shell files - Check YAML/JSON syntax 2. **If Issues Found**: Commit is blocked until fixed 3. **Auto-fixes Applied**: Many issues are automatically corrected ## 🛠️ IDE Setup ### VS Code Extensions (Recommended) - Prettier - Code formatter - ESLint - EditorConfig for VS Code ## 📖 Full Documentation See `docs/CODE_QUALITY.md` for complete setup and customization guide. --- **Your code will now be automatically formatted and checked on every commit! 🎉**