-
Notifications
You must be signed in to change notification settings - Fork 26
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
Clarification on insert_final_newline behavior for empty files #15
Comments
I think this is a duplicate of of editorconfig/editorconfig#416 |
Empty files have zero lines, so there's nothing to terminate. Adding a newline in that case would inserting a new (empty) line, which is just wrong. Editors and linters that don't respect this behavior are buggy. For the specification, yes, it can be clarified if necessary, to help implementers avoid mistakes. Is that necessary? |
Per @ppalaga at editorconfig/editorconfig#416 (comment) , I agree with clarifying the specification to state expressly that editors shall not insert newlines in empty files when saving those files with |
POSIX requires non-empty files to feature a final end of line (e.g.
\n
line feed) terminator, and in general EditorConfig does a good job of helping users to enforce this.For blank files, however, POSIX does allow for the omission of final end of line terminators. In the event that EditorConfig encounters a file with absolutely no content, it should not warn (and text editor plugins should not auto-insert) about end of line terminators.
In Atom for example, saving a blank file with EditorConfig and
insert_final_newline
rule enabled, does not present an extra end of line terminator. Neither does Vim. That is acceptable and storage-optimal behavior as far as POSIX is concerned. Not sure about how other EditorConfig toolsets behave.If we ignore backwards compatibility, then EditorConfig should clarify final eol rule behavior. EditorConfig plugins and linters should go ahead and check for empty files before warning or auto-inserting final eol terminators. This could temporarily break some CI configurations, though the end result is that user data is more POSIX compliant.
However, if backwards compatibility is preeminent, then we may want to create a new option for this rule, something like
blank_files_skip_eol
, which takes valuestrue
,false
, ornone
(not enforced). And encourage the community of EditorConfig tools to update and encourage good form.The text was updated successfully, but these errors were encountered: