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
Prohibiting two consecutive newlines at EOF does not work as expected #12742
Comments
I’m unable to reproduce this. I know you mentioned you did try the I’d have to look at the Git history, but I’m assuming the |
Like I described above: Setting
And it really doesn't make a difference, two consecutive lines at EOF are being permitted -- no matter whether |
|
This certainly solved my issue. Thus, closing this issue is fine by me. However, you guys might want to leave it open, as this behavior is really non-intuitive. Without the explanation that @mdjermanovic just gave, it's really hard to grasp why |
I believe it's technically zero empty lines at the EOF, but it looks like one empty line in most editors. I agree this should be explained in the documentation. Also, I think there should be an example with Just, I'm not sure how to avoid this confusion in maxEOF examples because the presentation depends on the editor/viewer. For instance, if you open to view a source file on GitHub and see a code that looks exactly like the actual However, if you open another source file in VSCode, and see a code that looks exactly like the actual It's same in ESLint Online Demo So, these examples can be indeed confusing. Also, it looks that some other rules like |
Right, an empty line is actually |
There is an option in VSCode to modify this behavior: And it seems to be Also, the question does a newline/linebreak/eol sequence ends the current line or creates a new line (i.e. is there an empty line after the last I was thinking to provide both views on the same examples in the docs - one representing a screenshot of a viewer that doesn't render an extra empty line, the other representing a viewer that does render an extra empty line. (not real screenshots, just code blocks with extra lines) Does this seem like a good idea? There is also the following potential problem: code examples in the documentation have a different appearance on eslint.org and GitHub. This looks like 2 empty lines at the end: This looks like 0 empty lines at the end: There are three This usually doesn't matter but in this particular case users might already get the wrong impression on how the rule works at the EOF depending on where they're reading the documentation. |
It seems we all agree that the rule is working as intended and that it would be great to improve the documentation, so I marked this as an accepted "documentation" issue. |
Sounds good to me! I think it would helpful to show this with line numbers anyway. |
That's a great idea! Is there already a way to show line numbers in code blocks (at least on eslint.org)? |
We don't have anything set up as far as I know, but it might be worth looking at the options for the Markdown -> HTML plugins we're using in Eleventy to see if there's a built-in way to do it. If not, we can implement it. That being said, I don't think that needs to be a blocker for the documentation update! |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Added an explanation on how and why maxEOF should be set to 0 to work with the eol-last rule.
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? default (?)
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Source code:
// Source code of any .js file of the project
Command:
npx eslint .
What did you expect to happen? What actually happened?
I want to ensure there is exactly one newline at the end of each file. Since I am extending the Airbnb style guide,
eol-last
is already enabled, which afaik requires at least one newline at the end of the file. So all that's left for me to specify is that more than one newlines at the end of the file are disallowed. I thought I might be able to accomplish this like so:Now, there should be both
eol-last
being enabled in the Airbnb style guide, as well asno-multiple-empty-lines
to{ "max": 1 }
.However, this still configuration seems to still allow two consecutive newlines at the end of the file.
In the Gitter chat room, it was recommended to set
maxEOF
to1
. This, however, does not change the fact that two newlines at the end of the file are being accepted. The fact that this does not fix the issue is to be expected, asmax
is already set to1
, so settingmaxEOF
to1
also should not have an effect.In the Gitter chat room it was concluded to file a bug report.
Are you willing to submit a pull request to fix this bug?
Maybe. It would be an honor but I'm not sure I can. I'll take a look.
The text was updated successfully, but these errors were encountered: