diff --git a/.travis.yml b/.travis.yml index 432dbd02..f98fed06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: node_js node_js: - - '11' + - '12' - '10' - '8' - - '6' diff --git a/README.md b/README.md index 94da9d3d..2fcf8448 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ comb.processPath('assets/css'); This project is actively mantained. But anyone and everyone is welcome to contribute. Please take a moment to review the [guidelines for contributing](CONTRIBUTING.md). -Also you can become a mantainer. To do that please ping +Also you can become a maintainer. To do that please ping [@tonyganch](https://github.com/tonyganch). ## Authors diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 482e0259..141734b6 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -171,7 +171,10 @@ module.exports = { _getSortablePropertyName(node) { if (node.is('declaration')) { - let property = node.first('property').first(); + let property = node.first('property'); + if (property === null) property = node.first('customProperty'); + + property = property.first(); return property.is('variable') ? '$variable' : property.content; } @@ -382,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/core/css/test.js b/test/core/css/test.js new file mode 100644 index 00000000..a3bbbb93 --- /dev/null +++ b/test/core/css/test.js @@ -0,0 +1,11 @@ +const Test = require('../core_test'); + +describe('css', function() { + it('Should parse variables', function() { + const test = new Test(this); + + test.comb.configure({}); + + return test.shouldBeEqual('variable.css'); + }); +}); diff --git a/test/core/css/variable.css b/test/core/css/variable.css new file mode 100644 index 00000000..dd6becf9 --- /dev/null +++ b/test/core/css/variable.css @@ -0,0 +1,3 @@ +div { + --color: red; +} 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; }