[📖] Please provide a section about what is your recommendation to find useless console.logs
Suggestion
Using console.log seems to be common. Yet it has a downside. Sometimes it's left unintentionally in the code.
When the codebase becomes bigger, then a terminal is littered with logs, but the file and line of code that made that log are not apparent.
One technique that we use is to override console.log to include the stack trace too:
const originalLog = console.log
console.log = props => {
const stack = new Error()
.stack
.split("\n")
.filter(i => !/^.*(\.vite|keycloak|\.main\.jsx).*/.test(i))
originalLog(stack, props)
}
Try console.log("something") and you will see a good stack helping you find the place of the left log.
This works when we put it inside a component. But when we want to put it inside the entry.express or entry.dev or entry.preview, then it has no effect.
Please add a section to the documentation explaining your official way of finding useless console.log statements.
I guess you could try something similar to this? https://nuxt.com/docs/api/kit/logging
This is not a priority right now to add such a route to the docs so PR very welcome 🍻
why not simply enable the eslint rule? Not sure such a general recommendation belongs in the qwik docs
@wmertens, the eslint rule is not effective in this case. We want to keep some of the console.logs and remove others. We need to know what text comes from which console.log. That's effective.
Hi! I'd like to try working on this issue if possible. Would it be okay to assign it to me? Thank you!