[英]How do I make Prettier format my code with indentation continuation?
如果我们要遵循谷歌 JavaScript 风格指南,那么根据这个:
https://google.github.io/styleguide/jsguide.html#formatting-indent
换行时,“第一行(每个续行)之后的每一行都从原始行缩进至少 +4”
例如,
const v = 10 + 10 + 10 + 10 + ... // goes beyond line limit
Google JavaScript 样式建议,我们换行如下:
const v =
10 + 10 + 10 + 10 + ...
查看完整示例: https://github.com/saad-learns/prettier-example/blob/main/bar.js
但是有了 prettier,我们得到
const v =
10 + 10 + 10 + 10 + ...
查看完整示例: https://github.com/saad-learns/prettier-example/blob/main/foo.js
我找不到让 Prettier 遵循 Google JavaScript Style 的方法。 没有选择吗? 还是 Prettier 的哲学与 Google 的 JavaScript 风格不兼容?
所以这已经被其他人在更漂亮的 github 问题中问到:
https://github.com/prettier/prettier/issues/11897
答案是他们不会添加更多选项来支持与块缩进不同的行继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.