cover-img

How to add Prettier code formatter to your project?

28 July, 2022

2

2

0

You can use Prettier to make your code more readable and consistent with your style guide. There are several ways to start Prettier automatically, these are the most popular:

  1. pretty-quick
  • Use the library pretty-quick to format your changed or staged files.

  1. Shell script
  • Save this script as .git/hooks/pre-commit and give it execute permission:

If git is reporting that your prettified files are still modified after committing, you may need to add a post-commit script to update git’s index.

Add something like the following to .git/hooks/post-commit:


Configure rules

Create a *.prettierrc file at the root of your project to configure your prettier rules.

Here's an example file containing some popular rules:


For everything you don't want to format, create a .prettierignore file:


Manual Run & Fix

To manual run via CLI, add a command to package.json and run npm run format.

tutorial

css

javascript

cli

2

2

0

tutorial

css

javascript

cli

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.