postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.15k stars 66 forks source link

Incorrect spacing of compiled CSS #85

Closed mccoyrjm closed 5 years ago

mccoyrjm commented 5 years ago

Writing a basic parent-child selector like this

.class1 {
  .class2 {
    property: value;
  }
}

results in an incorrect format on the compiled CSS in lines 2 & 3. Those lines are using the spacing from lines 2 & 4 from the Pre-Compiled code.

.class1 .class2 {
    property: value; /* 4 spaces before */
  } /* 2 spaces before */

Per the documentation, I'd expect line 2 to have 2 spaces before and line 3 to have none.

Here is a link to a codepen using the postcss-nested plugin demonstrating this behavior.

Steps to Replicate

  1. On a new Codepen, pick PostCSS as the CSS Pre-Processor.
  2. Add postcss-nested plugin.
  3. Write PostCSS as described earlier.
  4. Select View Compiled CSS
ai commented 5 years ago

Sorry, it is too many edge cases to trying to keep origin code style.

Just use any PostCSS plugin to force the style which you want. You can use Stylelint or stylefmt.