简体   繁体   English

VS Code:如何阻止 Prettier 在我的 JS 文件末尾添加新行?

[英]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.

相关问题 如何阻止 nodejs-firestore 写入阻止 node.js 事件循环? - How do I stop nodejs-firestore writes from blocking the node.js event loop? 通过 expo 在 firebase 中注册帐户的格式以及如何编写代码以在通过应用程序创建新用户时捕获错误 - Format for registration of account in firebase via expo and how do i code my code to catch errors when creating new user via app 如何允许从前端 web 应用程序公开/未经身份验证的发布到我的 GCP 发布/订阅主题? - How do I allow public/unauthenticated publish to my GCP pub/sub topic from front-end webapp? 当我尝试将数据从 Google Search Console 提取到 BigQuery 时,如何阻止我的脚本超时? - How do I stop my script from timing out when I try to extract data from Google Search Console to BigQuery? 在使用 Node.js 连接到 S3 时,如何让我在 AWS Fargate 容器中运行的代码承担 IAM 角色? - How do I enable my code runing in a AWS Fargate container to assume an IAM role when connecting to S3 with Node.js? 如何从发送到我的 Twilio 号码的文本中提取 zip 代码参数? - How do I extract the zip code parameter from a text sent to my Twilio number? 如何创建函数以减少代码中的冗余? [JS] - How can I create functions to reduce redundancy in my code? [JS] 如何在 firebase 上保存相同 JS 代码的多个实例? - How do I save multiple instances of the same JS code on firebase? 如何在授权代码流程中查看我的授权代码? - How do I check my authorization code in authorization code flow? 如何为我的独立可启动代码启用 SSE? - How do I enable SSE for my freestanding bootable code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM