简体   繁体   中英

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. I ran Firebase deploy and now I'm getting an error:

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?

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. 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. Like this:

{
 "proseWrap": "never"
}

Hope this helps.

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.

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