Prettier is an automatic code formatter which supports various languages, including TypeScript. It also has extensions for various text editors like VSCode, Atom, and even Vim. If you have installed these extensions, it will use Prettier's service to automatically format your code after saving.
If you would rather not use Prettier instead, you can easily disable it too. In VSCode, open .vscode/settings.json, then change the "editor.formatOnSave" option to false:
1
{
2
"[json]":{
3
"editor.formatOnSave":false
4
},
5
"[javascript]":{
6
"editor.formatOnSave":false
7
},
8
"[typescript]":{
9
"editor.formatOnSave":false
10
}
11
}
Copied!
Configuring ESLint for Prettier
The .prettierrc file configures how Prettier formats your code. By default we use the following options.
1
{
2
"semi":true,
3
"tabWidth":2,
4
"printWidth":120,
5
"singleQuote":false,
6
"trailingComma":"none",
7
"arrowParens":"avoid",
8
"endOfLine":"auto"
9
}
Copied!
We can use ESLint config and plugin for Prettier to override some ESLint rules to not conflict with Prettier.