-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for change of the indent options #92
Comments
Can you please provide examples of all those options in action? |
Updated the issue's text with examples. If it is still unclear, I could add more, just tell me which options or their combinations seem strange. |
@kizu, great work, thank you. If I understand everything correctly, those options should be renamed:
Reference links: css3 spec, css2 spec. block-start-space and block-end-spaceDoes I think that
Also |
Yes, of course, I'll change it in the text later, thanks.
Yes. On the second though I find current And the only case when the So, I guess we could just throw out the arrays and say those However, I now don't like those names much, so if anyone would find something better — it would be nice. |
BTW, here is an interesting tweet proposing replacing 4 spaces with 1 tab: https://twitter.com/Guldmand/status/402380200949723136 |
That should be |
I vote for this issue to be done next, before adding sass support. |
I have plans to start work on this issue, because it's a blocker for adding sass support. |
@tonyganch Woot. BTW, what do you think about renaming existing options like I suggested here? |
@tonyganch @kizu I agree with this issue but first I'd like to publish 2.0.0 version. |
Some more thoughts on the options names. The main ideas for those renames:
I again invite everyone to join me in discussing the names for the options: as this is one of the rare open API in CSSComb.js, the better those names would be the better, so we could find the nest possible way of naming things, so we won’t need to rename anything later. So it is better to think everything straight away and then use those rules on naming things for all future options. The optionsTab-sizeThe one option to control the behavior of
Available values: IndentsOptions that set the size of the indents before different entities:
Available values: SpacingsOptions that set the space around different entities: I’m not sure about those names; should we have options that would set the whitespace after those braces?
And more similar options could be added/renamed, as those (there is a question on the naming order of the
Available values: |
Options removed:
Options added:
I believe in two things:
All names are readable and self-explaining and all values are consistent:
No arrays and no objects. Those options are enough to reproduce current code styles without adding new functional. |
Ok, agree. |
Ready. Waiting for all 2.x.x-related issues to be closed first. |
I'm in a process of writing a The thing is commas could be in differen places, between:
And as those are really different places, it would make sense to provide a way of setting them independently. Like someone would want to have newlines between selectors, space after commas in values and no space in I see a two ways of doing this:
At first I thought about the first variant, but now I'm fond more of splitting this one option to the multiple ones. However, there is another thing: some people would want to set different option to some specific functions. So they would want no spaces in Or even it would make sense to wish different options between values for With the Object solution it would be not that hard to implement any number of such specific options, like this: {
"space-after-comma": {
"default": " ",
"selector": "\n",
"value": {
"backgrounds": "\n\t",
},
"function": {
"colors": "",
"gradients": "\n"
}
}
} Such object is nice and readable, but it would be hard to detect and some of the keys could be unguessable, so people would need to look deep into docs. But the splitted options for such cases would be even worse: we would need to create dozens of them and for some cases (like functions) we would need to add “shortcuts” for all of them and then play with the overrides. So, what'd you say, @tonyganch, @mishanga? Is there any other way to provide people with such variety of options, do you thing it is overengeneering (but I would really like to use different whitespaces for gradients/functions and newlines for backgrounds). Or maybe there is a simple way to provide people with some simple API to add their own options along the ones we described? Actually, I would see it would make to have an API for user-added options. |
@kizu, I'd say that objects and default values are evil because they are potentially confusing. I totally love the idea of |
Ok, then |
I'm closing the issue as it's become too broad. @kizu, thank you for ideas and great discussion. |
Current options for setting the indent of blocks,
block-indent
,rule-indent
andstick-brace
, are complete nonsense.Those names are hard to understand and their behaviour is not logical in any way.
tl;dr: in this issue I propose that some new options should be addeed,
block-indent
should be changed to only change the indent of the whole block,rule-indent
shouldn't be able to set newlines andstick-brace
should be trashed and replaced by options to set up the whitespace around curly braces.tab-size
optionThere should be a main option like
tab-size
, that should set the global indent size. Without any other settings this shouldn't do anything. It could be one of the following:[0-9]*|[ \t]*
When CSSComb sees the
\t
symbol (or an actual tab) inside other indent options, it should replace them with the value oftab-size
option.}
.bar { color: lime; }
}
}
root-indent
optionThis option should set the starting indent of each line. Who knows why it should be used, but there could be some cases where it would be logical.
}
.bar { color: lime; }
}
}
block-indent
optionThe only thing the
block-indent
option should do is to tell how the blocks of rules should be placed inside of things like media queries etc. It shouldn't change the way the whitespaces are placed around curly braces.}
@media print {
.foo {
color: blue;
}
.bar { color: lime; }
}
}
rule-indent
optionOk, that's the only option that could be saved as it is now I guess. Ah, except for it shouldn't create newlines, only tell how much whitespace should be there before rules. Ah, and it shouldn't do anything when there is no newline, like with
rule-delimiter
which don't have\n
in it.}
.bar { color: lime; }
}
declaration-delimiter
optionThat should tell should which whitespace should be there between the declarations. If it contains at least one
\n
symbol, then therule-indent
comes into play, otherwise it would be a oneliner.If there are no second value of
block-start-space
and/or first value ofblock-end-space
set, then thedeclaration-delimiter
is placed before the first rule and opening brace and after the last rule and closing brace.}
.bar { color: lime; background: red; }
}
}
}
block-start-space
andblock-end-space
optionsThose options should tell which whitespace should be there around the opening and closing curly braces.
If there is only one value (usual
true|false|[ \t\n]*|[0-9]
thingy), it should tell which whitespace should be there before the braces and if there would be an array of two values, then it would set the whitespace before and after the curly braces.One thing to mention is that the second value of
block-start-space
should override the whitespace (rule-indent
) between the opening curly brace and first rule when thedeclaration-delimiter
is set to be empty.}
.bar { color: lime; }
}
}
}
}
.bar { color: lime; }
}
rule-delimiter
optionThis option should set the whitespace around the rules. So there would be both ways to set things like
a{…} b{…}
,a{…}\n\na{…}
and others.This option should override the trailing newlines of the second value of
block-end-space
option.}
.bar { color: lime; }
}
}
Those changes would make it possible to recreate almost any code style, also it would be a base for allowing usage of smart (equal to the indent)
\t
in other whitespace rules, so we could align things in any possible way.The current available options are not capable of that, for example, tell me how to use them to create things like those (and it doesn't matter how stupid such code style would look, we should be agnostic to it).
etc.
Legacy
Yep, I want to change a lot of stuff, so things could break, so it maybe should be a major version number update. However, there could be made at least some fallbacks, like if there is a
stick-brace
option in settings, we could treat the other options in an old way (they would be actually just aliases to the proper options), and we could treat this way other old values that are not there in new proposal (liketrue
value forblock-indent
).While someone could find those options a bit oververbose, it is better to have a way to fully describe the code style. Also, the current
block-indent
,rule-indent
andstick-brace
are no better: I could understand how they work only after reading the code and tests.And those changes would allow us to detect the codestyle properly, and when #30 would be implemented, there wouldn't be a need for users to set almost any of the options manually, they could just use the CSS-templates for it.
And another thing — those changes would be a great base for future improvements of the overall whitespacing, like placing the multiple values on new lines with equal indents, having different settings for different cases (like allowing different whitespace settings for different kinds of blocks: uniform arrays of modifiers, keyframes etc).
Discuss :)
The text was updated successfully, but these errors were encountered: