(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)
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
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, eg 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.
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.