-
Notifications
You must be signed in to change notification settings - Fork 37
LF at the End of File #20
Comments
First of all, a whole bunch of unix utils rely upon the fact that every line in a text file ends with newline. Second, some editors inserts last newline automatically, so you may accidentally become author of the last line. |
What are those UNIX tools? |
Mainly, editors: they just add last newline on saving a file (and you'll become the author of the last line). According to POSIX in Unix-like systems text file is the one with newlines at the end of every line, including last line. Otherwise a program has every right to treat a file as a binary one.
CR LF is Win-only, whereas LF is for everything else we actually use. Majority wins. |
What's the problem with being an author of empty line? And why state this in a codestyle? |
Not empty but the last one, which can be meaningful. |
Meaningful to people? How? |
You know you can write code and the last line of a file? :) |
I don't understand. |
I don't want to argue about this anymore. There is an implication from POSIX, which may or may not be strictly necessary, and since we mostly use POSIX-compliant tools I suggest this rule continues to live. There is no any reason whatsoever to change this, only nasty little repercussions. |
We live without this rule, and everything is fine. Problem is greatly exaggerated, no contemporary tool gives any damn to absence of blank line. |
Again, what about ones adding the last newline? |
See no problem with them (== with being an author of blank line). |
It's not just that: you may accidentally commit files you haven't actually changed. |
Does this impose any problem? |
I believe it does. SCMs are not only for ability to revert some changes, they're also able to provide sometimes crucial info about a piece of code. Thus checking in unrelated crap is not exactly desired. |
|
You do understand that would be informational noise which would not ease an investigation. |
Requirement to add LFs to all files makes much more noise. |
No, it's not. One in a lifetime setting to your editor. |
Nope. As you mentioned, there are tons of different tools, some of them add LF, and some do not. |
Actually, if you don't use windows, only tools we're using that don't add the last LF by default are WebStorm and SublimeText (these are known to me). |
I think
Using |
Please, explain the logic to me then:
|
Yeah, "portability" might be a little stretch. What I meant is portability across POSIX-compatible systems we use. Never the less, I think I've exhausted my arguments here. If the majority of concerned people is pro removing the rule, let's just do that. |
Let me note that other teams could have just opposite situation, i.e. much more windows than osx/linux systems. |
I vote for remove this rule from codestyle. |
my vote: keep the rule in the codestyle |
Keep the rule. |
Windows IDEs and editors can be configured to use POSIX EOL characters and automatically place new line chars at the end of files in a few clicks. @twirl why is this an issue? P.S. Even git will fire warnings if the file doesn't end with a new line. |
Not every Windows tool could be configured to use LFs. |
Notepad can't for sure. |
My suggestion is: do not state rules which are defined by developer tools stack since different teams use different stacks. |
Yep, you're right, but I think EOL in the end of file is a good rule to follow. |
We use POSIX systems and we haven't been facing any problems for at least last 3 years. |
That doesn't guarantee that you won't in the future. PS we should really discuss what goes in the codestyle - only how to write JS code, source file structure, Web API recommendation etc. I got really confused after all the issues you created. |
For me personally, it's a good practice to standardize an end of line:
I suggest to keep this rule for a while. It's not a big deal to support it. What do you think? |
I think the issue is about trailing blank line, not LF vs CRLF (that's just side story). |
My final suggestion is to keep this rule if we OK with unix and cli specific aspect in the codestyle. If we do not want to state this, it's may be worth to remove the rule. Also it applies to no-BOM and LF-only rules. |
I agree with @dmikis. Keep it. |
Okay. So, who makes final decision? |
I think @ikokostya must, because he is primary author of this codestyle. |
Hmm. Does @ikokostya act on behalf of all Yandex JavaScript developers? |
@dmikis, @tarmolov and me voted for keeping the rule. @dodev wasn't so explicit, but he said "I think EOL in the end of file is a good rule to follow", so I will count him on that side :) So, majority of participants of that discussion supports that rule. This issue can be closed. |
Don't hurry, please ;) |
@twirl I'm not sure why you against this rule. Pros:
Cons:
upd I'm working on Windows via putty (nano/mcedit) and in GUI (Sublime, earlier Intype/Idea/Netbeans/FAR) and OS X (Sublime/TextMate/terminal editors). And you really confusing me when saying "Not every Windows tool could be configured to use LFs" — can you tell me which one can't be configured? |
I've never seen such a warning from git or other tools I use. I should mention that we develop 1M+ lines of code project and never have any problem with EOLs since we stopped appending one file to another with
What about "Plurality is not to be posited without necessity" rule? |
@zloylos Removing is even worse than an opposite. Here we should decide to use EOL at EOF or don't. Explicitly. @tarmolov I know that Yandex codestyle is more common than BEM community, but canonical version has this rule and new one is based on Yandex jscs preset that also has this rule. It means that some other guys will vote for this rule (I don't know if it weights anything for ya), just fyi. |
This rule helps us keep our sources in same style and removes redundant git diffs. Of course you need setup your editor, but only once. |
Why using this rule in 2014?
Are you still making one large js file with
cat
?The text was updated successfully, but these errors were encountered: