hudochenkov / stylelint-order

A plugin pack of order related linting rules for Stylelint.
MIT License
916 stars 61 forks source link

Fixed order *within* flexible order? #64

Closed jsit closed 6 years ago

jsit commented 6 years ago

Say I want this to be valid:

div {
  margin: 0;
  margin-top: 10px;
  margin-right: 20px;
  padding: 0;
}

And I want this to be valid:

div {
  padding: 0;
  margin: 0;
  margin-top: 10px;
  margin-right: 20px;
}

But I want this to be invalid:

div {
  padding: 0;
  margin-right: 20px;
  margin: 0;
  margin-top: 10px;
}

In other words, I don't care whether padding or margin comes first, but I always want any margin properties to be in the same order.

The config might look something like this:

[
  {
    "properties": [
      {
        "properties": [
          "padding", "padding-top", "padding-right", "padding-bottom", "padding-left"
        ]
      },
      {
        "properties": [
          "margin", "margin-top", "margin-right", "margin-bottom", "margin-left"
        ]
      },
    ],
    "order": "flexible"
  }
]

This doesn't work, of course, but could something like it be made to work?

hudochenkov commented 6 years ago

It's impossible to achieve.

jsit commented 6 years ago

In theory, or in the current implementation?

hudochenkov commented 6 years ago

Sorry for a late response. It's impossible to achieve with the current implementation. And, I'm afraid, it will never be achieved because this request is quite unique.

If you wanted this feature to avoid error, when shorthand property overrides londhand property consider using declaration-block-no-shorthand-property-overrides.