Assume that we have JS project and we need to enable there automatic formatting.
First of all we have to install prettier as dependency into the project. Execute in project directory where package.json is located:
npm install --save-dev --save-exact prettier
yarn add prettier --dev --exact
Now we need to enable formatting on save in Visual Studio Code.
Navigate to setting using menu
File -> Preferences -> Settings or using
Ctrl+, key combination. Then search in settings for
Format On Save and enable it.
At this moment everything should work. Try to navigate to some
.js file, reindent some row and hit