Skip to content

Commit 04080b1

Browse files
author
OneStepAt4time
committed
ci(console-guard): upgrade no-console to error + add baseline guard script (#4233)
- Upgrade eslint no-console rule from warn to error for src/ - Exclude all 34 existing violator files (tracked for future cleanup) - Add scripts/console-guard.sh — baseline counter that blocks new violations - Wire console guard into CI lint job - Goal: zero new console.* in production code; migrate existing to StructuredLogger
1 parent 232eea9 commit 04080b1

4 files changed

Lines changed: 95 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
run: npm run security-check
6565
- name: Run linter
6666
run: npm run lint
67+
- name: Console.* guard — block new console.log/warn/error in src/
68+
run: bash scripts/console-guard.sh
6769
feat-minor-bump-gate:
6870
if: github.event_name == 'pull_request'
6971
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ wt/
8484
coverage/
8585
wt-last-updated
8686
wt-i18n-sessionboard
87+
aegis

eslint.config.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,57 @@ export default [
2929
],
3030
},
3131
},
32+
// no-console: error for production src/ — existing violators are excluded so CI stays green.
33+
// Goal: shrink this list over time by migrating to StructuredLogger.
3234
{
3335
files: ['src/**/*.ts'],
34-
ignores: ['src/__tests__/**', 'src/cli.ts', 'src/logger.ts'],
36+
ignores: [
37+
'src/__tests__/**',
38+
// Core infra — logger, CLI, startup bootstrap
39+
'src/cli.ts',
40+
'src/logger.ts',
41+
'src/startup.ts',
42+
'src/suppress.ts',
43+
'src/tracing.ts',
44+
// Hooks & permissions
45+
'src/hooks.ts',
46+
'src/hook.ts',
47+
'src/permission-guard.ts',
48+
'src/permission-request-manager.ts',
49+
// Sessions
50+
'src/session.ts',
51+
'src/session-discovery.ts',
52+
'src/session-transcripts.ts',
53+
// ACP
54+
'src/services/acp/backend.ts',
55+
'src/services/auth/AuthManager.ts',
56+
'src/services/state/JsonFileStore.ts',
57+
// Channels
58+
'src/channels/email.ts',
59+
'src/channels/manager.ts',
60+
'src/channels/slack.ts',
61+
'src/channels/telegram.ts',
62+
'src/channels/webhook.ts',
63+
// Server & config
64+
'src/server.ts',
65+
'src/config.ts',
66+
'src/events.ts',
67+
// Memory & learnings
68+
'src/memory-bridge-learning.ts',
69+
'src/memory-bridge.ts',
70+
'src/structured-learnings.ts',
71+
// Misc
72+
'src/file-utils.ts',
73+
'src/jsonl-watcher.ts',
74+
'src/mcp/server.ts',
75+
'src/question-manager.ts',
76+
'src/signal-cleanup-helper.ts',
77+
'src/template-store.ts',
78+
'src/transcript.ts',
79+
'src/webhook/verify.ts',
80+
],
3581
rules: {
36-
'no-console': 'warn',
82+
'no-console': 'error',
3783
},
3884
},
3985
{

scripts/console-guard.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# console-guard.sh — CI guard: fail if production src/ adds new console.* calls
3+
# Existing exceptions are tracked in eslint.config.js ignores.
4+
# This script provides a second layer: a baseline count that must not increase.
5+
set -euo pipefail
6+
7+
cd "$(git rev-parse --show-toplevel 2>/dev/null || echo .)"
8+
9+
# Count console.* calls in non-test src/ (excluding comments)
10+
VIOLATIONS=$(grep -rn "console\.\(log\|warn\|error\)" src/ --include="*.ts" \
11+
| grep -v "node_modules" \
12+
| grep -v "__tests__" \
13+
| grep -v "^\s*//" \
14+
| grep -v "^\s*\*" \
15+
| wc -l)
16+
17+
BASELINE=165
18+
19+
echo "Console.* violations in src/: ${VIOLATIONS}"
20+
echo "Baseline: ${BASELINE}"
21+
22+
if [ "$VIOLATIONS" -gt "$BASELINE" ]; then
23+
DIFF=$((VIOLATIONS - BASELINE))
24+
echo ""
25+
echo "❌ FAIL: ${DIFF} new console.* call(s) detected in production code."
26+
echo " Use StructuredLogger instead, or add the file to eslint.config.js ignores."
27+
echo ""
28+
echo "New violations:"
29+
grep -rn "console\.\(log\|warn\|error\)" src/ --include="*.ts" \
30+
| grep -v "node_modules" \
31+
| grep -v "__tests__" \
32+
| grep -v "^\s*//" \
33+
| grep -v "^\s*\*" \
34+
| head -20
35+
exit 1
36+
fi
37+
38+
if [ "$VIOLATIONS" -lt "$BASELINE" ]; then
39+
DIFF=$((BASELINE - VIOLATIONS))
40+
echo "✅ PASS: ${DIFF} violation(s) removed since baseline — consider updating BASELINE in this script."
41+
fi
42+
43+
echo "✅ PASS: No new console.* violations."
44+
exit 0

0 commit comments

Comments
 (0)