JSHint - Line Feed Error

JSHint complains when there is no line at the end of the file. Here's an example:

Missing line feed at file end at app/services/cache.js :
    14 |
    15 |  });
    16 |})();
-------------^

      

What is the purpose of this feed? Who cares?

+3


source to share


1 answer


If you are using a .js file directly in HTML or NodeJS and you are editing it completely using an IDE like WebStorm or Sublime, etc., then there are no real benefits.

If later in your build and deployment you use something like Gulp to combine multiple .js files like cache.js

and edit.js

together into one master.js

, then the last line cache.js

will be on the same line as the first line edit.js

.

That is, if cache.js

, as you wrote, has no line and ends with the following

  });
})();

      

and let's say you have another file edit.js

that you merge into one master.js

with 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 at all. You might find it harder to debug or read later depending on the relevant lines.

And as amenthes comments , command line tools like cat

and wc -l

will not give the expected results.

And like Przemysław Jan Wróbel I saw there is a fantastic answer here at fooobar.com/questions/7116 / ...

+2


source







All Articles