csscomb / csscomb.js

CSS coding style formatter
http://csscomb.com/
MIT License
3.28k stars 459 forks source link

Extra indentation when using "lines-between-rulesets" #610

Open henriquebs12 opened 5 years ago

henriquebs12 commented 5 years ago

Consider the following CSS:

Before:

body {
    background-color: #111;
}.landing-page {
    color: black;
}

Expected behavior:

body {
    background-color: #111;
}

.landing-page {
    color: black;
}

After CSSComb:

body {
    background-color: #111;
}

    .landing-page {
    color: black;
}

Problem confirmed in Sublime and VS Code. So there is definitely something wrong when using

"block-indent": "    ",
"lines-between-rulesets": 1,

The rest of my configs:

                "remove-empty-rulesets": true,
                "always-semicolon": true,
                "color-case": "lower",
                "color-shorthand": true,
                "block-indent": "    ",
                "element-case": "lower",
                "eof-newline": true,
                "leading-zero": true,
                "quotes": "single",
                "sort-order-fallback": "abc",
                "space-after-colon": " ",
                "space-before-combinator": " ",
                "space-after-combinator": " ",
                "space-between-declarations": "\n",
                "space-before-opening-brace": " ",
                "space-after-opening-brace": "\n",
                "space-after-selector-delimiter": 1,
                "space-before-selector-delimiter": "",
                "space-before-closing-brace": "\n",
                "strip-spaces": true,
                "tab-size": true,
                "unitless-zero": true,
                "vendor-prefix-align": true,
                "lines-between-rulesets": 1
ryanaltvater commented 5 years ago

@henriquebs12 Change lines-between-rulesets to be true instead of 1. You just helped me solve my search for adding lines between rulesets. When I copied your code with a 1, I got the same issue you're running into. When I changed it to true, I got the expected output. Hope that helps, and thank you for indirectly helping me!

ryanaltvater commented 5 years ago

@henriquebs12 Never mind. It's a really weird behavior. When I set the value to 1 and run CSScomb, I get the issue. I set it to true instead and it makes it the expected output. If I leave it as true and paste in fresh CSS to be formatted, I don't get any lines between rulesets. I have to set it to 1 again, run CSScomb, and then set it to true and run CSScomb to get the correct output. Sorry about that. :/

darkxio commented 5 years ago

Good day! To correct the indention, I changed the value in the file lines-between-rulesets.js of 'runBefore ()' function:

from

get runBefore () {
    return 'block-indent';
},

to

get runBefore () {
    return 'tab-size';
},

After that, it began to work as it should! I hope that I will help someone ...