FR: Option for Line Break at Document End to ignore empty files #1228
Labels
markdown
General Markdown or Markdown related issue or feature
resolution/update-made
A change has been made that should resolve this issue or request
rule suggestion
Suggestion to add or edit a rule
Is Your Feature Request Related to a Problem? Please Describe.
I use the Line Break at Document End option, but I find its behavior annoying in one specific case: when linting an empty file, it adds a new line, meaning that the file is no longer empty. I lint files on document save and on focused file change, so this means that whenever I edit an empty file, even for a second, it ends up containing a single line break.
The current behavior is consistent with the rule description, but apart from the annoyance of having to remove the line when I don't want it, it's also convenient to keep empty files truly empty, since it makes it easy to find them by querying the file system (or Dataview) for files that are 0B in size.
To replicate: enable the Line Break at Document End option, create an empty note, lint it, then check its file size:
Describe the Solution You'd Like
An option to disable the rule on empty files. (Since the option is a toggle, I don't know if a new option would have to be added or if the existing rule can be adapted.)
I’m happy to put in a PR if there’s agreement on a direction.
Describe Alternatives You've Considered
I can of course tweak my search to instead find files that are 1 byte in size, but that's less convenient, inconsistent with other methods of finding empty files, and could also lead to false positives.
I could also disable the specific setting and / or only lint on demand, but this setup works as I want 99% of the time, so that would not be ideal, either.
Additional Context
For comparison, formatters such as Prettier do not add a line break to empty files:
(Also, apologies if there's already an issue about this – it's very hard to search given the sheer number of open issues and the fact that many issues contain debug output.)
The text was updated successfully, but these errors were encountered: