This checklist ensures complete integration of new validation rules across CodeKeeper's dual architecture (standalone scripts + ESLint plugin).
File: lib/validators/{rule-name}.js
- Export validation patterns/configurations
- Export main validation function that returns
{ violations, skipped, reason } - Include framework-specific checks (Next.js, React, etc.)
- Add proper JSDoc documentation
Example structure:
module.exports = {
PATTERNS,
EXCLUDE_PATHS,
findViolations,
checkFrameworkConfig
}File: scripts/validation/check-{rule-name}.js
- Add shebang line:
#!/usr/bin/env node - Include comprehensive file header with description
- Add configuration section:
// ============================================================================
// CONFIGURATION - Customize these settings for your project
// ============================================================================- Import shared validator from
../../lib/validators/{rule-name}.js - Implement file discovery logic
- Add colored console output with proper exit codes
- Include helpful suggestions in error messages
- Export functions for testing:
module.exports = { ... } - Add conditional execution:
if (require.main === module) { main() } - Make executable:
chmod +x scripts/validation/check-{rule-name}.js
Directory: tests/fixtures/{rule-name}/
- File:
bad-{rule-name}.{ext}- Contains violations (fails validation) - File:
good-{rule-name}.{ext}- No violations (passes validation) - Include realistic, representative code examples
- Cover edge cases and allowed patterns
File: tests/test-runner.js
- Add new test configuration to TESTS object:
'check-{rule-name}': {
shouldFail: ['tests/fixtures/{rule-name}/bad-{rule-name}.{ext}'],
shouldPass: ['tests/fixtures/{rule-name}/good-{rule-name}.{ext}'],
expectedViolations: N, // Number of violations in bad file
}File: package.json
- Add script:
"test:{rule-name}": "node scripts/validation/check-{rule-name}.js tests/fixtures/{rule-name}/bad-{rule-name}.{ext}" - Verify script works:
npm run test:{rule-name}
File: eslint-plugin-codekeeper/rules/{rule-name}.js
- Import shared validator:
require('../lib/validators/{rule-name}') - Define rule metadata (type, docs, schema, messages)
- Implement
create(context)function - Handle framework-specific logic (Next.js detection, etc.)
- Use proper ESLint context methods (
getSourceCode(),getFilename()) - Report violations with
context.report()
File: eslint-plugin-codekeeper/index.js
- Import new rule:
const {ruleName} = require('./rules/{rule-name}') - Add to rules object:
'{rule-name}': {ruleName} - Add to recommended config with appropriate severity
- Add to strict config (usually 'error')
- Add to react config with framework-specific options
Command: cp lib/validators/{rule-name}.js eslint-plugin-codekeeper/lib/validators/
- Copy shared validator to ESLint plugin directory
- Verify paths resolve correctly
File: test-validation/test-eslint-plugin.js
- Import rule:
const {ruleName} = require('../eslint-plugin-codekeeper/rules/{rule-name}') - Add fixture:
'{rule-name}.{ext}': fs.readFileSync(path.join(__dirname, '../tests/fixtures/{rule-name}/bad-{rule-name}.{ext}'), 'utf8') - Add test case:
total++;
if (testRule('{rule-name}', {ruleName}, 'tests/fixtures/{rule-name}/bad-{rule-name}.{ext}', fixtures['{rule-name}.{ext}'])) {
passed++;
}File: .github/actions/run-validation-tests/action.yml
- Add
"test:{rule-name}"to SCRIPTS array in comprehensive validation step
File: .github/actions/validate-scripts/action.yml
- Add
"check-{rule-name}.js"to EXPECTED_SCRIPTS array
File: README.md
- Add new script to the validation scripts table:
| Script | Purpose | Example |
|---|---|---|
check-{rule-name}.js |
Brief description of what it validates | node scripts/validation/check-{rule-name}.js |
- Add standalone usage example:
# Check specific file
node scripts/validation/check-{rule-name}.js src/components/MyComponent.tsx
# Check all files
node scripts/validation/check-{rule-name}.js --all- Add rule to the ESLint rules table:
| Rule | Description | Severity | Fixable |
|---|---|---|---|
codekeeper/{rule-name} |
Brief description | warn/error | ❌/✅ |
- Add ESLint configuration example:
// .eslintrc.js
module.exports = {
plugins: ['@thedaviddias/codekeeper'],
rules: {
'codekeeper/{rule-name}': ['warn', {
// rule-specific options
}]
}
}- Add detailed section for the new rule:
- Brief bullet points of violations detected
- Explanation of the problem this solves
- Impact on code quality/performance/maintainability
// Example of code that violates the rule// Example of compliant code- Document any customizable options
- Include default values
- Next.js considerations (if applicable)
- React-specific handling (if applicable)
- Other framework notes
File: eslint-plugin-codekeeper/README.md
- Add rule to rules list with description
- Include configuration examples
- Add to configuration presets documentation
- Update rule count in overview section
Files: examples/*/README.md
- Add new script to available commands
- Include integration examples
- Update any relevant setup instructions
- Syntax check:
node -c scripts/validation/check-{rule-name}.js - Configuration section:
grep -q "CONFIGURATION.*Customize these settings" scripts/validation/check-{rule-name}.js - Executable permission:
ls -la scripts/validation/check-{rule-name}.js(should show x permission) - npm script exists:
grep -q "test:{rule-name}" package.json
- Standalone script with bad file:
npm run test:{rule-name}(should exit with code 1) - Standalone script with good file:
node scripts/validation/check-{rule-name}.js tests/fixtures/{rule-name}/good-{rule-name}.{ext}(should exit with code 0) - Test runner:
npm test(should include new rule and pass) - ESLint plugin:
node test-validation/test-eslint-plugin.js(should detect violations)
- CI validation: All GitHub Actions composite actions work
- Script discovery: New script appears in validation workflows
- ESLint configs: Rule appears in recommended/strict/react presets
- Documentation: Rule behavior matches expected patterns
- Links work: All internal documentation links are valid
- Examples run: Code examples in README can be executed
- Consistency: Terminology and formatting match existing docs
- Completeness: All major use cases are documented
Directories: examples/nextjs-lefthook-example/, examples/react-husky-example/
- Scripts will be auto-synced by GitHub Actions workflow
- Verify examples work after sync: check CI workflows
- Document rule options in ESLint plugin README
- Add usage examples for different severity levels
- Include framework-specific configuration notes
- Use conventional commit:
feat: add {rule-name} validation - Describe feature benefits and use cases
- Include breaking changes if any
- Validators sync: Ensure sync-validators.yml will trigger correctly
- ESLint plugin: Rule included in automatic publishing
- Examples sync: Auto-sync workflows include new script
- Changelog: Ensure rule is documented in release notes
- Migration guide: Include any breaking changes or migration steps
- Feature highlights: Emphasize key benefits and use cases
| Phase | File | Action |
|---|---|---|
| Core | lib/validators/{rule-name}.js | Create shared validator |
| Core | scripts/validation/check-{rule-name}.js | Create standalone script |
| Test | tests/fixtures/{rule-name}/bad-{rule-name}.{ext} | Create violation test case |
| Test | tests/fixtures/{rule-name}/good-{rule-name}.{ext} | Create passing test case |
| Test | tests/test-runner.js | Add test configuration |
| Test | package.json | Add npm test script |
| ESLint | eslint-plugin-codekeeper/rules/{rule-name}.js | Create ESLint rule |
| ESLint | eslint-plugin-codekeeper/index.js | Register rule & configs |
| ESLint | eslint-plugin-codekeeper/lib/validators/{rule-name}.js | Copy shared validator |
| ESLint | test-validation/test-eslint-plugin.js | Add ESLint test |
| CI | .github/actions/run-validation-tests/action.yml | Add to test scripts |
| CI | .github/actions/validate-scripts/action.yml | Add to expected scripts |
| 📚 Docs | README.md | Add rule documentation, examples, and configuration |
| 📚 Docs | eslint-plugin-codekeeper/README.md | Add ESLint-specific docs |
| 📚 Docs | examples/*/README.md | Update example documentation |
- Start with test fixtures - Write your bad/good examples first to clarify expected behavior
- Use existing patterns - Copy structure from check-as-casts.js for consistency
- Test early and often - Run npm test after each major step
- Framework awareness - Consider Next.js, React, and other framework-specific behaviors
- Error messages matter - Provide actionable suggestions, not just "violation found"
- Conventional commits - Use feat: prefix to trigger minor version bump in release-please
- 📝 Documentation first - Write the README sections before implementing to clarify the feature scope
- 🔗 Cross-reference examples - Ensure code examples in docs actually work with your implementation
- 🎯 User perspective - Write documentation from the user's perspective, not the implementer's
- List of specific violations
- Edge cases handled
- Framework-specific behaviors
Brief explanation of the problem and its impact.
// Code that violates the rule// Compliant code- option1: Description (default: value)
- option2: Description (default: value)
- Next.js: Automatic detection of removeConsole configuration
- React: Component-specific validation rules
This comprehensive checklist ensures your new validation rule is fully integrated, tested, and documented across the entire CodeKeeper ecosystem! 🎉