Closed milahu closed 3 years ago
I'd be in favor of this, but on the Svelte site I think we should then strip trailing whitespace when building REPL examples, so that they don't have the extra newline at the end.
what about, we hack the code editor to hide the last line number? so it shows the correct line count, as defined by posix (one line = string + newline)
or is it the one line of vertical space you want to avoid?
Hi @milahu - please could you raise this according to the process here - https://github.com/sveltejs/eslint-config/issues/new/choose
I'd much rather try hacking the data being sent to Code Mirror than to try hacking Code Mirror.
@antony done
Reason for the rule mostly to make git happy
git diff
shows warnings on missing newlines at end-of-file in terms of function, this will (probably) have zero effectExamples with rule
eol-last
line 1\nline 2\nline 3\nline 4\n
line 1\nline 2\nline 3\nline 4
so much trouble for just one character ------------^
Poll
![](https://api.gh-polls.com/poll/01EKFWQC2EF7WFQYXKRS5GCY3A/no%2C%20we%20dont%20need%20rule%20%60eol-last%60)
Background background is compatibility with POSIX tools for example the 'word counter'
wc --lines input.js
prints the number of newline characters since 'one line' in POSIX is defined as 'string + newline character' and if the last line is not terminated with a\n
thenwc -l
prints one line less (and the world ends)Exceptions one special case is: source code for svelte code examples for aesthetic reasons, the code can be
trim()
med to remove whitespace at end-of-file (as it is done now) but there is no need to do this trimming in the file system so the eslint-rule can apply to these files toooriginal post
.. to make `git diff` happy .. for compatibility with POSIX tools .. to reduce diff noise when appending to files https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline