Skip to content

insert_final_newline = true: should it remove all but one newline? #111

@jednano

Description

@jednano

I'm just wondering if there has been any discussion or decision on how insert_final_newline = true is supposed to behave when there are multiple newlines at the end of a file?

The reason I bring this up is because we're using EditorConfig at work and we have a contractor who submitted a bunch of files w/ 2 newlines at the end of each file. It would be nice if we could enforce a newline and specify that it's exactly one newline.

I realize insert_final_newline = true, if it were to remove all but one newline at the end of a file, is not very intuitive, in which case, what do we do?

I'm actually not a fan of this rule name, for this reason and more. I brought up before that the false value is misleading, in that telling me to NOT insert a newline isn't saying to actually remove newlines.

I do think this would make more sense if the rule were named final_newlines and the value could be an integer. This way, 0 would remove the final newline, or multiple newlines would be removed until there are none, 1 would ensure only 1 newline exists and hell, 2 if for whatever reason you want 2 newlines at the end of your file. Go crazy. At least it's intuitive and you know exactly what to expect.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions