I am using prettier with VSCode, How can I configure it to format my code like this :
function test()
{
if()
{
MYCODE GOES HERE;
}
}
I want the {
and }
on new lines, and an empty line after {
and before }
.
Currently, it moves the curly brackets to same lines if condition or function name, and also remove the empty lines after/before {
and }
.
Prettier is considered an "opinionated" formatter, which means it doesn't let you choose things like that. If you want more control over the formatting, you can use a different formatter.
The built-in VS code formatter allows you to do what you're looking for, just search the settings for "function new line" and similar options.
There are of course many other formatting extensions available in the VS code marketplace as well. Whichever you choose, you will have to select it has your default formatter in your VS code settings.