You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 values true, false, or none (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:
mcandre
changed the title
Clarification on final end of line behavior for empty files
Clarification on insert_final_newline behavior for empty files
Jan 13, 2020
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 insert_final_newline = true.
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: