简体   繁体   中英

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

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 🌹

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM