Skip to content
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

Code formatting in .mongodb #122

Closed
delcon opened this issue May 26, 2020 · 10 comments
Closed

Code formatting in .mongodb #122

delcon opened this issue May 26, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@delcon
Copy link

delcon commented May 26, 2020

Is there any way to configure / use a formatter / linter for .mongodb files?
This is my no1 feature that I miss in all mongodb GUI and would save me the countless times I try to run a query - just to get notified that something is not formatted right.

@mmarcon mmarcon added the enhancement New feature or request label May 27, 2020
@mmarcon
Copy link
Member

mmarcon commented Jun 17, 2020

As a workaround, you could use the Beautify extension.

I know it's not the best solution but it gets the job done.

2020-05-29_09-29-01 (1)

@mmarcon
Copy link
Member

mmarcon commented Jun 17, 2020

Can you create a feature request in our feedback forum?

@charlesonunze
Copy link

You can also add this to your settings.json file.

	"files.associations": {
		"*.mongodb": "javascript"
	}

@mmarcon
Copy link
Member

mmarcon commented Aug 25, 2020

You can also add this to your settings.json file.

	"files.associations": {
		"*.mongodb": "javascript"
	}

@charlesonunze this actually breaks playgrounds as they will be identified as JS files and the extension won't add the playground-related features anymore.

@charlesonunze
Copy link

Shit, I actually did not think that was the issue when intellisense wasn't working. I guess it needs it's own formatted after all :(

@Flamefork
Copy link

Prettier could be integrated too, although not in a straight way:

  1. adding to vscode config
  "prettier.documentSelectors": [
    "**/*.mongodb"
  ],

  1. adding to .prettierrc or creating one
{
  "overrides": [
    {
      "files": "*.mongodb",
      "options": {
        "parser": "babel"
      }
    }
  ]
}

@charlesonunze
Copy link

This actually works! Thanks! @Flamefork

@alenakhineika
Copy link
Contributor

I am closing this issue, but we have a formatting enhancement request on the MongoDB forum that you can track: https://feedback.mongodb.com/forums/929236-mongodb-for-vs-code/suggestions/42380848-formatting-support-for-mongodb-playground-files

And feel free to reach out if you have any further questions!

@mainakchhari
Copy link

this overrides section is not working when added to the global ~/.prettierrc

@SethFalco
Copy link
Contributor

It's worth noting that the extension marketplace now shows that the Beautify extension is unmaintained and deprecated.

image

Thought I'd put it here instead since I can include a screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants