- Install the
prettier
package.
npm install --save-dev --save-exact prettier
-
Add a
.vscode
folder to your project. -
Add a
settings.json
file to the.vscode
folder containing the following:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
- Add a Prettier configuration file
.prettierrc.json
to the root of your project containing the following:
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
- Format all files in the project:
npx prettier . --write