I started using Prettier, but discovered that it doesn’t have an option to control the number of blank lines between code blocks, and defaults to one.
I want 2 blank lines:
JavaScript
x
14
14
1
const bar = 10;
2
// blank 1
3
// blank 2
4
function foo() {
5
hello();
6
world();
7
}
8
// blank 1
9
// blank 2
10
foo();
11
// blank 1
12
// blank 2
13
export foo;
14
But it defaults to 1 blank line:
JavaScript
1
11
11
1
const bar = 10;
2
// blank 1
3
function foo() {
4
hello();
5
world();
6
}
7
// blank 1
8
foo();
9
// blank 1
10
export foo;
11
How can I achieve this with Prettier?
(Or perhaps there is another way to do this. I was surprised how few configurable options are available in Prettier. I was hoping for more control.)
Advertisement
Answer
How to add multiple lines between code blocks with Prettier?
You can’t.
I was surprised how few configurable options are available in Prettier. I was hoping for more control
That is very intentional. Prettier is an opinionated code formatter.
One of those opinions is 1 line is enough 🌹