0

(There's a similar question asked >> Visual Studio - blank line at the end of each new file. But This is the complete opposite. And that doesn't answer this)

I have Visual Studio Code Version 1.19.0 on OSX. JavaScript (ES6) linter wants me to add a new blank line at the end of each file. When I hit save after adding a new blank line myself at the end of the file, VS Code removes that automatically. My concern is that, overriding any DEFAULT User Setting won't fix that.

Anyone with a solution? Thanks in advance.

(Setting I tried overriding but failed >> "files.insertFinalNewline": true)

2 Answers2

0

You can change the linter rule that enforces you to enter new line at the end so this will work

if you use ESlint you cab use the rul eol-last and set its value to "never"

in your .eslintrc file

{
"rules": {
   "eol-last" :"never"
   }
 }

learn more eol-last ESlint

mostafa tourad
  • 4,308
  • 1
  • 12
  • 21
0

For those who want to get rid of the new line at the end of a file:

I had a similar issue and the solution provided by 9paradox in this post solved my problem.

When I was saving my code (Python, JSON, JS, etc...) I got always a new line inserted at the end of the file.

Solution: if, e.g. on Mac, you are editing any file in your project, then go to the root directory of your project, let's say /Users/<username>/git/<project> then search for .editorconfig in that folder, then open that file with any text editor like vi or TextEdit and make insert_final_newline = false. VS Code takes over the settings changes immediately. No restart needed.

Tony
  • 7,767
  • 2
  • 22
  • 51