Search code examples
javascriptnode.jstypescriptvisual-studio-codeprettier

How to add multiple lines between code blocks with Prettier?


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:

const bar = 10;
// blank 1
// blank 2
function foo() {
  hello();
  world();
}
// blank 1
// blank 2
foo();
// blank 1
// blank 2
export foo;

But it defaults to 1 blank line:

const bar = 10;
// blank 1
function foo() {
  hello();
  world();
}
// blank 1
foo();
// blank 1
export foo;

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.)


Solution

  • 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 🌹