Skip to content

Conversation

@BaumiCoder
Copy link

If trim_trailing_whitespace and insert_final_newline are true and end_of_line is not set,
the trailing white spaces are removed, but no final newline is added.

This Pull Request currently only contains a failing tests to show this issues, which I reported in ec4j/editorconfig-maven-plugin#139.

In this situation only the trim is performed
but the final newline is not added.
@ppalaga
Copy link
Contributor

ppalaga commented Dec 21, 2025

@BaumiCoder thanks for the test, now I see what you expect. The question is how should editorconfig-linters know which eol should it use if end_of_line is not set?

@BaumiCoder
Copy link
Author

BaumiCoder commented Dec 22, 2025

You are right, there is no default of end_of_line in the EditorConfig specification, but normally an application uses the operating system default if not configured otherwise. I also adjusted the test to show, that System.lineSeparator() is also expected to be used in the input and output in this situation.

(A common scenario, where you not use EditorConfig to handle the EOL characters, is to handle them with git. Every developer has the files with the native EOL character on their machine and the central repository has LF.)

@ppalaga
Copy link
Contributor

ppalaga commented Dec 23, 2025

I have filed a clarification issue editorconfig/editorconfig#570 so that we keep the behavior consistent over various agents interpreting .editorconfigfiles.

@ppalaga
Copy link
Contributor

ppalaga commented Dec 25, 2025

@BaumiCoder I wonder why you do not set end_of_line to avoid the current issue?

@BaumiCoder
Copy link
Author

BaumiCoder commented Dec 25, 2025

Currently, I have no active Java project, but in general using end_of_line inside a git repository is not a good way in my opinion.

The reason is that git handles EOL already. The remote repository contains all files with LF and locally this is changed to platform specific EOL. To make sure nobody uses another git setting for this when working with your repository, you can add * text=auto to your .gitattributes file.

If you want to use end_of_line from EditorConfig, you also have to adjust the git setting. Because if EditorConfig enforces e.g., lf, but git converts the EOL on Windows PCs to CRLF, you get mixed line ending. Therefore, not using the native EOL is more complicated to configure. Furthermore, some simple tools (e.g., search tools like grep) have no EditorConfig support and maybe get confused if the EOLs are not the platform specific ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants