Reputation: 648
I would like to configure the Visual Studio Code Prettier extension to automatically format on save, but only if a .prettierrc
file exists in the project (what I understand as the "Prettier: Require Config" option).
I have the following enabled in my VS Code settings:
Under the "Editor: Default Formatter" settings, the following behavior is happening depending on what I have selected:
.prettierrc
file.prettierrc
file.Similar to other issues, I seem to need Prettier set under "Editor: Default Formatter" in order for "Editor: Format on Save" to work at all. However, it seems the "Prettier: Require Config" setting effectively does nothing in any configuration I've tried. I have also tested with other supported configurations according to the Prettier docs. Is there something I'm missing here?
Upvotes: 5
Views: 2255
Reputation: 115
I had a similar issue where Prettier was formatting, despite the absence of the .prettierrc
file.
When looking at the Prettier plugin logs in VSCode, it appears that Prettier will also look for the presence of a .editorconfig
file, which I had in my project. Removing this solved the issue for me.
Upvotes: 3