Show HN: EOF Script to ensure text files end with newline
github.comI do quite a lot of code reviews and usually all the files contain newline at the end - so github is happy and does not show warning icon. But sometimes - new person joins the project and is not aware of this, or somebody does small change in misconfigured ide or file is generated and in these cases newline is missing. My original way of handling this was to just edit the file directly but then I would have to wait for tests to run again, so at the end I gave up. Linters can usually help but they are always tied to one type of text files and do not cover config files.
I wanted to write a simple python script that will go through all text files (with white and blacklist) and ensures there is exactly one newline at the end. I also wanted for script to be able to fix the file or just report issues.
The current version works quite well - atleast for my 1 day of limited testing. Please take a look and happy to hear what you think.
What's the problem? Why is github showing a warning?
This is how the warning looks like https://stackoverflow.com/questions/65300309/add-missing-tra... . Generaly the text files should end with newline as it helps with compatibility. Here is nice thread talking about the reasons https://stackoverflow.com/questions/729692/why-should-text-f... .