diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 91b9c679..141734b6 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -385,6 +385,14 @@ module.exports = { a = a.node.first().first().content; b = b.node.first().first().content; + if (Array.isArray(a)) { + a = a[0].content; + } + + if (Array.isArray(b)) { + b = b[0].content; + } + // Get prefix and unprefixed part. For example: // ['-o-animation', '-o-', 'animation'] // ['color', '', 'color'] diff --git a/test/options/sort-order-fallback/process/scss/leftovers-variable.expected.scss b/test/options/sort-order-fallback/process/scss/leftovers-variable.expected.scss new file mode 100644 index 00000000..a7d2eca2 --- /dev/null +++ b/test/options/sort-order-fallback/process/scss/leftovers-variable.expected.scss @@ -0,0 +1 @@ +div {$blue: steelblue; $red: tomato; } diff --git a/test/options/sort-order-fallback/process/scss/leftovers-variable.scss b/test/options/sort-order-fallback/process/scss/leftovers-variable.scss new file mode 100644 index 00000000..efe7eb6c --- /dev/null +++ b/test/options/sort-order-fallback/process/scss/leftovers-variable.scss @@ -0,0 +1 @@ +div {$red: tomato; $blue: steelblue; } diff --git a/test/options/sort-order-fallback/process/test.js b/test/options/sort-order-fallback/process/test.js index 9127d943..6ef495e0 100644 --- a/test/options/sort-order-fallback/process/test.js +++ b/test/options/sort-order-fallback/process/test.js @@ -41,4 +41,15 @@ describe('Option `sort-order-fallback`, process', function() { return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); + + describe('scss', function() { + it('Should sort leftover variables alphabetically', function() { + let config = { + 'sort-order': [], + 'sort-order-fallback': 'abc' + }; + let test = new Test(this, config); + return test.shouldBeEqual('leftovers-variable.scss', 'leftovers-variable.expected.scss'); + }); + }); }); diff --git a/test/options/sort-order/process/scss/variable.expected.scss b/test/options/sort-order/process/scss/variable.expected.scss index c17c6341..a7359b10 100644 --- a/test/options/sort-order/process/scss/variable.expected.scss +++ b/test/options/sort-order/process/scss/variable.expected.scss @@ -1 +1 @@ -div {$red: tomato; color: $tomato; } +div {$red: tomato; color: $red; } diff --git a/test/options/sort-order/process/scss/variable.scss b/test/options/sort-order/process/scss/variable.scss index f759f22c..967fd4f0 100644 --- a/test/options/sort-order/process/scss/variable.scss +++ b/test/options/sort-order/process/scss/variable.scss @@ -1 +1 @@ -div { color: $tomato; $red: tomato; } +div { color: $red; $red: tomato; }