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

Enforce only 1 newline at end of file (currently 1-2 are allowed) #733

Closed
johannes-z opened this issue Jan 5, 2017 · 3 comments
Closed
Labels
Milestone

Comments

@johannes-z
Copy link

If there are spaces on the last line, standard --fix will remove the spaces, but still add a newline.

In the following example I added characters to visualize newlines and spaces. An empty line is marked with a _ (underscore) and a space is marked with a . (dot).

Correct:

console.log('test');

becomes

console.log('test')
_

Wrong:

console.log('test');\n
..

becomes

console.log('test')
_
_
@feross
Copy link
Member

feross commented Jan 5, 2017

This looks like an ESLint bug, so I opened an issue there: eslint/eslint#7866

@feross feross closed this as completed Jan 5, 2017
@feross
Copy link
Member

feross commented Jan 11, 2017

Turns out the way ESLint counts lines at the end of the file is a bit wonky. They don't count the last \n, so we actually need to set maxEOF: 0 on the no-multiple-empty-lines rule:

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

That fixes this issue, and also another issue with standard right now, which is that we allow either 1 or 2 newlines at the end of a file. 👍

@feross feross reopened this Jan 11, 2017
@feross feross changed the title Space on last line - wrong formatting Enforce only 1 newline at end of file (currently 1-2 are allowed) Jan 11, 2017
@dcousens dcousens added the bug label Jan 11, 2017
@feross feross added this to the standard v9 milestone Jan 11, 2017
feross added a commit to standard/eslint-config-standard that referenced this issue Feb 9, 2017
@feross
Copy link
Member

feross commented Feb 9, 2017

This will be part of standard v9. There were 12 repos that failed, but this is trivial to fix, is also automatically fixable with --fix, and was an enforced rule in the past (this was a regression).

@feross feross closed this as completed Feb 9, 2017
feross added a commit to standard/eslint-config-standard that referenced this issue Feb 9, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Archived in project
Development

No branches or pull requests

3 participants