[英]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.我开始使用 Prettier,但发现它没有控制代码块之间空行数的选项,默认为 1。
I want 2 blank lines:我想要 2 个空行:
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:但它默认为 1 个空行:
const bar = 10;
// blank 1
function foo() {
hello();
world();
}
// blank 1
foo();
// blank 1
export foo;
How can I achieve this with Prettier?我如何使用 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.) (或者也许有另一种方法可以做到这一点。我很惊讶 Prettier 中可用的可配置选项很少。我希望有更多的控制。)
How to add multiple lines between code blocks with Prettier?
如何使用 Prettier 在代码块之间添加多行?
You can't.你不能。
I was surprised how few configurable options are available in Prettier.
我很惊讶 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 🌹其中一个意见是1行就足够了🌹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.