Search code examples
prettier

Prettier as a dev dependency


I'm collaborating on a project and use prettier as my code formatter. The number of collaborators is growing and I just suggested that we install prettier as a dev dependency and set up a config file so that our formatting is consistent. I have two questions about this:

  1. I want to specify a specific version in the package.json so that versioning does not create diffs. I have Prettier installed globally on my machine and want to make sure the dev dependency is taking precedence over the globally installed version.
  2. I wanted to know if anyone had any experience putting multiple config files in their project to format different directories slightly differently and if this caused any issues. specifically I'm thinking of using separate config files for the server and client code.

Any help is appreciated. Thanks so much.


Solution

  • What you're describing is the recommended way to use Prettier. See https://prettier.io/docs/en/install.html

    To configure different settings for different parts of the project, use the overrides key in the config file. See https://prettier.io/docs/en/configuration.html#configuration-overrides

    If something isn't clear and you still have questions, please write them here.