Skip to content

Commit 7142cbb

Browse files
authored
chore: enable noConsoleLog lint (coder#14329)
1 parent 2c150d0 commit 7142cbb

File tree

7 files changed

+33
-39
lines changed

7 files changed

+33
-39
lines changed

site/biome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"suspicious": {
1818
"noArrayIndexKey": { "level": "off" },
19+
"noConsoleLog": { "level": "error" },
1920
"noThenProperty": { "level": "off" }
2021
},
2122
"nursery": {

site/e2e/helpers.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,12 @@ export const startAgentWithCommand = async (
386386
},
387387
});
388388
cp.stdout.on("data", (data: Buffer) => {
389-
// eslint-disable-next-line no-console -- Log agent activity
390-
console.log(
389+
console.info(
391390
`[agent] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
392391
);
393392
});
394393
cp.stderr.on("data", (data: Buffer) => {
395-
// eslint-disable-next-line no-console -- Log agent activity
396-
console.log(
394+
console.info(
397395
`[agent] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
398396
);
399397
});

site/e2e/hooks.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ import type { BrowserContext, Page } from "@playwright/test";
33
import { coderPort, gitAuth } from "./constants";
44

55
export const beforeCoderTest = async (page: Page) => {
6-
// eslint-disable-next-line no-console -- Show everything that was printed with console.log()
7-
page.on("console", (msg) => console.log(`[onConsole] ${msg.text()}`));
6+
page.on("console", (msg) => console.info(`[onConsole] ${msg.text()}`));
87

98
page.on("request", (request) => {
109
if (!isApiCall(request.url())) {
1110
return;
1211
}
1312

14-
// eslint-disable-next-line no-console -- Log HTTP requests for debugging purposes
15-
console.log(
13+
console.info(
1614
`[onRequest] method=${request.method()} url=${request.url()} postData=${
1715
request.postData() ? request.postData() : ""
1816
}`,
@@ -40,8 +38,7 @@ export const beforeCoderTest = async (page: Page) => {
4038
responseText = "not_available";
4139
}
4240

43-
// eslint-disable-next-line no-console -- Log HTTP requests for debugging purposes
44-
console.log(
41+
console.info(
4542
`[onResponse] url=${response.url()} status=${response.status()} body=${responseText}`,
4643
);
4744
});

site/e2e/proxy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ export const startWorkspaceProxy = async (
1414
},
1515
});
1616
cp.stdout.on("data", (data: Buffer) => {
17-
// eslint-disable-next-line no-console -- Log wsproxy activity
18-
console.log(
17+
console.info(
1918
`[wsproxy] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
2019
);
2120
});
2221
cp.stderr.on("data", (data: Buffer) => {
23-
// eslint-disable-next-line no-console -- Log wsproxy activity
24-
console.log(
22+
console.info(
2523
`[wsproxy] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
2624
);
2725
});

site/e2e/reporter.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ class CoderReporter implements Reporter {
2323

2424
onBegin(config: FullConfig, suite: Suite) {
2525
this.config = config;
26-
console.log(`==> Running ${suite.allTests().length} tests`);
26+
console.info(`==> Running ${suite.allTests().length} tests`);
2727
}
2828

2929
onTestBegin(test: TestCase) {
3030
this.testOutput.set(test.id, []);
31-
console.log(`==> Starting test ${test.title}`);
31+
console.info(`==> Starting test ${test.title}`);
3232
}
3333

3434
onStdOut(chunk: string, test?: TestCase, _?: TestResult): void {
3535
// If there's no associated test, just print it now
3636
if (!test) {
3737
for (const line of logLines(chunk)) {
38-
console.log(`[stdout] ${line}`);
38+
console.info(`[stdout] ${line}`);
3939
}
4040
return;
4141
}
@@ -58,12 +58,12 @@ class CoderReporter implements Reporter {
5858
async onTestEnd(test: TestCase, result: TestResult) {
5959
try {
6060
if (test.expectedStatus === "skipped") {
61-
console.log(`==> Skipping test ${test.title}`);
61+
console.info(`==> Skipping test ${test.title}`);
6262
this.skippedCount++;
6363
return;
6464
}
6565

66-
console.log(`==> Finished test ${test.title}: ${result.status}`);
66+
console.info(`==> Finished test ${test.title}: ${result.status}`);
6767

6868
if (result.status === "passed") {
6969
this.passedCount++;
@@ -82,24 +82,24 @@ class CoderReporter implements Reporter {
8282
const outputFile = `test-results/debug-pprof-goroutine-${fsTestTitle}.txt`;
8383
await exportDebugPprof(outputFile);
8484

85-
console.log(`Data from pprof has been saved to ${outputFile}`);
86-
console.log("==> Output");
85+
console.info(`Data from pprof has been saved to ${outputFile}`);
86+
console.info("==> Output");
8787
const output = this.testOutput.get(test.id)!;
8888
for (const [target, chunk] of output) {
8989
target.write(`${chunk.replace(/\n$/g, "")}\n`);
9090
}
9191

9292
if (result.errors.length > 0) {
93-
console.log("==> Errors");
93+
console.info("==> Errors");
9494
for (const error of result.errors) {
9595
reportError(error);
9696
}
9797
}
9898

9999
if (result.attachments.length > 0) {
100-
console.log("==> Attachments");
100+
console.info("==> Attachments");
101101
for (const attachment of result.attachments) {
102-
console.log(attachment);
102+
console.info(attachment);
103103
}
104104
}
105105
} finally {
@@ -108,26 +108,26 @@ class CoderReporter implements Reporter {
108108
}
109109

110110
onEnd(result: FullResult) {
111-
console.log(`==> Tests ${result.status}`);
111+
console.info(`==> Tests ${result.status}`);
112112
if (!enterpriseLicense) {
113-
console.log(
113+
console.info(
114114
"==> Enterprise tests were skipped, because no license was provided",
115115
);
116116
}
117-
console.log(`${this.passedCount} passed`);
117+
console.info(`${this.passedCount} passed`);
118118
if (this.skippedCount > 0) {
119-
console.log(`${this.skippedCount} skipped`);
119+
console.info(`${this.skippedCount} skipped`);
120120
}
121121
if (this.failedTests.length > 0) {
122-
console.log(`${this.failedTests.length} failed`);
122+
console.info(`${this.failedTests.length} failed`);
123123
for (const test of this.failedTests) {
124-
console.log(` ${test.location.file}${test.title}`);
124+
console.info(` ${test.location.file}${test.title}`);
125125
}
126126
}
127127
if (this.timedOutTests.length > 0) {
128-
console.log(`${this.timedOutTests.length} timed out`);
128+
console.info(`${this.timedOutTests.length} timed out`);
129129
for (const test of this.timedOutTests) {
130-
console.log(` ${test.location.file}${test.title}`);
130+
console.info(` ${test.location.file}${test.title}`);
131131
}
132132
}
133133
}
@@ -157,16 +157,16 @@ const exportDebugPprof = async (outputFile: string) => {
157157

158158
const reportError = (error: TestError) => {
159159
if (error.location) {
160-
console.log(`${error.location.file}:${error.location.line}:`);
160+
console.info(`${error.location.file}:${error.location.line}:`);
161161
}
162162
if (error.snippet) {
163-
console.log(error.snippet);
163+
console.info(error.snippet);
164164
}
165165

166166
if (error.message) {
167-
console.log(error.message);
167+
console.info(error.message);
168168
} else {
169-
console.log(error);
169+
console.info(error);
170170
}
171171
};
172172

site/e2e/tests/webTerminal.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test("web terminal", async ({ context, page }) => {
6363
} catch (error) {
6464
const pageContent = await terminal.content();
6565
// eslint-disable-next-line no-console -- Let's see what is inside of xterm-rows
66-
console.log("Unable to find echoed text:", pageContent);
66+
console.error("Unable to find echoed text:", pageContent);
6767
throw error;
6868
}
6969

site/src/contexts/useProxyLatency.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ export const useProxyLatency = (
162162
} else {
163163
// This is the total duration of the request and will be off by a good margin.
164164
// This is a fallback if the better timing is not available.
165-
// eslint-disable-next-line no-console -- We can remove this when we display the "accurate" bool on the UI
166-
console.log(
165+
// We can remove this when we display the "accurate" bool on the UI
166+
console.warn(
167167
`Using fallback latency calculation for "${entry.name}". Latency will be incorrect and larger then actual.`,
168168
);
169169
latencyMS = entry.duration;

0 commit comments

Comments
 (0)