Formatting support for mongodb playground files.
There's no way that I can find to format the code in a .mongodb playground file.
At present, I need to manually change the file suffix to js, then use a hot-key to run prettier, then rename it back.
If there is a better way, I'd love to know it!
Thanks,
Kim
With MongoDB for VS Code 1.0, Playground files are now true JS files. This means that whatever configuration you normally use for code formatting (e.g. Standard, Prettier, etc.) is available also for Playgrounds.
-
Libin commented
Suggestion:
1. Could please make "mongodb" as subtype of "javascript" so that did does not break the playground feature, and at the same time get all the features associated with javascript. (https://github.com/mongodb-js/vscode/issues/122#issuecomment-679909456)
2. You could support any formatter with following"[mongodb]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
}, -
Kim commented
Thanks for the tip @Massimiliano.
I think most folks are working with Prettier these days.
It might be best to try to look in that direction.
-
AdminMassimiliano (Admin, MongoDB) commented
Right now we don't have a built-in formatter. However, there is a workaround: with the beautify extension (https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify) you can format the file without changing the file extension (Cmd/Ctrl + Shift + P > Beautify file > JS).