简体   繁体   English

VSCode Prettier 将 Condition 语句分隔成单独的行

[英]VSCode Prettier Keeps separating Condition statements into separate lines

How do I Stop Prettier VSCode Formatter from breaking up equal statements?如何阻止 Prettier VSCode Formatter 分解相等的语句? The following condition statement is broken into two lines, when coding Angular.在编码 Angular 时,以下条件语句分为两行。

if (
   productId ===
   productTest
){

It makes it difficult to read simple code.它使阅读简单的代码变得困难。

Prettier doesn't by default break up equal statements, so either the statement exceeds the maximum print width, or you have another plugin that is somehow interfering. Prettier 默认情况下不会分解相等的语句,因此要么语句超过了最大打印宽度,要么你有另一个插件以某种方式干扰。

You can increase the printwidth by adding a prettier configuration file, eg .prettierrc file to the root of your project and setting the printwidth, eg您可以通过添加更漂亮的配置文件来增加打印宽度,例如.prettierrc文件到项目的根目录并设置打印宽度,例如

{
  "printWidth": 100
}

You can see the full list of configuration file types and options at: https://prettier.io/docs/en/configuration.html您可以在以下位置查看配置文件类型和选项的完整列表: https://prettier.io/docs/en/configuration.html
https://prettier.io/docs/en/options.html https://prettier.io/docs/en/options.html

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

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