LoginSignup
2
0

More than 3 years have passed since last update.

Prettier の ifBreak を現在の group 以外に使う

Posted at

Prettier の doc ユーティリティに ifBreak というのがあります。
現在の group が break されてるかどうかに応じて print する doc を変えることができる便利ユーティリティです。
実は、現在の group 以外の group を指定することが可能です。

group を作るときに id を付与しておくと ifBreak でその group を見ることができます。

const printed = group(concat(parts), { id: Symbol.for("foo") });
const printed = ifBreak("foo", "bar", { groupId: Symbol.for("foo") });

最近知った、大変便利。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0