'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:
- "Editor: Format On Save"
- "Prettier: Require Config"
Under the "Editor: Default Formatter" settings, the following behavior is happening depending on what I have selected:
- "None": Prettier does not format on save, regardless of the presence of a
.prettierrcfile - "Prettier - Code formatter": Prettier always formates on save, regardless of the presence of a
.prettierrcfile.
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
- Operating System: macOS 10.14.6
- Visual Studio Code: v1.56.0
- Prettier - Code formatter: v6.3.2
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | djjavo |
