Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: enable noConsoleLog lint #14329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions site/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"suspicious": {
"noArrayIndexKey": { "level": "off" },
"noConsoleLog": { "level": "error" },
"noThenProperty": { "level": "off" }
},
"nursery": {
Expand Down
6 changes: 2 additions & 4 deletions site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,12 @@ export const startAgentWithCommand = async (
},
});
cp.stdout.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log agent activity
console.log(
console.info(
`[agent] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
);
});
cp.stderr.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log agent activity
console.log(
console.info(
`[agent] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
);
});
Expand Down
9 changes: 3 additions & 6 deletions site/e2e/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import type { BrowserContext, Page } from "@playwright/test";
import { coderPort, gitAuth } from "./constants";

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

page.on("request", (request) => {
if (!isApiCall(request.url())) {
return;
}

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

// eslint-disable-next-line no-console -- Log HTTP requests for debugging purposes
console.log(
console.info(
`[onResponse] url=${response.url()} status=${response.status()} body=${responseText}`,
);
});
Expand Down
6 changes: 2 additions & 4 deletions site/e2e/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ export const startWorkspaceProxy = async (
},
});
cp.stdout.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log wsproxy activity
console.log(
console.info(
`[wsproxy] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
);
});
cp.stderr.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log wsproxy activity
console.log(
console.info(
`[wsproxy] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
);
});
Expand Down
44 changes: 22 additions & 22 deletions site/e2e/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class CoderReporter implements Reporter {

onBegin(config: FullConfig, suite: Suite) {
this.config = config;
console.log(`==> Running ${suite.allTests().length} tests`);
console.info(`==> Running ${suite.allTests().length} tests`);
}

onTestBegin(test: TestCase) {
this.testOutput.set(test.id, []);
console.log(`==> Starting test ${test.title}`);
console.info(`==> Starting test ${test.title}`);
}

onStdOut(chunk: string, test?: TestCase, _?: TestResult): void {
// If there's no associated test, just print it now
if (!test) {
for (const line of logLines(chunk)) {
console.log(`[stdout] ${line}`);
console.info(`[stdout] ${line}`);
}
return;
}
Expand All @@ -58,12 +58,12 @@ class CoderReporter implements Reporter {
async onTestEnd(test: TestCase, result: TestResult) {
try {
if (test.expectedStatus === "skipped") {
console.log(`==> Skipping test ${test.title}`);
console.info(`==> Skipping test ${test.title}`);
this.skippedCount++;
return;
}

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

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

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

if (result.errors.length > 0) {
console.log("==> Errors");
console.info("==> Errors");
for (const error of result.errors) {
reportError(error);
}
}

if (result.attachments.length > 0) {
console.log("==> Attachments");
console.info("==> Attachments");
for (const attachment of result.attachments) {
console.log(attachment);
console.info(attachment);
}
}
} finally {
Expand All @@ -108,26 +108,26 @@ class CoderReporter implements Reporter {
}

onEnd(result: FullResult) {
console.log(`==> Tests ${result.status}`);
console.info(`==> Tests ${result.status}`);
if (!enterpriseLicense) {
console.log(
console.info(
"==> Enterprise tests were skipped, because no license was provided",
);
}
console.log(`${this.passedCount} passed`);
console.info(`${this.passedCount} passed`);
if (this.skippedCount > 0) {
console.log(`${this.skippedCount} skipped`);
console.info(`${this.skippedCount} skipped`);
}
if (this.failedTests.length > 0) {
console.log(`${this.failedTests.length} failed`);
console.info(`${this.failedTests.length} failed`);
for (const test of this.failedTests) {
console.log(` ${test.location.file} › ${test.title}`);
console.info(` ${test.location.file} › ${test.title}`);
}
}
if (this.timedOutTests.length > 0) {
console.log(`${this.timedOutTests.length} timed out`);
console.info(`${this.timedOutTests.length} timed out`);
for (const test of this.timedOutTests) {
console.log(` ${test.location.file} › ${test.title}`);
console.info(` ${test.location.file} › ${test.title}`);
}
}
}
Expand Down Expand Up @@ -157,16 +157,16 @@ const exportDebugPprof = async (outputFile: string) => {

const reportError = (error: TestError) => {
if (error.location) {
console.log(`${error.location.file}:${error.location.line}:`);
console.info(`${error.location.file}:${error.location.line}:`);
}
if (error.snippet) {
console.log(error.snippet);
console.info(error.snippet);
}

if (error.message) {
console.log(error.message);
console.info(error.message);
} else {
console.log(error);
console.info(error);
}
};

Expand Down
2 changes: 1 addition & 1 deletion site/e2e/tests/webTerminal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test("web terminal", async ({ context, page }) => {
} catch (error) {
const pageContent = await terminal.content();
// eslint-disable-next-line no-console -- Let's see what is inside of xterm-rows
console.log("Unable to find echoed text:", pageContent);
console.error("Unable to find echoed text:", pageContent);
throw error;
}

Expand Down
4 changes: 2 additions & 2 deletions site/src/contexts/useProxyLatency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export const useProxyLatency = (
} else {
// This is the total duration of the request and will be off by a good margin.
// This is a fallback if the better timing is not available.
// eslint-disable-next-line no-console -- We can remove this when we display the "accurate" bool on the UI
console.log(
// We can remove this when we display the "accurate" bool on the UI
console.warn(
`Using fallback latency calculation for "${entry.name}". Latency will be incorrect and larger then actual.`,
);
latencyMS = entry.duration;
Expand Down
Loading