Closed gajus closed 5 years ago
For me this isn't fixed. Still get this issue when I use variables or at-rules. :/
Windows 10, vscode insider build and stable build csscomb 4.2.0
config:
{
"always-semicolon": true,
"color-case": "lower",
"block-indent": "\t",
"color-shorthand": false,
"element-case": "lower",
"eof-newline": true,
"leading-zero": true,
"quotes": "double",
"sort-order-fallback": "abc",
"space-before-colon": "",
"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": "\n",
"space-before-selector-delimiter": "",
"space-before-closing-brace": "\n",
"strip-spaces": true,
"unitless-zero": true,
"vendor-prefix-align": true,
"sort-order": [
// ....
]
}
For me, csscomb stops working if the scss file has an @-rule or a scoped variable in it:
// doesn't work
#header {
width: 100%;
@include blackBg;
}
// doesn't work
#header {
width: 100%;
$headerHeight: 64px;
}
// does work
#header {
width: 100%;
height: $headerHeight;
}
// does work
#header {
width: 100%;
#{$bg}-color: blue
}
In the cases it doesn't work, csscomb throws me an error:
TypeError: a.match is not a function
When I remove my sort-order property from the config, everything works fine. :)
This should be fixed in the latest release now that the sortLeftovers
uses
a = a.node.first().first().content;
b = b.node.first().first().content;
still getting this issue
Hi @JiniHendrix!
Can you create a small repro repo that demonstrates the issue for me to investigate.
hey @jdalton here's an example repo https://github.com/JiniHendrix/csscomb-sort-break
thanks!
Thank you @JiniHendrix!
Yep, the issue still persists. Let's fix it together! Would you be up for creating a failing test case in a PR that I can write a patch against?
ill give it a shot 👍
Rock! The issue is that because left-overs can be a variety of things, one of those being a Variable node which has content
as an array (instead of a string like the Ident node).
@jdalton looks like there already is a test for it, and it's passing. may need to refactor the tests.
test/options/sort-order/process/test.js line 413
dont really have the time for it unfortunately, seems like you know how to fix the issue though?
If you're up for the refactor that would be appreciated too : )
Ah okay, sorry. I posted my initial reply before the newer comments popped in. No worries. Thanks for pin pointing the existing test!
Update:
Patch PR started at #609.
hey @jdalton thanks for fixing the issue. any idea when this will be published?
Produces:
I did a bit of debugging:
This is
sortLeftovers
function fromsort-order.js
that triggers the error.The output of
console.log
is: