R.J.
R.J.

Reputation: 648

VSCode Prettier not respecting Require Config option for Format on Save

Description

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).

Issue

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:

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?

Software Versions

Upvotes: 5

Views: 2255

Answers (1)

djjavo
djjavo

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

Related Questions