Skip to content

Commit 09820b6

Browse files
Claudeclaude
authored andcommitted
fix: allowlist CLI commands in no-console-log test
telemetry.ts is a CLI command that correctly uses console.log for user-facing output, not MCP stdio. Added allowlist for commands/ files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f4d1468 commit 09820b6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/unit/no-console-log.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ function collectTsFiles(dir: string): string[] {
2828
return results;
2929
}
3030

31+
// CLI commands run outside MCP stdio transport — console.log is correct there
32+
const CLI_COMMAND_ALLOWLIST = new Set([
33+
"src/commands/telemetry.ts",
34+
]);
35+
3136
describe("no console.log in src/", () => {
3237
const srcDir = join(__dirname, "../../src");
3338
const files = collectTsFiles(srcDir);
@@ -36,18 +41,21 @@ describe("no console.log in src/", () => {
3641
expect(files.length).toBeGreaterThan(0);
3742
});
3843

39-
it("should not contain console.log in any src/ file", () => {
44+
it("should not contain console.log in any src/ file (except CLI commands)", () => {
4045
const violations: string[] = [];
4146

4247
for (const file of files) {
48+
const relative = file.replace(srcDir, "src");
49+
// CLI commands use stdout directly — not MCP stdio
50+
if (CLI_COMMAND_ALLOWLIST.has(relative)) continue;
51+
4352
const content = readFileSync(file, "utf-8");
4453
const lines = content.split("\n");
4554
for (let i = 0; i < lines.length; i++) {
4655
const line = lines[i];
4756
// Skip comments
4857
if (line.trimStart().startsWith("//") || line.trimStart().startsWith("*")) continue;
4958
if (line.includes("console.log")) {
50-
const relative = file.replace(srcDir, "src");
5159
violations.push(`${relative}:${i + 1}: ${line.trim()}`);
5260
}
5361
}

0 commit comments

Comments
 (0)