DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for How to disable prettier in VSCode for a specific project?
Gulshan Saini
Gulshan Saini

Posted on

How to disable prettier in VSCode for a specific project?

Post source

Prettier is an opinionated code formatter and ensures that code follows consistent style. It can automatically fix formatting related issues for HTML, CSS and JavaScript - for complete list of supported languages, please look at the official docs.

If you are working in a big team and want consistent code formatting without manual intervention(code reviews), I highly recommend Prettier.

Prettier is available as VSCode extension which can be enabled and it automatically take cares of formatting. You could even set preference when to format the file i.e. on file save or when you paste text etc.

I love Prettier and use it daily for personal and organization projects. There could be a case where you do not want Prettier to automatically format files.

Now the first option is to disable the VSCode extension. I am sure this is not what you are looking for as it is pain to enable and disable the extensions every time you switch projects.

Other option is to enable Prettier only when a configuration file is present in the project. To enable this option open VSCode settings

  • On Windows/Linux - File > Preferences > Settings
  • On macOS - Code > Preferences > Settings

Search for Prettier:Require Config and make sure it is checked

Prettier:Require Config

So how does this work?

By turning on this option, Prettier will only work for the projects having valid .prettierrc file. A valid .prettierrc could be as simple as having just opening and closing curly braces as follows

{}
Enter fullscreen mode Exit fullscreen mode

Originally posted at tutorial.tips

Top comments (3)

Collapse
 
jonathanmelnik profile image
Jonathan Melnik

I found out you can set the parser attribute to an invalid value, and prettier won't format your files in that project. For example, this is my .prettierrc:
{
"parser": "do not use prettier in this project"
}

Collapse
 
ludder profile image
Tom

You can disable Prettier per workspace as described here: github.com/microsoft/vscode/issues...

Collapse
 
makeitback profile image
Mike

More info on customised settings for a workspace here
(including changing specific settings for an extension such as prettier, or disabling it altogether)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›