Skip to content

Instantly share code, notes, and snippets.

@smashdevcode
Last active December 10, 2023 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smashdevcode/b35d0beb8dcc1c8b55a672bd130956f8 to your computer and use it in GitHub Desktop.
Save smashdevcode/b35d0beb8dcc1c8b55a672bd130956f8 to your computer and use it in GitHub Desktop.
Prettier Installation and Configuration

Prettier Installation and Configuration

  1. Install the prettier package.
npm install --save-dev --save-exact prettier
  1. Add a .vscode folder to your project.

  2. Add a settings.json file to the .vscode folder containing the following:

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true
}
  1. Add a Prettier configuration file .prettierrc.json to the root of your project containing the following:
{
  "trailingComma": "es5",
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true
}
  1. Format all files in the project:
npx prettier . --write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment