I started to use Prettier inside my Microsoft Visual Studio Code (MVSC), but, when formatting a javascript file, I get some strange formatting.
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?
Thanks.
Prettier gonna always try to give line break your code if it exceeds your print width configuration.
You can change that by accessing vscode settings
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.