简体   繁体   English

如何防止 Prettier 评论断行?

[英]How to prevent Prettier from breaking lines with comments?

For some reason Prettier breaks the line with comments moving everything after opened braсket on new line.出于某种原因,Prettier 在新行上打开括号后用注释移动所有内容来打破这一行。 Here is before这是之前自动格式化前

And here is after这是之后后

As you can see it makes kind of random formatting: at the 1st line it moves comments to a line above, then it breaks line by brackets, then again moves comments above.如您所见,它进行了某种随机格式化:在第一行,它将注释移动到上面的一行,然后用括号换行,然后再次将注释移动到上面。 I found here How to prevent Prettier from moving comments to new line it's like impossible to prevent Prettier from moving comments to a new line, but I can't find something about how to prevent it from breaking lines and making that bunches of cascades.我在这里找到了如何防止 Prettier 将评论移至新行似乎不可能阻止 Prettier 将评论移至新行,但我找不到有关如何防止它断行并形成一堆级联的信息。 Increasing Print width (line limit) does nothing, it's 160 for me now.增加打印宽度(行限制)没有任何作用,现在对我来说是 160。 Any solutions?任何解决方案?

Prettier is for front-end. Prettier 用于前端。 Use Python formatter instead, for example, Black formatter.请改用 Python 格式器,例如 Black 格式器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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