Skip to content
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

Is there a way to sort declarations before nestings? #23

Closed
misund opened this issue Feb 20, 2017 · 6 comments
Closed

Is there a way to sort declarations before nestings? #23

misund opened this issue Feb 20, 2017 · 6 comments

Comments

@misund
Copy link

misund commented Feb 20, 2017

It would be nice to have a config parameter to output declarations before nestings.

Example

Before:

.foo {
  .bar {
    display: block;
  }

  display: block;
}

After:

.foo {
  display: block;

  .bar {
    display: block;
  }
}
@Siilwyn
Copy link
Owner

Siilwyn commented Feb 21, 2017

That could nice to have yes. Currently there is no way of doing this, I'm not fully convinced though as this also means moving the selector .bar instead of only declarations... 🤔

At the moment the selector in the middle will 'split' the sorting keeping the declarations at their original position compared to the selector while still being sorted.

Example

Before:

.foo {
  display: block;

  .bar {
    display: block;
  }
  display: block;
  animation: none;
}

After:

.foo {
  display: block;

  .bar {
    display: block;
  }
  animation: none;
  display: block;
}

@misund
Copy link
Author

misund commented Mar 9, 2017

This is what I am experiencing (using the atom package, with the command css-declaration-sorter:sort-smacss):

Before

.foo {
  display: block;

  .bar {
    display: block;
  }
  display: block;
  animation: none;
}

After

.foo {

  .bar {
    display: block;
  }
  display: block;
  display: block;
  animation: none;
}

@misund
Copy link
Author

misund commented Mar 9, 2017

For alphabetical sorting, it seems to work as expected

@Siilwyn
Copy link
Owner

Siilwyn commented Mar 9, 2017

Oh interesting find! It shouldn't modify the order like that... I will split this issue.

@misund
Copy link
Author

misund commented Mar 9, 2017

Moving declarations to the bottom was/is a blocker for me to actually use the plugin. If it's fixed by moving declarations to the top, it might be a blocker for others. If it's fixed by moving declarations anywhere (top or bottom), I think it should be configurable.

For my needs, fixing #29 would be sufficient.

@Siilwyn
Copy link
Owner

Siilwyn commented Mar 15, 2017

After asking around in the PostCSS gitter room, Twitter and #web room on freenode I have eight people all putting the declarations on the top. So this looks like sane standard behaviour.

Siilwyn added a commit that referenced this issue Mar 16, 2017
Siilwyn added a commit that referenced this issue Mar 16, 2017
Siilwyn pushed a commit that referenced this issue Mar 16, 2017
Siilwyn pushed a commit that referenced this issue Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants