question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preserve new line at end of file

See original GitHub issue

Hi,

The js-beautify will remove the last new line before inside the HTML script tag. For example the new line in the following HTML script,

<head>
  <script>
    mocha.setup('bdd');

  </script>
</head>

will be removed after js-beautify reformatted the file,

<head>
  <script>
    mocha.setup('bdd');
  </script>
</head>

However, the problem is ESLint will complaint that a newline required at end of file but not found (eol-last).

May I know if we can configure js-beautify not to remove the last newline?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bitwisemancommented, Apr 5, 2020

@nelson6e65 This is not atom-beautify, sorry. You’ll need to address the issue in that project.

1reaction
bitwisemancommented, Dec 3, 2018

@jonkri Settings overrides should work for this. Set the html (or root) setting to true and set the value for js and css children to false. It would look something like this.

{
  "end_with_newline": true,        
  "html": {
    "js": {
      "end_with_newline": false        
    },
    "css": {
      "end_with_newline": false        
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a newline to the end of a file?
Here you go: sed -i -e '$a\' file. And alternatively for OS X sed : sed -i '' -e '$a\' file. This adds...
Read more >
No Newline at End of File
So, it turns out that, according to POSIX, every text file (including Ruby and JavaScript source files) should end with a \n ,...
Read more >
Why should text files end with a newline?
text file (each line is supposed to end in an end-of-line); binary file (there are no true "lines" to speak of, and the...
Read more >
How to Preserve Newlines, Line Breaks, and Whitespace in ...
Preserve Newlines, Line Breaks, and Whitespace in HTML. Use the white-space: pre; setting to display long-form content containing whitespace ...
Read more >
Sublime Text: Add NewLine at EOF on Save - ShellHacks
A Sublime Text can be configured to add a newline character automatically on a file save, using the ensure_newline_at_eof_on_save option ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found