Basic usage of prettier formatter with VSCode

Install prettier as your project dependency / dev-dependency (with npm or your desidered repo)

npm i prettier
# if you don't need in prod install as dev dependency
npm i prettier --save-dev

Create a file called .prettierrc with basic options to share with your team member and commit it in the root directory of your project

{
	"printWidth": 160,
	"useTabs": true
}

If you would like to personalize the style, create a folder in your root directory called .vscode and create a file called settings.json. If is already created just add the following keys:

Javascript / Typescript formatter example

{
	"editor.defaultFormatter": "esbenp.prettier-vscode",
	"editor.formatOnSave": true,
	"editor.codeActionsOnSave": {
		"source.organizeImports": true
	}
}

Categories: JavaJs,Ts,Css

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.