Skip to content

Commit 3b1b2f2

Browse files
ci(console-guard): upgrade no-console to error + baseline guard (#4233)
eslint no-console warn→error with 30 existing violator exclusions. console-guard.sh baseline script (165). .gitignore addition.
1 parent ae61ac6 commit 3b1b2f2

4 files changed

Lines changed: 86 additions & 5 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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,20 @@ docs/superpowers/
5757
.omc/
5858
competitors/
5959
_competitors/
60-
6160
# Ad-hoc analysis/report artifacts (not published)
6261
docs/*-analysis-20??-??-??.md
6362
docs/*-report-20??-??-??.md
6463
*-analysis-20??-??-??.md
6564
*-report-20??-??-??.md
66-
6765
# TypeDoc API reference (generated, served via GitHub Pages)
6866
docs/api/
6967
keys.env
7068
tracked.txt
71-
7269
# Dashboard icon audit output (reporter, regenerated on demand)
7370
scripts/dashboard-icons-audit.current.txt
74-
7571
# Local memory / vibe files and release tarballs
7672
memory/
7773
*.tgz
78-
7974
# Test artifacts (leaked in 996feb8)
8075
/.test-scratch/
8176
playwright-report/
@@ -85,3 +80,4 @@ coverage/
8580
wt-last-updated
8681
wt-i18n-sessionboard
8782
node_modules
83+
aegis

eslint.config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,54 @@ 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'],
3436
ignores: [
3537
'src/__tests__/**',
38+
// Core infra — logger, CLI, startup bootstrap
3639
'src/cli.ts',
3740
'src/logger.ts',
41+
'src/startup.ts',
3842
'src/suppress.ts',
43+
'src/tracing.ts',
44+
// Hooks & permissions
45+
'src/hooks.ts',
3946
'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',
4074
'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',
4180
],
4281
rules: {
4382
'no-console': 'error',

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)