You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reorganize the debugging documentation based on feedback:
- Move ESLint rules to the top as the recommended approach
- Add IDE search as a secondary option
- Keep stack trace method as temporary debugging technique
- Add warning notes about removing overrides after use
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Copy file name to clipboardExpand all lines: packages/docs/src/routes/docs/(qwikcity)/guides/debugging/index.mdx
+33-31Lines changed: 33 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,38 @@ Under the hood [launch-editor library](https://github.com/yyx990803/launch-edito
25
25
26
26
When working on larger codebases, you might occasionally leave `console.log` statements in your code unintentionally. These can clutter your terminal output, and it's often difficult to identify which file and line number produced each log message.
27
27
28
-
### Using stack traces in client-side components
28
+
### Using ESLint rules
29
+
30
+
The recommended approach is to configure ESLint to prevent `console.log` statements from being committed:
This will catch `console.log` statements during development, preventing them from being committed.
44
+
45
+
### Using IDE search
46
+
47
+
Most IDEs provide powerful search functionality to find all occurrences of `console.log` across your codebase:
48
+
-**VS Code**: Press `Ctrl+Shift+F` (or `Cmd+Shift+F` on Mac) and search for `console\.log`
49
+
-**Enable regex mode** to match only exact `console.log` calls and not `console.error` or `console.warn`
50
+
51
+
This approach is simple but requires manual review of each occurrence to determine if it's intentional or leftover debug code.
52
+
53
+
### Using stack traces (temporary debugging)
54
+
55
+
If you need to identify existing leftover console.logs in a codebase that's already cluttered, you can temporarily override `console.log` to include stack traces.
56
+
57
+
#### In client-side components
29
58
30
-
You can override `console.log`to include stack trace information in your component code. For example, in your root component or a layout component:
59
+
You can override `console.log` in your component code:
Now when you call `console.log("something")`, you'll see the stack trace pointing to the exact location where the log was called, making it much easier to locate and remove leftover debug statements.
53
-
54
-
### Using stack traces in server-side entry files
81
+
#### In server-side entry files
55
82
56
83
For entry files like `entry.express.tsx`, `entry.dev.tsx`, or `entry.preview.tsx`, you can override `console.log` at the module level:
> **Note:** The filter regex should be adjusted based on your specific build setup. Common patterns to filter out include `.vite`, `.main.jsx`, `node_modules`, and `internal` paths.
74
-
75
-
### Using ESLint rules
76
-
77
-
You can configure ESLint to warn or error on `console.log` statements in production code:
0 commit comments