[英]VS Code: How do I stop Prettier from adding a new line at the end of my JS file?
I installed Prettier and changed the settings to format on save.我安装了 Prettier 并将设置更改为保存时格式化。 I ran Firebase deploy and now I'm getting an error:我运行了 Firebase deploy,现在出现错误:
172:6 error Newline not allowed at end of file eol-last
I see that when I format on save, it's adding a new line at the end.我看到当我在保存时格式化时,它在末尾添加了一个新行。 How do I force Prettier to not do this?我如何强制 Prettier 不这样做?
You can configure the Prettier extension to not add a new line at the end of file by setting the "insertFinalNewLine" option to "false" in your prettier configuration file.您可以通过在更漂亮的配置文件中将“insertFinalNewLine”选项设置为“false”,将更漂亮的扩展配置为不在文件末尾添加新行。 Like this:像这样:
{
"insertFinalNewLine": "false"
}
Or you can set "proseWrap" to "never" to disable automatic line-wrapping and to not add newline at the end of file.或者您可以将“proseWrap”设置为“never”以禁用自动换行并且不在文件末尾添加换行符。 Like this:像这样:
{
"proseWrap": "never"
}
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.