-
Install the VS Code Extention "Prettier - Code formatter" ( esbenp.prettier-vscode )
-
( In the project root )
npm install --save-dev prettier prettier-plugin-tt2@latest
-
Configure Prettier through extention or with a ".prettierrc" file.
-
(optional) Configure format on save in VS Code
- File > Preferences > Settings
- Search for "format on save" and enable "Editor: Format On Save"
Example .prettierrc
:
{
"plugins": ["prettier-plugin-tt2"],
"tabWidth": 2,
"printWidth": 80,
"bracketSameLine": true
}
If you dont want Linebreaks because of long Lines you could change the "printWidth" to some large value like 8000.
- Reinstall the plugin with:
npm install -D prettier-plugin-tt2@latest
To install Prettier globally:
npm install -g prettier prettier-plugin-tt2@latest
- In VS Code Prettier Settings enable "Prettier: Resolve Global Modules"
- Contiune with configuring prettier ...