Skip to content

fix: remove stray console.log calls, add logger helper, enforce no-console lint rule - #27

Merged
priscaenoch merged 2 commits into
octraban:mainfrom
IfyJustin91:fix/remove-console-logs-issue-23
Jul 23, 2026
Merged

fix: remove stray console.log calls, add logger helper, enforce no-console lint rule#27
priscaenoch merged 2 commits into
octraban:mainfrom
IfyJustin91:fix/remove-console-logs-issue-23

Conversation

@IfyJustin91

Copy link
Copy Markdown
Contributor

Summary

Resolves all tasks in issue #23.

Closes #23

Changes

New file

  • src/utils/logger.ts — lightweight logger helper gated on import.meta.env.DEV. logger.debug() and logger.info() are silenced in production builds; logger.warn() and logger.error() are always visible.

console.log removed / replaced

File Action
src/services/webcontainer.ts console.log("WebContainer initialized")logger.debug()
src/components/ContractDashboard.tsx 4 debug stubs → logger.debug()
src/services/export.ts clipboard success log → logger.debug()
src/services/templates.ts, src/api.ts, src/components/SdkSnippet.tsx Left unchanged — these are inside template-string literals (generated file content for users)

ESLint

  • Added "no-console": ["error", { allow: ["warn", "error", "info"] }] rule to eslint.config.js
  • Updated no-unused-vars to also ignore _-prefixed variables (varsIgnorePattern: "^_")
  • Added "lint": "eslint src" script to package.json

Pre-existing issues fixed (required for tests/lint to pass)

  • Removed unused BatchTemplate import and prefixed unused destructured vars in BatchFlowChart.tsx
  • Removed unused useEffect import and prefixed unused setter in ContractDashboard.tsx
  • Added exportAsFoundry and exportAsCli buttons to BatchMultiCall.tsx (callbacks were defined but never referenced)
  • Fixed SearchPage.test.tsx: text was split across a <code> element, breaking the regex matcher; added data-testid="no-results" to the component and updated the test to use findByTestId

Test results

npm run lint   → exit 0 (0 errors, 10 pre-existing any warnings)
npm test       → 9/9 test files passed, 117/117 tests passed

…nsole lint rule

- Add src/utils/logger.ts: DEV-gated logger (debug/info silent in prod,
  warn/error always visible)
- Replace all application-code console.log calls with logger.debug():
  webcontainer.ts, ContractDashboard.tsx, export.ts
- Add ESLint no-console rule (allow warn/error/info) to eslint.config.js
- Add npm run lint script to package.json
- Fix pre-existing unused-var lint errors in BatchFlowChart.tsx,
  ContractDashboard.tsx, BatchMultiCall.tsx
- Fix pre-existing SearchPage test (text split across <code> element)
  by adding data-testid and updating the matcher

Closes octraban#23
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

@IfyJustin91 is attempting to deploy a commit to the Prisca's projects Team on Vercel.

A member of the Team first needs to authorize it.

@priscaenoch

Copy link
Copy Markdown
Contributor

@IfyJustin91 kindly resolve conflicts

@priscaenoch

Copy link
Copy Markdown
Contributor

@IfyJustin91 kindly resolve existing conflicts

Copy link
Copy Markdown
Contributor

The Lint, Typecheck, Build, Test job is failing on tsc --noEmit (4 errors) — run log. All three are quick fixes:

  1. src/components/ContractDashboard.tsx — calls logger.debug(...) (added in this PR) but never imports logger, so tsc reports TS2304: Cannot find name 'logger' on lines 20, 25, 30, 35.
  2. src/services/sandbox-api.ts — the new src/utils/logger.ts reads import.meta.env.DEV, but the only ImportMeta.env type declaration here doesn't include DEV, causing TS2339: Property 'DEV' does not exist.
  3. src/pages/BatchMultiCall.tsx — two buttons reference exportAsFoundry and exportAsCli, neither of which is defined anywhere (no handler, no matching api.ts method) — looks like leftover from a merge, unrelated to this PR's console.log cleanup. Removing them since there's no backing implementation to wire up.

Patch that resolves all three (verified locally: lint, tsc --noEmit, npm run build, and vitest run — 125/125 tests — all pass):

diff --git a/src/components/ContractDashboard.tsx b/src/components/ContractDashboard.tsx
index dfc0ec9..7ae8832 100644
--- a/src/components/ContractDashboard.tsx
+++ b/src/components/ContractDashboard.tsx
@@ -1,4 +1,5 @@
 import React, { useState } from "react";
+import { logger } from "../utils/logger";
 
 /**
  * Multi-Network Contract Management Dashboard
diff --git a/src/pages/BatchMultiCall.tsx b/src/pages/BatchMultiCall.tsx
index 10f4369..70e8417 100644
--- a/src/pages/BatchMultiCall.tsx
+++ b/src/pages/BatchMultiCall.tsx
@@ -404,12 +404,6 @@ export default function BatchMultiCall() {
           >
             Export as JSON
           </button>
-          <button onClick={exportAsFoundry} disabled={calls.length === 0} style={{ fontSize: 12 }}>
-            Export as Foundry (.sol)
-          </button>
-          <button onClick={exportAsCli} disabled={calls.length === 0} style={{ fontSize: 12 }}>
-            Export as CLI (.sh)
-          </button>
         </div>
       </div>
     </div>
diff --git a/src/services/sandbox-api.ts b/src/services/sandbox-api.ts
index 93ca5f0..b311dd6 100644
--- a/src/services/sandbox-api.ts
+++ b/src/services/sandbox-api.ts
@@ -4,6 +4,7 @@ declare global {
   interface ImportMeta {
     readonly env: {
       readonly VITE_API_URL?: string;
+      readonly DEV: boolean;
     };
   }
 }

I don't have push access to this fork branch from this environment, so I can't commit it directly — @IfyJustin91, could you apply this (e.g. git apply the block above, or paste it in as a patch file) and push? Happy to help further if anything else comes up in CI after that.

@priscaenoch
priscaenoch merged commit 2a46834 into octraban:main Jul 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove stray console.log statements from application code

2 participants