|
| 1 | +# Contributing to CodeKeeper |
| 2 | + |
| 3 | +Thank you for your interest in contributing to CodeKeeper! This guide will help you understand our development process and contribution guidelines. |
| 4 | + |
| 5 | +## 🚀 Automated Releases |
| 6 | + |
| 7 | +We use automated releases with [release-please](https://github.com/googleapis/release-please) and conventional commits. When you merge a PR to `main`, releases are created automatically based on your commit messages. |
| 8 | + |
| 9 | +## 📝 Conventional Commits |
| 10 | + |
| 11 | +We use [Conventional Commits](https://www.conventionalcommits.org/) to automatically generate changelogs and determine version bumps. |
| 12 | + |
| 13 | +### Commit Message Format |
| 14 | + |
| 15 | +``` |
| 16 | +<type>[optional scope]: <description> |
| 17 | +
|
| 18 | +[optional body] |
| 19 | +
|
| 20 | +[optional footer(s)] |
| 21 | +``` |
| 22 | + |
| 23 | +### Types |
| 24 | + |
| 25 | +- **feat**: A new feature (triggers minor version bump) |
| 26 | +- **fix**: A bug fix (triggers patch version bump) |
| 27 | +- **docs**: Documentation only changes |
| 28 | +- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc) |
| 29 | +- **refactor**: A code change that neither fixes a bug nor adds a feature |
| 30 | +- **perf**: A code change that improves performance (triggers minor version bump) |
| 31 | +- **test**: Adding missing tests or correcting existing tests |
| 32 | +- **build**: Changes that affect the build system or external dependencies |
| 33 | +- **ci**: Changes to our CI configuration files and scripts |
| 34 | +- **chore**: Other changes that don't modify src or test files |
| 35 | +- **revert**: Reverts a previous commit |
| 36 | + |
| 37 | +### Breaking Changes |
| 38 | + |
| 39 | +To trigger a major version bump, add `BREAKING CHANGE:` in the commit footer or add `!` after the type: |
| 40 | + |
| 41 | +```bash |
| 42 | +feat!: remove support for Node.js 16 |
| 43 | + |
| 44 | +BREAKING CHANGE: Node.js 18+ is now required |
| 45 | +``` |
| 46 | + |
| 47 | +### Examples |
| 48 | + |
| 49 | +```bash |
| 50 | +# New feature (minor bump) |
| 51 | +feat: add new TypeScript interface validation |
| 52 | + |
| 53 | +# Bug fix (patch bump) |
| 54 | +fix: correct regex pattern in AS casts detection |
| 55 | + |
| 56 | +# Documentation update (patch bump) |
| 57 | +docs: update installation instructions |
| 58 | + |
| 59 | +# Breaking change (major bump) |
| 60 | +feat!: update validation API to use async functions |
| 61 | + |
| 62 | +BREAKING CHANGE: All validation functions now return promises |
| 63 | +``` |
| 64 | + |
| 65 | +### Scopes (Optional) |
| 66 | + |
| 67 | +You can add scopes to provide more context: |
| 68 | + |
| 69 | +- `scripts`: Changes to validation scripts |
| 70 | +- `eslint`: Changes to ESLint plugin |
| 71 | +- `examples`: Changes to example projects |
| 72 | +- `ci`: Changes to GitHub Actions |
| 73 | +- `docs`: Changes to documentation |
| 74 | + |
| 75 | +Examples: |
| 76 | +```bash |
| 77 | +feat(scripts): add new barrel file detection patterns |
| 78 | +fix(eslint): correct rule loading in plugin |
| 79 | +docs(examples): add Next.js integration example |
| 80 | +``` |
| 81 | + |
| 82 | +## 🔄 Release Process |
| 83 | + |
| 84 | +### What Happens When You Merge a PR: |
| 85 | + |
| 86 | +1. **Commit Analysis**: Release-please analyzes conventional commits since the last release |
| 87 | +2. **Version Calculation**: Determines version bump based on commit types |
| 88 | +3. **Changelog Generation**: Creates changelog from commit messages |
| 89 | +4. **Release Creation**: Creates GitHub releases for both main project and ESLint plugin |
| 90 | +5. **Package Publishing**: Publishes ESLint plugin to GitHub Packages |
| 91 | +6. **Asset Creation**: Creates downloadable release assets |
| 92 | + |
| 93 | +### Two-Package Release Strategy: |
| 94 | + |
| 95 | +- **Main Project** (`codekeeper-guardrails`): Contains validation scripts, examples, docs |
| 96 | +- **ESLint Plugin** (`@thedaviddias/eslint-plugin-codekeeper`): Contains ESLint rules |
| 97 | + |
| 98 | +Both packages are versioned independently but released together when relevant. |
| 99 | + |
| 100 | +## 🛠️ Development Workflow |
| 101 | + |
| 102 | +### Setting Up |
| 103 | + |
| 104 | +1. **Clone the repository** |
| 105 | + ```bash |
| 106 | + git clone https://github.com/thedaviddias/codekeeper.git |
| 107 | + cd codekeeper |
| 108 | + ``` |
| 109 | + |
| 110 | +2. **Install dependencies** |
| 111 | + ```bash |
| 112 | + npm ci |
| 113 | + ``` |
| 114 | + |
| 115 | +3. **Install git hooks** |
| 116 | + ```bash |
| 117 | + npm run guardrails:setup |
| 118 | + ``` |
| 119 | + |
| 120 | +### Making Changes |
| 121 | + |
| 122 | +1. **Create a feature branch** |
| 123 | + ```bash |
| 124 | + git checkout -b feat/your-feature-name |
| 125 | + ``` |
| 126 | + |
| 127 | +2. **Make your changes** |
| 128 | + - Edit validation scripts in `scripts/validation/` |
| 129 | + - Update shared validators in `lib/validators/` if needed |
| 130 | + - Add/update tests in `test-validation/` |
| 131 | + - Update examples if relevant |
| 132 | + |
| 133 | +3. **Test your changes** |
| 134 | + ```bash |
| 135 | + npm test |
| 136 | + node test-validation/test-eslint-plugin.js |
| 137 | + ``` |
| 138 | + |
| 139 | +4. **Commit with conventional commit message** |
| 140 | + ```bash |
| 141 | + git add . |
| 142 | + git commit -m "feat: add new validation rule for components" |
| 143 | + ``` |
| 144 | + |
| 145 | +5. **Push and create PR** |
| 146 | + ```bash |
| 147 | + git push origin feat/your-feature-name |
| 148 | + ``` |
| 149 | + |
| 150 | +### Keeping Validators in Sync |
| 151 | + |
| 152 | +If you modify `lib/validators/`, the ESLint plugin validators will be automatically synced: |
| 153 | +- During PR validation |
| 154 | +- Before ESLint plugin releases |
| 155 | +- Via automated sync workflow |
| 156 | + |
| 157 | +## 🧪 Testing |
| 158 | + |
| 159 | +### Running Tests |
| 160 | + |
| 161 | +```bash |
| 162 | +# Run all validation tests |
| 163 | +npm test |
| 164 | + |
| 165 | +# Test ESLint plugin specifically |
| 166 | +node test-validation/test-eslint-plugin.js |
| 167 | + |
| 168 | +# Test individual validation scripts |
| 169 | +npm run test:as-casts |
| 170 | +npm run test:barrel-files |
| 171 | +npm run test:jsdoc |
| 172 | +npm run test:complexity |
| 173 | +``` |
| 174 | + |
| 175 | +### Adding Tests |
| 176 | + |
| 177 | +When adding new validation rules: |
| 178 | + |
| 179 | +1. **Create test fixtures** in `test-validation/fixtures/` |
| 180 | +2. **Add tests** to existing test files or create new ones |
| 181 | +3. **Update ESLint plugin tests** if you modify validators |
| 182 | +4. **Test both approaches** (standalone scripts + ESLint plugin) |
| 183 | + |
| 184 | +## 📋 Pull Request Guidelines |
| 185 | + |
| 186 | +### PR Title |
| 187 | + |
| 188 | +Use conventional commit format for PR titles: |
| 189 | +``` |
| 190 | +feat: add new TypeScript validation rule |
| 191 | +fix: correct barrel file detection regex |
| 192 | +docs: update installation instructions |
| 193 | +``` |
| 194 | + |
| 195 | +### PR Description |
| 196 | + |
| 197 | +Include: |
| 198 | +- **What**: What changes you made |
| 199 | +- **Why**: Why you made these changes |
| 200 | +- **How**: How you implemented the changes |
| 201 | +- **Testing**: What testing you performed |
| 202 | +- **Breaking Changes**: Any breaking changes (if applicable) |
| 203 | + |
| 204 | +### PR Checklist |
| 205 | + |
| 206 | +- [ ] Follows conventional commit format |
| 207 | +- [ ] Tests pass locally (`npm test`) |
| 208 | +- [ ] ESLint plugin tests pass (`node test-validation/test-eslint-plugin.js`) |
| 209 | +- [ ] Documentation updated (if needed) |
| 210 | +- [ ] Examples updated (if needed) |
| 211 | +- [ ] Backward compatibility maintained (or breaking change noted) |
| 212 | + |
| 213 | +## 🎯 Release Types |
| 214 | + |
| 215 | +### When Releases Are Created: |
| 216 | + |
| 217 | +- **feat**: New features → Minor version bump (1.0.0 → 1.1.0) |
| 218 | +- **fix**: Bug fixes → Patch version bump (1.0.0 → 1.0.1) |
| 219 | +- **feat!** or **BREAKING CHANGE**: → Major version bump (1.0.0 → 2.0.0) |
| 220 | +- **docs, style, refactor, test, etc.**: → Patch version bump |
| 221 | + |
| 222 | +### Release Artifacts: |
| 223 | + |
| 224 | +**Main Project Release:** |
| 225 | +- GitHub release with changelog |
| 226 | +- Downloadable `.tar.gz` with all scripts and examples |
| 227 | +- Installation script for easy setup |
| 228 | + |
| 229 | +**ESLint Plugin Release:** |
| 230 | +- Published to GitHub Packages |
| 231 | +- GitHub release with installation instructions |
| 232 | +- Synchronized with latest validation logic |
| 233 | + |
| 234 | +## 🔍 Code Review Process |
| 235 | + |
| 236 | +1. **Automated Checks**: PR validation runs automatically |
| 237 | +2. **Manual Review**: Maintainers review code and approach |
| 238 | +3. **Testing**: Changes are tested in various scenarios |
| 239 | +4. **Approval**: Once approved, PR can be merged |
| 240 | +5. **Automatic Release**: Merging triggers release process |
| 241 | + |
| 242 | +## 💡 Tips |
| 243 | + |
| 244 | +### Writing Good Commit Messages: |
| 245 | +- Use imperative mood ("add" not "added") |
| 246 | +- Keep first line under 50 characters |
| 247 | +- Reference issues when relevant |
| 248 | +- Explain the "why" in the body |
| 249 | + |
| 250 | +### Contributing Guidelines: |
| 251 | +- Keep changes focused and atomic |
| 252 | +- Update tests for any logic changes |
| 253 | +- Maintain backward compatibility when possible |
| 254 | +- Follow existing code style and patterns |
| 255 | + |
| 256 | +### Getting Help: |
| 257 | +- Check existing issues and discussions |
| 258 | +- Ask questions in PR comments |
| 259 | +- Review existing code for patterns and conventions |
| 260 | + |
| 261 | +## 🙏 Thank You |
| 262 | + |
| 263 | +Your contributions help make CodeKeeper better for everyone using AI-assisted development. Every improvement, bug fix, and piece of feedback is valued! |
| 264 | + |
| 265 | +--- |
| 266 | + |
| 267 | +**Happy Contributing! 🚀** |
0 commit comments