Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect output for `no-multiple-empty-lines` on lines at EOF #4917

minustehbare opened this Issue Jan 11, 2016 · 5 comments


None yet
4 participants
Copy link

minustehbare commented Jan 11, 2016

Version of ESLint
What I did
Attempted to create a .eslintrc configuration to enforce exactly one empty line at EOF. Here is the configuration:

  "rules": {
    "no-multiple-empty-lines": [2, { "max": 2, "maxEOF": 1 }],
    "eol-last": 2

I tested this on two separate files:

1 var a = 1;


1 var a = 1;

What I expected
An error on the first file, no error on the second file.
What actually happened
The first file produces no error. The second file (with 2 lines, the last one being an empty line) throws this error:

3:2 error Too many blank lines at the end of file. Max of 1 allowed no-multiple-empty-lines

There are only 2 lines present in the file, yet eslint is reporting the error on a 3rd line. cat -e on the file produces:

var a = 1;$

I found a similar issue, #4228, which was resolved with v1.8.0 though I am not sure how it might be related to this problem.


This comment has been minimized.

Copy link

eslintbot commented Jan 11, 2016

@minustehbare Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage label Jan 11, 2016


This comment has been minimized.

Copy link

nzakas commented Jan 11, 2016

Are you sure you have exactly one line at the end of the file? Some editors add an extra, invisible line that makes it difficult to tell (I've had this problem before).

@nzakas nzakas added bug rule evaluating and removed triage labels Jan 11, 2016


This comment has been minimized.

Copy link

minustehbare commented Jan 11, 2016

AFAIK, yes I am sure. I used vim to create the files, I double-checked the contents using cat, and I also just opened the files in gedit and can only see 2 lines. Do you know of any other way that I should verify this or is that sufficient?


This comment has been minimized.

Copy link

alberto commented Jan 12, 2016

Yes, I think the same problem there was with max was introduced with maxEOF. A line-break doesn't cause an empty line. Two line-breaks do. But some editors (e.g. Atom, Sublime) pretend there is an extra empty line at the end of the file when you insert a linebreak on the last line.

So, I think maxEOF has an off-by-one error, but it's going to cause a lot of confusion anyway.

@nzakas nzakas added accepted and removed evaluating labels Jan 12, 2016

@alberto alberto self-assigned this Jan 13, 2016


This comment has been minimized.

Copy link

alberto commented Jan 13, 2016

Do we want to keep two separate messages here for inner lines and lines at EOF? Otherwise, I think the logic could be simplified a little.

@nzakas nzakas closed this in 86e6e57 Jan 13, 2016

nzakas added a commit that referenced this issue Jan 13, 2016

Merge pull request #4940 from eslint/issue4917
Fix: Incorrect error at EOF for no-multiple-empty-lines (fixes #4917)

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.