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

Zero newlines allowed at end of file #990

Closed
Gryff opened this issue Sep 20, 2017 · 2 comments
Closed

Zero newlines allowed at end of file #990

Gryff opened this issue Sep 20, 2017 · 2 comments

Comments

@Gryff
Copy link

Gryff commented Sep 20, 2017

From the standard rules I see that files must end with a newline. However when running standard it tells me files that adhere to this rule are wrong.

myFile.js -

function hello () {
  console.log('hello')
}

module.exports = hello

$ standard --version
10.0.3
$ standard myFile.js
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  /path/to/myFile.js:6:1: Too many blank lines at the end of file. Max of 0 allowed.

Searching the issues here I see this comment about enforcing no more than 1 newline at the end of a file.

Eslint's rules imply that this is wrong and we should use maxEOF: 1.

Maybe eslint fixed the wonkiness mentioned in the issue comment above?

@LinusU
Copy link
Member

LinusU commented Sep 20, 2017

It seems like your file ends with two newlines? (one blank line)

The rule comes from the fact that a unix text file is defined as multiple strings all terminated by \n (a newline). It seems like your file ends with two newlines (\n\n) which is the same as one blank line.

Basically, there should be exactly one newline character at the end of the file, which will result in no blank lines at the end of the file.

Hope that this made sense 😄

@Gryff
Copy link
Author

Gryff commented Sep 20, 2017

Thanks @LinusU, that does make sense. I misunderstood.
newline !== blank line

@LinusU LinusU closed this as completed Sep 20, 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
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants