Skip to content

Commit 9dc14f0

Browse files
committed
chore(lint): ban console in runtime code with Biome noConsole
Runtime code logs through createLogger from @sim/logger. Scripts, CLIs, script-migrations, the logger itself, SDK examples, and tests keep console as their interface. Autofix is disabled so lint --unsafe never silently deletes a console call.
1 parent 70412cc commit 9dc14f0

9 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎apps/docs/app/api/search/route.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { createLogger } from '@sim/logger'
12
import { sql } from 'drizzle-orm'
23
import { type NextRequest, NextResponse } from 'next/server'
34
import { db, docsEmbeddings } from '@/lib/db'
45
import { generateSearchEmbedding } from '@/lib/embeddings'
56

7+
const logger = createLogger('DocsSearchAPI')
8+
69
export const runtime = 'nodejs'
710
export const revalidate = 0
811

@@ -196,7 +199,7 @@ export async function GET(request: NextRequest) {
196199

197200
return NextResponse.json(searchResults)
198201
} catch (error) {
199-
console.error('Semantic search error:', error)
202+
logger.error('Semantic search error:', error)
200203

201204
return NextResponse.json([])
202205
}

‎apps/docs/app/llms-full.txt/route.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import { getLLMText } from '@/lib/llms'
23
import { source } from '@/lib/source'
34

5+
const logger = createLogger('DocsLlmsFullText')
6+
47
export const revalidate = false
58

69
export async function GET() {
@@ -18,7 +21,7 @@ export async function GET() {
1821
},
1922
})
2023
} catch (error) {
21-
console.error('Error generating LLM full text:', error)
24+
logger.error('Error generating LLM full text:', error)
2225
return new Response('Error generating full documentation text', { status: 500 })
2326
}
2427
}

‎apps/docs/app/llms.txt/route.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import { source } from '@/lib/source'
23
import { DOCS_BASE_URL } from '@/lib/urls'
34

5+
const logger = createLogger('DocsLlmsManifest')
6+
47
export const revalidate = false
58

69
export async function GET() {
@@ -70,7 +73,7 @@ See: https://llmstxt.org for specification`
7073
},
7174
})
7275
} catch (error) {
73-
console.error('Error generating LLM manifest:', error)
76+
logger.error('Error generating LLM manifest:', error)
7477
return new Response('Error generating documentation manifest', { status: 500 })
7578
}
7679
}

‎apps/docs/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"@sim/db": "workspace:*",
2222
"@sim/emcn": "workspace:*",
23+
"@sim/logger": "workspace:*",
2324
"@sim/utils": "workspace:*",
2425
"@sim/workflow-renderer": "workspace:*",
2526
"@xyflow/react": "12.11.3",

‎apps/sim/app/_shell/hydration-error-handler.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function isRadixIdMismatch(args: unknown[]): boolean {
3333
*/
3434
export function HydrationErrorHandler() {
3535
useEffect(() => {
36+
// biome-ignore lint/suspicious/noConsole: wraps console.error itself to filter extension hydration noise
3637
const originalError = console.error
3738
console.error = (...args) => {
3839
if (typeof args[0] === 'string' && args[0].includes('Hydration')) {

‎apps/sim/instrumentation-node.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ async function initializeOpenTelemetry() {
259259
exporter.export = (spans, resultCallback) => {
260260
origExport(spans, (result) => {
261261
if (result?.code !== 0) {
262-
// eslint-disable-next-line no-console
263-
console.error('[OTEL] exporter export failed', {
262+
logger.error('Exporter export failed', {
264263
endpoint: telemetryConfig.endpoint,
265264
resultCode: result?.code,
266265
error: result?.error?.message,

‎biome.json‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
"noControlCharactersInRegex": "off",
101101
"noThenProperty": "off",
102102
"noAssignInExpressions": "off",
103-
"noDocumentCookie": "off"
103+
"noDocumentCookie": "off",
104+
"noConsole": { "level": "error", "fix": "none" }
104105
},
105106
"correctness": {
106107
"useExhaustiveDependencies": "off",
@@ -155,6 +156,21 @@
155156
"includes": ["apps/sim/app/_styles/tailwind.css"],
156157
"linter": { "enabled": false },
157158
"formatter": { "enabled": false }
159+
},
160+
{
161+
"includes": [
162+
"**/scripts/**",
163+
"**/*.test.ts",
164+
"**/*.test.tsx",
165+
"apps/sim/vitest.setup.ts",
166+
"packages/cli/**",
167+
"packages/sim-cli/**",
168+
"packages/sim-setup/**",
169+
"packages/db/script-migrations/**",
170+
"packages/logger/src/**",
171+
"packages/ts-sdk/examples/**"
172+
],
173+
"linter": { "rules": { "suspicious": { "noConsole": "off" } } }
158174
}
159175
],
160176
"javascript": {

‎bun.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/testing/src/environment/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function toolGuard(label: string, detect: () => { ok: boolean; hint: string }):
3131
}
3232
if (!warned) {
3333
warned = true
34+
// biome-ignore lint/suspicious/noConsole: a skipped suite must tell the test runner's console why
3435
console.warn(`[@sim/testing] Skipping tests that require ${label}. ${result.hint}`)
3536
}
3637
return false

0 commit comments

Comments
 (0)