Configure VSCode Projects to Force Formatting

I like to set VSCode workspace settings to format on save and commit those setting to the repo. This enables me to:

I simply gave up having my own opinions on formatting, trust Prettier’s opinions and waste less time.

Setup

Install the VsCode extension esbenp.prettier-vscode. This is the only manual that every coder has to do, the rest is done once and commited to the repo.

npm i --save-dev prettier

Create settings file for the project ./.vscode/settings.json:

settings.json
{
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true,
    "[html][js][css][ts][jsx][tsx]": {
        // VSCode's default tab size does not match prettier.
        "editor.tabSize": 2
    }
}
settings.json
{
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true,
    "[html][js][css][ts][jsx][tsx]": {
        // VSCode's default tab size does not match prettier.
        "editor.tabSize": 2
    }
}

Enjoy

Enjoy clean commits, more time to bikeshed on things that are not formatting.