-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
console.json #46689
Comments
You can change the default inspection depth by setting |
Since We could maybe coerce the eslint core team into making console.json a production build no-no, kind of like how console.log is these days anyway. Just thinking out loud on risk mitigation for performance hits in production from this. I just keep thinking about the utility as a developer - would be so handy in 2023. |
Console methods adhere to a standard and thus, it's not possible to add that helper. And the overall goal would ideally be the solution mentioned above. That would as such also resolve your request, if I am not mistaken. |
|
This is basically a wontfix, right? I'll go ahead and close it as such. |
I wonder if these types of threads are why projects like Deno and Bun.sh are skyrocketing in popularity so quickly? Standards are good and have their place, but when they become the default fallback that we blame for lack of innovation or shipping features that are just plain cool/useful, standards loose their luster rapidly. Guess Node.js maintainers aren't really interested in building/shipping product features that average developers would love and be excited about even if they draw outside the lines of "standards" occasionally? Sad. |
@wmelton have you considered opening an issue at https://github.com/whatwg/console/issues? FWIW, I agree with some of what you've said, and disagree with other parts. |
@cjihrig I haven't. Feels like starting at the top of a long bureaucratic chain to get a really cool/useful feature shipped is the wrong path for projects that want to stay competitive/relevant. Anyway - not gonna keep wasting your alls time. Thanks for entertaining my offer to commit a cool feature. Sorry to hear the decision making processes are structured to overly value what they do. I love JavaScript/TypeScript deeply. Hope more long-term, competitive decision making starts being had amongst the node.js crew. I don't imagine many people will feel a lot of loyalty lost to start typing |
@wmelton it's that Colin already replied to you, otherwise I'd have hidden your comments as off-topic rants. Save it for twitter, it's not welcome here. |
@cjihrig for what its worth, I did open a thread over at whatwg but as I suspected, likely a long battle convincing folks of what seems obviously hugely helpful and different than what's available: whatwg/console#222 @bnoordhuis criticism and rants are very different. Only those with mindsets oriented towards success can be bothered to receive the first without unhelpfully categorizing them as the latter. |
@wmelton why doesn't this work for you? This seems like the solution for your problem. I use this trick often myself. IMO this solution is favorable, too, as the syntax highlighting of objects is more distinctive than that of JSON. |
@paulirish reasonable question. I think some of my examples given in the whatwg issue I opened help drive at why, but to recap:
If I came across as a jerk earlier in this thread, I apologize. Very passionate developer and avid js/node fan. It was admittedly frustrating to feel like my proposal was discarded so quickly without a lot of thought or discussion. I think this would be a dope feature to roll out. Not sure whatwg is going to add this to their standard though, so not sure where this all leaves us since whatwg is looping us back here. Thanks again for hearing me out. |
Bumping this thread in case there's any interest in pursuing this any further. |
@paulirish how do you handle that config universally across all repositories/projects? How do you handle dealing with other companies gnarly nested objects? Genuinely seeking to understand. |
What is the problem this feature will solve?
Working with objects and arrays during node.js development can be a bit bothersome when needing to introspect a nested object, some REST-API response you're consuming, or intermediary DTOs, etc. I know I'm beating an old drum here, but when calling
console.log(<object>)
in hopes of seeing what we're working with, getting[object Object]
in the console is less than helpful.If you're lucky you may see the top level props, but are left with the lower level bits as still masked, e.g.
{ prop: { someChildPRop: [object Object] }}
While I'm sure there are age old reasons for all of this that are logical, from a developer experience and productivity perspective this is less than ideal.
What is the feature you are proposing to solve the problem?
An excellent alternative would be
console.json(<JSON-serializable>)
that essentially performs the same action thatconsole.log(JSON.stringify(<serializable>, null, 2))
would perform. Perhapspretty
printing is an option flag, but regardless, having written this exact line of code 10k times in my life, console.json would be a breath of fresh air.I'm happy to open a PR on this and do the leg work to make it happen if we can get buy-in to get it across the finish line. Feels like a low-risk feature that has a lot of developer productivity upside.
What alternatives have you considered?
I've considered continuing to write
console.log(JSON.stringify(<JSON-serializable>, null, 2))
the rest of my life, and it makes me feel very sad inside.The text was updated successfully, but these errors were encountered: