Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
wrong count for 'no-multiple-empty-lines' on last line #4228
Happens on the last line.
throws error with this code:
doesn't throw for this code
but does for this one
Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions.
Ok, it turns out I didn't know what is a linebreak. :)
A linebreak doesn't really add a new line, just terminates the current line.
This code has just one line of code, linebreak terminated:
var a = 5;\n
As shown by
wc -l linebreak.js 1 linebreak.js
And the file output displaying non-printing characters
console.log(context.getSourceLines()) [ 'var a = 5;', '' ]
And editors display that file differently:
I believe the same thing is happening in the online editor
Given all that, I'm not sure what should be done. Now I'm thinking this fix was wrong, although the reporting is confusing in editors such as atom.
Thoughts @eslint/eslint-team ?
If you consider the linebreak to be a line terminator but not creating a new line itself, then I think the original code was doing the right thing removing the last line if it was empty.
As you can see from the screenshots I posted, when you open the same file with vim it appears to have one line. With atom it looks like it has two. I don't think there is a way for them to look correct from a user perspective, but technically the original behaviour seems the correct one so I would favor that.