-
Notifications
You must be signed in to change notification settings - Fork 4
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
Rule to enforce consistent order of composite values #23
Comments
Here's a list of CSS properties I've found and their tokens, which can be in any order.
|
I started writing code and realized that implementing a shorthand parser within this repository is somewhat redundant. Something like this: But these repositories are abandoned, don't work with some features, and generally work a bit differently than what we need for sorting already written properties. |
@MorevM Hi!
The first variant is more suitable, because for example the
Both points seem to be solved by combining two tokens into one, as in the list below for the All in all, everything looks not bad. |
I haven't had time to figure out the necessity of it yet. But... I've thought about inviting you into the organization before. And creating separate tools seems like a good reason to do so. The shorthand parser could be placed in the organization. @MorevM Have a desire to be part of the team? |
@firefoxic Hi, It will definitely be required.
In general, I wanted to make a universal shorthand parser like the links above... Although, on second thought, I have nowhere to use it except here :D So I might consider creating a specialized package with I'll message you in Discord, discuss details there if necessary :) |
Uh, do we have Discord? 👀 |
What is the problem you're trying to solve?
As a continuation of the idea raised here in the point 3, I suggest we discuss this in more detail here - naming and options.
I propose the following implementation plan:
Choose a name for the rule. I propose
composite-values-order
orshorthand-values-order
.Make a list of properties to which the rule needs to be applied. First of all these are shorthand properties like
animation
,transition
,background
and so on, but we need to decide about other values as well - for example, we can control the order of some keywords likeauto
inaspect-ratio
property (auto 1/2
and1/2 auto
both valid). I'm sure there are others like that.Make a list of tokens defining the constituents of each rule. I suggest using token names defined in MDN, for example for
animation
it would be['time', 'easing-option', 'single-animation-iteration-count', '...so on']
.Define what default order we wish to provide without the need for additional configuration. I guess we could also focus on MDN, although for some properties personally I prefer a slightly different order... But in terms of standards, I think it's better to stick to open authoritative sources.
In the end, I envision a configuration like this:
Potential problems:
Properties that have some conditions (for example, in the
font
property, theline-height
part can only come afterfont-size
, there is a similar thing forbackground
property, and so on).I don't think they can be thrown out from the configuration - we should probably come up with own compound tokens for these properties (e.g.
font-size-and-line-height
), but it's not very clear what to do in case of misconfiguration (lack of mandatory part) - Stylelint, as far as I know, doesn't provide a way to notify the user about invalid configuration. We'll probably have to leave that up to the users.Other user misconfiguration - for example, listing not all required tokens. What to do with the remaining ones? It looks like the rule should be turned off in such cases, but how the user should know about - it's still a question.
Some of compound parts may have an optional order within it. Referring to MDN,
linear-stop
part may have a conditional order of compound parts.We'll probably have to add tokens that don't match CSS properties to the configuration for such scenarios.
So, what do you think about the name, non-shorthand properties handling, about defaults and so on?
If there are any other clarifications/opinions, I'd love to hear them. For now, I plan to go with this plan, recording progress here.
It's a long and rather difficult task, but I believe this can be done.
What solution would you like to see?
I will start working on the implementation according to the plan above after receiving feedback :)
The text was updated successfully, but these errors were encountered: