-
Notifications
You must be signed in to change notification settings - Fork 889
More lenient "indent": [true, "tabs"] #1306
Comments
ooh this seems like holy war fodder. Mixing tabs and spaces? It should probably be an additional option, and you can't hard code the max space count to 4 because other users might set tabwidth to 2 or 8 (that's the whole point of tabs I believe). |
Yes, holy war fodder indeed. I should have been more generic; a better proposal would be to add to the indent rule:
It could look like: {
"indent": [
true,
"tabs",
{
"allow-spaces": true/2/4/"infinite" // false by default, any number, or "infinite"
}
]
} |
Let me leave my 5 coins here: when we decided to use tabs for spacing in our company, we figured out that it's only worth to use tabs for all type of spacing. Like this: if (
~~~>longArgumentlongArgumentlongArgument
~~~>&& anotherLongArgumentanotherLongArgument
) {
~~~>hereICallSomeMethod(
~~~>~~~>withLongParameterName1,
~~~>~~~>withLongParameterName2
~~~>)
} After 5 years of using this rule (now we switched to 2 spaces) I can tell you this was the right decision! |
@olegstepura can you precise which one is the right decision. It's not clear for me in your comment. Tabs or 2 spaces. Thank |
We switched to 2 spaces to be consistent with the rest of the world. The right decision is to use the standard which is used by most of open source in the scope of the language you operate. We used tabs for It's actually up to you which one to choose, but I would recommend inspecting what is used by the open source software you will use (framework, maybe some big libraries). But I will continue to use 2 spaces ;) |
Thank, I better understand your comment. And I see you point of view. 2016-06-15 15:33 GMT+02:00 Oleg Stepura [email protected]:
Richard Lasjunies |
Using spaces after tabs seems very non-standard to me. I don't care at all whether projects choose to use spaces or tabs, but I'm not convinced we want to promote any combination of both. If we do, off-by-default as #1317 does is definitely the right way to go, but I feel hesitant that this should be part of the core rules at all. |
In defense of the rule, the ideology of maintaining a single style is good to have, but it doesn't hold up in all corner cases. Take the ~~~>if-(longArgumentlongArgumentlongArgument
~~~>~~~>&& anotherLongArgumentanotherLongArgument) { ~~~>if-(longArgumentlongArgumentlongArgument
~~~>---&& anotherLongArgumentanotherLongArgument) { ~~~>if-(longArgumentlongArgumentlongArgument
~~~>----&& anotherLongArgumentanotherLongArgument) { Allowing spaces after the tabs doesn't violate the tab ideology of allowing any width for them because they're aligning to the characters above. It's necessary to use spaces for vertical alignment: they're synced to the text content rather than indentation level. ~~~>while-(longArgumentlongArgumentlongArgument
~~~>-------&& anotherLongArgumentanotherLongArgument) { All that being said, if you'd prefer to keep out of this warzone that's reasonable as well. I'm playing devil's advocate here: IMO spaces are obviously better than tabs! |
@JoshuaKGoldberg such code becomes broken too often. Extra space can be left after tab, some editors would convert other 4 spaces to tabs and viola, we got this:
visually |
@olegstepura Is that sample not a violation of the proposed cases? The feature proposal is to allow a limited number of spaces after tabs, not interspersed within. I agree with @jkillian that we shouldn't be advocating one style over others. From my understanding the debate is whether the style is legitimate enough to justify being included in tslint core at the risk of allowing (advocating for?) improper behavior. |
@JoshuaKGoldberg you're right, my example was about mixing tabs with spaces, not just ending tabs with spaces. But that was an example of evil mixing tabs with spaces. Just choose one method and you will find a way to workaround your issue (as I mentioned earlier, for example) |
I understand why this rule would help in @JoshuaKGoldberg's situation, but overall mixing tabs and spaces doesn't seem like an idea we want to encourage, so I'm going to close this. Thanks for all the input everyone! |
Consider the following formatting where
~~~>
is a tab and-
is a space:This gets flagged by the indent rule.
Would you be up for me adding an option to allow <4 spaces at the end of the tabs?
The text was updated successfully, but these errors were encountered: