Reputation: 28116
JSHint complains when, at the end of the file, there is no line feed. Here is an example:
Missing line feed at file end at app/services/cache.js :
14 |
15 | });
16 |})();
-------------^
What's the purpose of having this line feed? What difference would it make?
Upvotes: 3
Views: 2993
Reputation: 15875
If you're using the .js file directly in HTML or NodeJS and you edit it entirely using IDE's like WebStorm or Sublime, etc., then there is no real advantage.
If later in your build and deployment you are using something like Gulp to concatenate multiple .js files like cache.js
and edit.js
together into one master.js
, then the last line of cache.js
is going to be in the same line as the first line of edit.js
.
That is if cache.js
, as you wrote, has no line feed and ends with the following
});
})();
and say you had another file edit.js
that you concatenate into one master.js
using a tool like Gulp and edit.js
starts with the following
/* a really krufty set of code for editing barrels of kittens */
$().read(function() {
// ... da code be here ...
then your final master.js
will have a line like this
})();/* a really krufty set of code for editing barrels of kittens */
Is there anything wrong with that? No, not really. Might make it harder to debug or read later depending on the lines in question.
And, as amenthes has commented, command line tools like cat
and wc -l
aren't going to give expected results.
And, as Przemysław Jan Wróbel led me to see, there is a fantastic answer here https://stackoverflow.com/a/25322168/266531
Upvotes: 1