Skip to content

Commit 9f0ec6d

Browse files
committed
feat: add console logs validation with Next.js auto-removal detection
- Add new check-console-logs.js validation script - Detects console.log, console.warn, console.error, etc. statements - Smart Next.js integration: skips validation if removeConsole is enabled - Supports allowed patterns: development conditions, ESLint disables, error logging - Includes comprehensive test fixtures for both violations and allowed usage - Integrates with existing test runner and CI/CD pipeline - Provides helpful suggestions for console.log alternatives This validation helps maintain clean production code by catching debug statements that developers often forget to remove before deployment.
1 parent ece42d1 commit 9f0ec6d

File tree

16 files changed

+1160
-17
lines changed

16 files changed

+1160
-17
lines changed

.github/actions/run-validation-tests/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ runs:
7474
"test:jsdoc"
7575
"test:complexity"
7676
"test:structure"
77+
"test:console-logs"
7778
)
7879
7980
for script in "${SCRIPTS[@]}"; do

.github/actions/validate-scripts/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ runs:
120120
"check-jsdoc.js"
121121
"check-file-complexity.js"
122122
"check-directory-structure.js"
123+
"check-console-logs.js"
123124
)
124125
125126
MISSING_SCRIPTS=()

.github/workflows/release-pr.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
pull_request:
66
types: [opened, synchronize, reopened]
77

8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
813
jobs:
914
check-if-release-pr:
1015
name: Check if Release PR

CONTRIBUTING.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ Enhancement suggestions are tracked as GitHub issues. When creating an enhanceme
2525

2626
### 🔧 Adding New Guardrails
2727

28-
Want to add a new validation script? Great! Here's how:
28+
Want to add a new validation rule? We have a comprehensive guide that covers the entire process!
2929

30+
📚 **[See the Complete Guide for Adding New Validation Rules](../docs/CONTRIBUTING-NEW-RULES.md)**
31+
32+
This guide covers:
33+
- Creating shared validators and standalone scripts
34+
- Setting up test infrastructure
35+
- ESLint plugin integration
36+
- GitHub Actions configuration
37+
- Documentation requirements
38+
- Example templates and best practices
39+
40+
For a quick overview:
3041
1. **Create the validation script** in `scripts/validation/`
31-
2. **Follow the existing pattern**:
32-
```javascript
33-
// check-your-rule.js
34-
const RULE_NAME = 'your-rule';
35-
const DEFAULT_OPTIONS = {
36-
// Your default configuration
37-
};
38-
39-
function validate(files, options = {}) {
40-
// Your validation logic
41-
}
42-
43-
module.exports = { validate, RULE_NAME };
44-
```
42+
2. **Follow the existing pattern** from other validation scripts
4543
3. **Add tests** for your guardrail
4644
4. **Update the documentation** in README.md
4745
5. **Add examples** in docs/EXAMPLES.md

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ We welcome contributions! Whether it's:
471471
2. Add test fixtures for new validation rules
472472
3. Update documentation if needed
473473

474-
See our [Contributing Guide](./CONTRIBUTING.md) for details.
474+
### 📚 Contributing Resources
475+
476+
- [Contributing Guide](./CONTRIBUTING.md) - General contribution guidelines
477+
- [Adding New Validation Rules](./docs/CONTRIBUTING-NEW-RULES.md) - Comprehensive step-by-step guide for adding new rules
478+
- [Examples](./docs/EXAMPLES.md) - Usage examples and patterns
475479

476480
## 📊 Stats & Community
477481

0 commit comments

Comments
 (0)