[英]I wish to know how I can prevent Prettier to format my js code in this strange form
I started to use Prettier inside my Microsoft Visual Studio Code (MVSC), but, when formatting a javascript file, I get some strange formatting.我开始在我的 Microsoft Visual Studio Code (MVSC) 中使用 Prettier,但是,在格式化 javascript 文件时,我得到了一些奇怪的格式。
For example, if I have this code:例如,如果我有这个代码:
if ($("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + (programListIndexOffset + 1) + ")" ).length) {
$("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + programListIndexOffset + ")").removeClass("epgtablerowselected");
$("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + (programListIndexOffset + 1) + ")").addClass("epgtablerowselected");
} else {
programListIndexOffset--;
}
It get it formatted as:它被格式化为:
if (
$(
"#epgprogramdescription" +
channelListIndexOffset +
":nth-of-type(" +
(programListIndexOffset + 1) +
")"
).length
) {
$(
"#epgprogramdescription" +
channelListIndexOffset +
":nth-of-type(" +
programListIndexOffset +
")"
).removeClass("epgtablerowselected");
$(
"#epgprogramdescription" +
channelListIndexOffset +
":nth-of-type(" +
(programListIndexOffset + 1) +
")"
).addClass("epgtablerowselected");
} else {
programListIndexOffset--;
}
Any way to configure Prettier to maintain the original formatting?有什么方法可以配置 Prettier 以保持原始格式?
Thanks.谢谢。
Prettier gonna always try to give line break your code if it exceeds your print width configuration.如果您的代码超出您的打印宽度配置,Prettier 将始终尝试给它换行。
You can change that by accessing vscode settings您可以通过访问 vscode 设置来更改它
Give it bigger value if you want your code to stay in the same line.如果您希望代码保持在同一行,则赋予它更大的价值。 Prettier only break your code into new lines if it exceeds the given configuration如果代码超过给定的配置,Prettier 只会将您的代码分成新行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.