6
Most linters from different programming languages, such as Rubocop (Ruby) and Jslint (Javascript) recommend a blank line from the end of all code files. As an example, Rubocop:
Rubocop::Cop::Style::Finalnewline
That one Cop reinforces the presence of a blank final line in each source file. (adapted from Rubydoc)
Besides the linters, to Git, when running git diff
, indicates when there is no blank line at the end of the source files:
No newline at end of file
To illustrate, the result is:
1 def say_hi
2 puts 'hi'
3 end
4
5 say_hi
6
Is it just a convention? There is a difference in putting a blank line at the end of my code and not putting?
Related to Soen: https://stackoverflow.com/q/2287967/1452488
– Woss
We also have the Unix influence, where there is always line break at the end of a text file
– Jefferson Quesado