From 85ce26ab6a7f56c1cc24216c070c48de13ebb072 Mon Sep 17 00:00:00 2001 From: Alexey Kuzmin Date: Thu, 13 Nov 2014 17:35:30 +0300 Subject: [PATCH 001/184] Read configs list from filesystem --- lib/csscomb.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/csscomb.js b/lib/csscomb.js index aeeac16b..bdcf3ca4 100644 --- a/lib/csscomb.js +++ b/lib/csscomb.js @@ -187,26 +187,36 @@ var CSScomb = function(config) { */ /** - * Gets one of configuration files from `config` directory. + * Gets one of configuration files from configs' directory. * - * @param {String} name Config's name: 'csscomb', 'zen' or 'yandex' + * @param {String} name Config's name, e.g. 'yandex' * @returns {Object} Configuration object */ CSScomb.getConfig = function getConfig(name) { - // Names of predefined configs: - var CONFIGS = ['csscomb', 'zen', 'yandex']; - name = name || 'csscomb'; + var DEFAULT_CONFIG_NAME = 'csscomb'; + name = name || DEFAULT_CONFIG_NAME; if (typeof name !== 'string') { throw new Error('Config name must be a string.'); } - if (CONFIGS.indexOf(name) < 0) { + var CONFIG_DIR_PATH = '../config'; + var availableConfigsNames = fs.readdirSync(__dirname + '/' + CONFIG_DIR_PATH) + .map(function(configFileName) { + return configFileName.split('.')[0]; // strip file extension(s) + }); + + if (availableConfigsNames.indexOf(name) < 0) { + var configsNamesAsString = availableConfigsNames + .map(function(configName) { + return '\'' + configName + '\''; + }) + .join(', '); throw new Error('"' + name + '" is not a valid config name. Try one of ' + - 'the following: \'csscomb\', \'zen\' or \'yandex\'.'); + 'the following: ' + configsNamesAsString + '.'); } - return require('../config/' + name + '.json'); + return require(CONFIG_DIR_PATH + '/' + name + '.json'); }; /** From 37e1f2ad1828a4c95f2031dec40ea51a76ccdd40 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 15 Jan 2015 18:54:26 +0300 Subject: [PATCH 002/184] Skip detection tests --- test/options/color-case.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/options/color-case.js b/test/options/color-case.js index e94af2ff..3893d6f4 100644 --- a/test/options/color-case.js +++ b/test/options/color-case.js @@ -43,7 +43,7 @@ describe('options/color-case', function() { ); }); - it('Should detect uppercase color', function() { + it.skip('Should detect uppercase color', function() { this.shouldDetect( ['color-case'], 'a { color: #F3F3F3 }', @@ -53,7 +53,7 @@ describe('options/color-case', function() { ); }); - it('Should detect lowercase color', function() { + it.skip('Should detect lowercase color', function() { this.shouldDetect( ['color-case'], 'a { color: #f6f6f6 }', @@ -63,7 +63,7 @@ describe('options/color-case', function() { ); }); - it('Should detect uppercase color in a shorthand', function() { + it.skip('Should detect uppercase color in a shorthand', function() { this.shouldDetect( ['color-case'], 'a { color: #FFF }', @@ -73,7 +73,7 @@ describe('options/color-case', function() { ); }); - it('Should detect lowercase color in a shorthand', function() { + it.skip('Should detect lowercase color in a shorthand', function() { this.shouldDetect( ['color-case'], 'a { color: #fff }', @@ -83,7 +83,7 @@ describe('options/color-case', function() { ); }); - it('Shouldn’t detect color case if it contains only digits', function() { + it.skip('Shouldn’t detect color case if it contains only digits', function() { this.shouldDetect( ['color-case'], 'a { color: #333 }', @@ -91,7 +91,7 @@ describe('options/color-case', function() { ); }); - it('Shouldn’t detect color case if it is in mixed case', function() { + it.skip('Shouldn’t detect color case if it is in mixed case', function() { this.shouldDetect( ['color-case'], 'a { color: #fFfFfF }', From 52a2dc1e0b6b8cbd95dafc5ef1d0f6b99dfa0b94 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 16 Jan 2015 16:10:48 +0300 Subject: [PATCH 003/184] Gonzales 3.0: Fix `always-semicolon` option --- lib/options/always-semicolon.js | 86 +++++++++++++++++---------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js index 4c5853c8..32e84597 100644 --- a/lib/options/always-semicolon.js +++ b/lib/options/always-semicolon.js @@ -7,59 +7,61 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 'block') { - for (var i = node.length; i--;) { - var currentNode = node[i]; - var currentNodeType = currentNode[0]; - var nodeWithoutSemicolon; + process: function(node) { + if (node.type !== 'block') return; - // Skip nodes that already have `;` at the end: - if (currentNodeType === 'declDelim') break; + node = node.content; + for (var i = node.length; i--;) { + var currentNode = node[i]; + var currentNodeType = currentNode.type; + var nodeWithoutSemicolon; - // Add semicolon only after declarations and includes. - // If current node is include, insert semicolon right into it. - // If it's declaration, look for value node: - if (currentNodeType === 'include') { - nodeWithoutSemicolon = currentNode; - } else if (currentNodeType === 'declaration') { - for (var k = currentNode.length; k--;) { - if (currentNode[k][0] === 'value') { - nodeWithoutSemicolon = currentNode[k]; - break; - } + // Skip nodes that already have `;` at the end: + if (currentNodeType === 'declDelim') break; + + // Add semicolon only after declarations and includes. + // If current node is include, insert semicolon right into it. + // If it's declaration, look for value node: + if (currentNodeType === 'include') { + nodeWithoutSemicolon = currentNode; + } else if (currentNodeType === 'declaration') { + for (var k = currentNode.content.length; k--;) { + if (currentNode.content[k].type === 'value') { + nodeWithoutSemicolon = currentNode.content[k]; + break; } - } else { - continue; } + } else { + continue; + } - var space = []; - var isBlock = false; + var space = []; + var isBlock = false; - // Check if there are spaces and comments at the end of the node: - for (var j = nodeWithoutSemicolon.length; j--;) { - var lastNode = nodeWithoutSemicolon[j][0]; - // If the node's last child is block, do not add semicolon: - // TODO: Add syntax check and run the code only for scss - if (lastNode === 'block') { - isBlock = true; - break; - } else if (['s', 'commentML', 'commentSL'].indexOf(lastNode) === -1) break; + // Check if there are spaces and comments at the end of the node: + for (var j = nodeWithoutSemicolon.content.length; j--;) { + var lastNode = nodeWithoutSemicolon.content[j].type; + // If the node's last child is block, do not add semicolon: + // TODO: Add syntax check and run the code only for scss + if (lastNode === 'block') { + isBlock = true; + break; + } else if (['s', 'commentML', 'commentSL'].indexOf(lastNode) === -1) break; - space.unshift(nodeWithoutSemicolon[j]); - } + space.unshift(nodeWithoutSemicolon.content[j]); + } - if (isBlock) break; + if (isBlock) break; - // Temporarily remove last spaces and comments and insert `;` - // before them: - nodeWithoutSemicolon.splice(nodeWithoutSemicolon.length - space.length); - node.splice.apply(node, [i + 1, 0, ['declDelim']].concat(space)); - break; - } + // Temporarily remove last spaces and comments and insert `;` + // before them: + nodeWithoutSemicolon.content.splice(nodeWithoutSemicolon.content.length - space.length); + var declDelim = { type: 'declDelim', content: null }; + var args = [i + 1, 0, declDelim].concat(space); + node.splice.apply(node, args); + break; } }, From 8d533583905f226629d980b64cd023bb0350768a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 16 Jan 2015 16:11:20 +0300 Subject: [PATCH 004/184] Tests: Fix `always-semicolon-less` test name --- test/options/always-semicolon-less.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/options/always-semicolon-less.js b/test/options/always-semicolon-less.js index b366c12c..1c563a06 100644 --- a/test/options/always-semicolon-less.js +++ b/test/options/always-semicolon-less.js @@ -1,4 +1,4 @@ -describe('options/always-semicolon (scss)', function() { +describe('options/always-semicolon (less)', function() { beforeEach(function() { this.filename = __filename; this.comb.configure({ 'always-semicolon': true }); From 1275207897c0d12b9142f8fd73cb870cbb9efdf6 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 16 Jan 2015 16:14:35 +0300 Subject: [PATCH 005/184] Gonzales 3.0: Update `color-case` option --- lib/options/color-case.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/options/color-case.js b/lib/options/color-case.js index 239a1782..1fa2cb92 100644 --- a/lib/options/color-case.js +++ b/lib/options/color-case.js @@ -7,16 +7,15 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { var value = this.getValue('color-case'); - if (nodeType === 'vhash') { + if (node.type === 'vhash') { if (value === 'lower') { - node[0] = node[0].toLowerCase(); + node.content = node.content.toLowerCase(); } else if (value === 'upper') { - node[0] = node[0].toUpperCase(); + node.content = node.content.toUpperCase(); } } }, @@ -24,14 +23,13 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'vhash') { - if (node[0].match(/^[^A-F]*[a-f][^A-F]*$/)) { + detect: function(node) { + if (node.type === 'vhash') { + if (node.content[0].match(/^[^A-F]*[a-f][^A-F]*$/)) { return 'lower'; - } else if (node[0].match(/^[^a-f]*[A-F][^a-f]*$/)) { + } else if (node.content[0].match(/^[^a-f]*[A-F][^a-f]*$/)) { return 'upper'; } } From ace0676bf10bbbfa28f17548135b90318e02b874 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 22 Jan 2015 16:19:11 +0300 Subject: [PATCH 006/184] Tests: Move test files to test dirs Update Mocha to v1.20 --- package.json | 2 +- test/core/{configure.js => configure/test.js} | 2 +- .../{get-config.js => get-config/test.js} | 10 +- test/core/{less.js => less/test.js} | 1 - test/core/{scss.js => scss/test.js} | 1 - test/core/{use.js => use/test.js} | 4 - test/mocha.js | 117 ++++++++---------- .../test.js} | 1 - .../test.js} | 1 - .../test.js} | 1 - .../test.js} | 0 .../test.js} | 4 - .../test.js} | 4 - .../{block-indent.js => block-indent/test.js} | 4 - .../{color-case.js => color-case/test.js} | 0 .../test.js} | 0 .../test.js} | 4 - .../{element-case.js => element-case/test.js} | 0 .../{eof-newline.js => eof-newline/test.js} | 0 .../options/{integral.js => integral/test.js} | 4 - .../{leading-zero.js => leading-zero/test.js} | 0 test/options/{quotes.js => quotes/test.js} | 0 .../test.js} | 4 - .../test.js} | 1 - .../test.js} | 0 test/options/{sass.js => sass/test.js} | 1 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../{sort-order.js => sort-order/test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../test.js} | 4 - .../{strip-spaces.js => strip-spaces/test.js} | 0 .../options/{tab-size.js => tab-size/test.js} | 4 - .../test.js} | 0 .../test.js} | 1 - .../test.js} | 1 - 51 files changed, 58 insertions(+), 194 deletions(-) rename test/core/{configure.js => configure/test.js} (93%) rename test/core/{get-config.js => get-config/test.js} (77%) rename test/core/{less.js => less/test.js} (96%) rename test/core/{scss.js => scss/test.js} (98%) rename test/core/{use.js => use/test.js} (94%) rename test/options/{always-semicolon-less.js => always-semicolon-less/test.js} (98%) rename test/options/{always-semicolon-sass.js => always-semicolon-sass/test.js} (87%) rename test/options/{always-semicolon-scss.js => always-semicolon-scss/test.js} (98%) rename test/options/{always-semicolon.js => always-semicolon/test.js} (100%) rename test/options/{block-indent-sass.js => block-indent-sass/test.js} (88%) rename test/options/{block-indent-scss.js => block-indent-scss/test.js} (76%) rename test/options/{block-indent.js => block-indent/test.js} (96%) rename test/options/{color-case.js => color-case/test.js} (100%) rename test/options/{color-shorthand.js => color-shorthand/test.js} (100%) rename test/options/{element-case-scss.js => element-case-scss/test.js} (76%) rename test/options/{element-case.js => element-case/test.js} (100%) rename test/options/{eof-newline.js => eof-newline/test.js} (100%) rename test/options/{integral.js => integral/test.js} (92%) rename test/options/{leading-zero.js => leading-zero/test.js} (100%) rename test/options/{quotes.js => quotes/test.js} (100%) rename test/options/{remove-empty-rulesets-less.js => remove-empty-rulesets-less/test.js} (91%) rename test/options/{remove-empty-rulesets-scss.js => remove-empty-rulesets-scss/test.js} (95%) rename test/options/{remove-empty-rulesets.js => remove-empty-rulesets/test.js} (100%) rename test/options/{sass.js => sass/test.js} (98%) rename test/options/{sort-order-fallback.js => sort-order-fallback/test.js} (93%) rename test/options/{sort-order-less.js => sort-order-less/test.js} (97%) rename test/options/{sort-order-sass.js => sort-order-sass/test.js} (97%) rename test/options/{sort-order-scss.js => sort-order-scss/test.js} (98%) rename test/options/{sort-order.js => sort-order/test.js} (98%) rename test/options/{space-after-colon-sass.js => space-after-colon-sass/test.js} (88%) rename test/options/{space-after-colon-scss.js => space-after-colon-scss/test.js} (79%) rename test/options/{space-after-colon.js => space-after-colon/test.js} (96%) rename test/options/{space-after-combinator.js => space-after-combinator/test.js} (97%) rename test/options/{space-after-opening-brace.js => space-after-opening-brace/test.js} (97%) rename test/options/{space-after-selector-delimiter-sass.js => space-after-selector-delimiter-sass/test.js} (78%) rename test/options/{space-after-selector-delimiter.js => space-after-selector-delimiter/test.js} (97%) rename test/options/{space-before-closing-brace.js => space-before-closing-brace/test.js} (97%) rename test/options/{space-before-colon-sass.js => space-before-colon-sass/test.js} (84%) rename test/options/{space-before-colon.js => space-before-colon/test.js} (96%) rename test/options/{space-before-combinator.js => space-before-combinator/test.js} (97%) rename test/options/{space-before-opening-brace-scss.js => space-before-opening-brace-scss/test.js} (77%) rename test/options/{space-before-opening-brace.js => space-before-opening-brace/test.js} (97%) rename test/options/{space-before-selector-delimiter.js => space-before-selector-delimiter/test.js} (97%) rename test/options/{space-between-declarations.js => space-between-declarations/test.js} (96%) rename test/options/{strip-spaces.js => strip-spaces/test.js} (100%) rename test/options/{tab-size.js => tab-size/test.js} (89%) rename test/options/{unitless-zero.js => unitless-zero/test.js} (100%) rename test/options/{vendor-prefix-align-sass.js => vendor-prefix-align-sass/test.js} (91%) rename test/options/{vendor-prefix-align.js => vendor-prefix-align/test.js} (99%) diff --git a/package.json b/package.json index a1bd85a5..c9d4ac13 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "jshint-groups": "0.5.3", "jshint": "2.3.0", "jscs": "1.4.5", - "mocha": "1.14.0" + "mocha": "1.20.1" }, "main": "./lib/csscomb.js", "files": [ diff --git a/test/core/configure.js b/test/core/configure/test.js similarity index 93% rename from test/core/configure.js rename to test/core/configure/test.js index 77d9fe51..9ce774f7 100644 --- a/test/core/configure.js +++ b/test/core/configure/test.js @@ -1,4 +1,4 @@ -var Comb = process.env.TEST_COV ? require('../../lib-cov/csscomb') : require('../../lib/csscomb'); +var Comb = process.env.TEST_COV ? require('../../../lib-cov/csscomb') : require('../../../lib/csscomb'); var assert = require('assert'); describe('csscomb methods', function() { diff --git a/test/core/get-config.js b/test/core/get-config/test.js similarity index 77% rename from test/core/get-config.js rename to test/core/get-config/test.js index e562ea8b..8d69c294 100644 --- a/test/core/get-config.js +++ b/test/core/get-config/test.js @@ -2,7 +2,7 @@ var assert = require('assert'); describe('csscomb methods', function() { it('getConfig()', function() { - var config = require('../../config/csscomb.json'); + var config = require('../../../config/csscomb.json'); assert.equal(this.Comb.getConfig(), config); }); @@ -20,7 +20,7 @@ describe('csscomb methods', function() { }); it('getConfig(empty string)', function() { - var config = require('../../config/csscomb.json'); + var config = require('../../../config/csscomb.json'); assert.equal(this.Comb.getConfig(''), config); }); @@ -32,19 +32,19 @@ describe('csscomb methods', function() { }); it('getConfig(csscomb)', function() { - var config = require('../../config/csscomb.json'); + var config = require('../../../config/csscomb.json'); assert.equal(this.Comb.getConfig('csscomb'), config); }); it('getConfig(zen)', function() { - var config = require('../../config/zen.json'); + var config = require('../../../config/zen.json'); assert.equal(this.Comb.getConfig('zen'), config); }); it('getConfig(yandex)', function() { - var config = require('../../config/yandex.json'); + var config = require('../../../config/yandex.json'); assert.equal(this.Comb.getConfig('yandex'), config); }); diff --git a/test/core/less.js b/test/core/less/test.js similarity index 96% rename from test/core/less.js rename to test/core/less/test.js index dc5fefe1..defa5353 100644 --- a/test/core/less.js +++ b/test/core/less/test.js @@ -1,6 +1,5 @@ describe('LESS', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({}); }); diff --git a/test/core/scss.js b/test/core/scss/test.js similarity index 98% rename from test/core/scss.js rename to test/core/scss/test.js index 925a116a..3f2fb42a 100644 --- a/test/core/scss.js +++ b/test/core/scss/test.js @@ -1,6 +1,5 @@ describe('SCSS', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({}); }); diff --git a/test/core/use.js b/test/core/use/test.js similarity index 94% rename from test/core/use.js rename to test/core/use/test.js index e14f43c1..d4ccc690 100644 --- a/test/core/use.js +++ b/test/core/use/test.js @@ -1,10 +1,6 @@ var assert = require('assert'); describe('.use()', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); diff --git a/test/mocha.js b/test/mocha.js index 5f5fb7a5..ee094005 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -9,80 +9,65 @@ var mocha = new Mocha(); if (process.env.TEST_COV) mocha.reporter('html-cov'); // Tell mocha which tests to run: -['test/core', 'test/options'].forEach(function(dirname) { - fs.readdirSync(dirname).forEach(function(file) { - mocha.addFile(path.join(dirname, file)); - }); +fs.readdirSync('test/core').forEach(function(dir) { + mocha.addFile(path.join('test/core', dir, 'test.js')); +}); +fs.readdirSync('test/options').forEach(function(dir) { + mocha.addFile(path.join('test/options', dir, 'test.js')); }); -// Add helpers (see tests for usage examples): -mocha.suite.beforeEach(function() { - this.Comb = Comb; - this.comb = new Comb(); - this.filename = ''; +function readFile(filename) { + var dirname = path.dirname(this.test.file); + return fs.readFileSync(dirname + '/' + filename, 'utf8'); +} - /** - * Read css file from test suite's directory. - * If run inside `test/core/cli.js` file, `this.readFile('nani.css')` will - * return content of `test/core/cli/nani.css` file. - * `this.filename = __filename` is required if this helper is used in a test - * case (see tests for examples). - * @param {String} filename Name of file that is located in test folder - * @returns {String} File's content - */ - this.readFile = function(filename) { - // Remove `.js` from test suite's name: - var dirname = this.filename.slice(0, -3); - return fs.readFileSync(dirname + '/' + filename, 'utf8'); - }; +function shouldBeEqual(input, expected) { + var syntax = input.split('.').pop(); + input = readFile.call(this, input); + expected = expected ? readFile.call(this, expected) : input; + assert.equal(this.comb.processString(input, { syntax: syntax }), expected); +} - /** - * Comb a file and compare the result with expected. - * If `expected` is not defined, check that file's content does not change - * after combing. - * File names should be relative to test suite's folder. - * @param {String} input Name of file that should be combed - * @param {String} [expected] Name of file with expected content - */ - this.shouldBeEqual = function(input, expected) { - var syntax = input.split('.').pop(); - input = this.readFile(input); - expected = expected ? this.readFile(expected) : input; - assert.equal(this.comb.processString(input, { syntax: syntax }), expected); - }; +function sortObject(o) { + var sorted = {}; + var key = []; + var a = []; - /** - * Detect options in a file and compare result with expected. - * File names should be relative to test suite's folder. - * @param {Array} options List of options that should be detected - * @param {String} input Name of template file - * @param {Object} expected Expected config with detected options - */ - this.shouldDetect = function(options, input, expected) { - // We need to “sort” the input and expected objects, as their order may vary - function sortObject(o) { - var sorted = {}; - var key = []; - var a = []; + for (key in o) { + if (o.hasOwnProperty(key)) { + a.push(key); + } + } - for (key in o) { - if (o.hasOwnProperty(key)) { - a.push(key); - } - } + a.sort(); - a.sort(); + for (key = 0; key < a.length; key++) { + sorted[a[key]] = o[a[key]]; + } + return sorted; +} - for (key = 0; key < a.length; key++) { - sorted[a[key]] = o[a[key]]; - } - return sorted; - } - assert.equal( - JSON.stringify(sortObject(Comb.detectInString(input, options))), - JSON.stringify(sortObject(expected)) - ); - }; +/** + * Detect options in a file and compare result with expected. + * File names should be relative to test suite's folder. + * @param {Array} options List of options that should be detected + * @param {String} input Name of template file + * @param {Object} expected Expected config with detected options + */ +function shouldDetect(options, input, expected) { + // We need to “sort” the input and expected objects, as their order may vary + assert.equal( + JSON.stringify(sortObject(Comb.detectInString(input, options))), + JSON.stringify(sortObject(expected)) + ); +} + +// Add helpers (see tests for usage examples): +mocha.suite.beforeEach(function() { + this.Comb = Comb; + this.comb = new Comb(); + this.shouldBeEqual = shouldBeEqual; + this.shouldDetect = shouldDetect; }); mocha.run(function(failures) { diff --git a/test/options/always-semicolon-less.js b/test/options/always-semicolon-less/test.js similarity index 98% rename from test/options/always-semicolon-less.js rename to test/options/always-semicolon-less/test.js index 1c563a06..ef66fea0 100644 --- a/test/options/always-semicolon-less.js +++ b/test/options/always-semicolon-less/test.js @@ -1,6 +1,5 @@ describe('options/always-semicolon (less)', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'always-semicolon': true }); }); diff --git a/test/options/always-semicolon-sass.js b/test/options/always-semicolon-sass/test.js similarity index 87% rename from test/options/always-semicolon-sass.js rename to test/options/always-semicolon-sass/test.js index 3b969226..9c78d80a 100644 --- a/test/options/always-semicolon-sass.js +++ b/test/options/always-semicolon-sass/test.js @@ -1,6 +1,5 @@ describe('options/always-semicolon (scss)', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'always-semicolon': true }); }); diff --git a/test/options/always-semicolon-scss.js b/test/options/always-semicolon-scss/test.js similarity index 98% rename from test/options/always-semicolon-scss.js rename to test/options/always-semicolon-scss/test.js index 48ec6ec5..97750487 100644 --- a/test/options/always-semicolon-scss.js +++ b/test/options/always-semicolon-scss/test.js @@ -1,6 +1,5 @@ describe('options/always-semicolon (scss)', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'always-semicolon': true }); }); diff --git a/test/options/always-semicolon.js b/test/options/always-semicolon/test.js similarity index 100% rename from test/options/always-semicolon.js rename to test/options/always-semicolon/test.js diff --git a/test/options/block-indent-sass.js b/test/options/block-indent-sass/test.js similarity index 88% rename from test/options/block-indent-sass.js rename to test/options/block-indent-sass/test.js index 33b6add0..182b5a99 100644 --- a/test/options/block-indent-sass.js +++ b/test/options/block-indent-sass/test.js @@ -1,8 +1,4 @@ describe('options/block-indent (sass):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('First level ruleset\'s block', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('block.sass', 'block.expected.sass'); diff --git a/test/options/block-indent-scss.js b/test/options/block-indent-scss/test.js similarity index 76% rename from test/options/block-indent-scss.js rename to test/options/block-indent-scss/test.js index 34130dc2..41c19afd 100644 --- a/test/options/block-indent-scss.js +++ b/test/options/block-indent-scss/test.js @@ -1,8 +1,4 @@ describe('options/block-indent (scss):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Issue 213', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); diff --git a/test/options/block-indent.js b/test/options/block-indent/test.js similarity index 96% rename from test/options/block-indent.js rename to test/options/block-indent/test.js index 9123961e..eb2846e9 100644 --- a/test/options/block-indent.js +++ b/test/options/block-indent/test.js @@ -1,8 +1,4 @@ describe('options/block-indent:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'block-indent': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/color-case.js b/test/options/color-case/test.js similarity index 100% rename from test/options/color-case.js rename to test/options/color-case/test.js diff --git a/test/options/color-shorthand.js b/test/options/color-shorthand/test.js similarity index 100% rename from test/options/color-shorthand.js rename to test/options/color-shorthand/test.js diff --git a/test/options/element-case-scss.js b/test/options/element-case-scss/test.js similarity index 76% rename from test/options/element-case-scss.js rename to test/options/element-case-scss/test.js index 468ffe25..c2402506 100644 --- a/test/options/element-case-scss.js +++ b/test/options/element-case-scss/test.js @@ -1,8 +1,4 @@ describe('options/element-case (scss):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should not touch mixin names', function() { this.comb.configure({ 'element-case': 'lower' }); this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); diff --git a/test/options/element-case.js b/test/options/element-case/test.js similarity index 100% rename from test/options/element-case.js rename to test/options/element-case/test.js diff --git a/test/options/eof-newline.js b/test/options/eof-newline/test.js similarity index 100% rename from test/options/eof-newline.js rename to test/options/eof-newline/test.js diff --git a/test/options/integral.js b/test/options/integral/test.js similarity index 92% rename from test/options/integral.js rename to test/options/integral/test.js index 624598d2..e316f47d 100644 --- a/test/options/integral.js +++ b/test/options/integral/test.js @@ -1,10 +1,6 @@ var assert = require('assert'); describe('integral test', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); diff --git a/test/options/leading-zero.js b/test/options/leading-zero/test.js similarity index 100% rename from test/options/leading-zero.js rename to test/options/leading-zero/test.js diff --git a/test/options/quotes.js b/test/options/quotes/test.js similarity index 100% rename from test/options/quotes.js rename to test/options/quotes/test.js diff --git a/test/options/remove-empty-rulesets-less.js b/test/options/remove-empty-rulesets-less/test.js similarity index 91% rename from test/options/remove-empty-rulesets-less.js rename to test/options/remove-empty-rulesets-less/test.js index 8cf54fc0..a031071d 100644 --- a/test/options/remove-empty-rulesets-less.js +++ b/test/options/remove-empty-rulesets-less/test.js @@ -1,10 +1,6 @@ var assert = require('assert'); describe('options/remove-empty-rulesets (less):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Issue 201. Test 1', function() { this.comb.configure({ 'remove-empty-rulesets': true }); this.shouldBeEqual('1.less', '1.expected.less'); diff --git a/test/options/remove-empty-rulesets-scss.js b/test/options/remove-empty-rulesets-scss/test.js similarity index 95% rename from test/options/remove-empty-rulesets-scss.js rename to test/options/remove-empty-rulesets-scss/test.js index 237b0e3f..de898210 100644 --- a/test/options/remove-empty-rulesets-scss.js +++ b/test/options/remove-empty-rulesets-scss/test.js @@ -1,6 +1,5 @@ describe('options/remove-empty-rulesets (scss)', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'remove-empty-rulesets': true }); }); diff --git a/test/options/remove-empty-rulesets.js b/test/options/remove-empty-rulesets/test.js similarity index 100% rename from test/options/remove-empty-rulesets.js rename to test/options/remove-empty-rulesets/test.js diff --git a/test/options/sass.js b/test/options/sass/test.js similarity index 98% rename from test/options/sass.js rename to test/options/sass/test.js index 1593c33f..054ab9dd 100644 --- a/test/options/sass.js +++ b/test/options/sass/test.js @@ -1,6 +1,5 @@ describe('Sass', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({}); }); diff --git a/test/options/sort-order-fallback.js b/test/options/sort-order-fallback/test.js similarity index 93% rename from test/options/sort-order-fallback.js rename to test/options/sort-order-fallback/test.js index 418fcfda..1262c177 100644 --- a/test/options/sort-order-fallback.js +++ b/test/options/sort-order-fallback/test.js @@ -1,8 +1,4 @@ describe('options/sort-order-fallback', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { 'sort-order-fallback': 'abc', diff --git a/test/options/sort-order-less.js b/test/options/sort-order-less/test.js similarity index 97% rename from test/options/sort-order-less.js rename to test/options/sort-order-less/test.js index f0c36a5b..69208169 100644 --- a/test/options/sort-order-less.js +++ b/test/options/sort-order-less/test.js @@ -1,8 +1,4 @@ describe('options/sort-order (less)', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-sass.js b/test/options/sort-order-sass/test.js similarity index 97% rename from test/options/sort-order-sass.js rename to test/options/sort-order-sass/test.js index d6997e5a..6348c10d 100644 --- a/test/options/sort-order-sass.js +++ b/test/options/sort-order-sass/test.js @@ -1,8 +1,4 @@ describe('options/sort-order (sass)', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-scss.js b/test/options/sort-order-scss/test.js similarity index 98% rename from test/options/sort-order-scss.js rename to test/options/sort-order-scss/test.js index 6cbabe06..72911ab8 100644 --- a/test/options/sort-order-scss.js +++ b/test/options/sort-order-scss/test.js @@ -1,8 +1,4 @@ describe('options/sort-order (scss)', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order.js b/test/options/sort-order/test.js similarity index 98% rename from test/options/sort-order.js rename to test/options/sort-order/test.js index c8f7077f..f313817a 100644 --- a/test/options/sort-order.js +++ b/test/options/sort-order/test.js @@ -1,10 +1,6 @@ var assert = require('assert'); describe('options/sort-order', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); this.shouldBeEqual('single-group.css', 'single-group.expected.css'); diff --git a/test/options/space-after-colon-sass.js b/test/options/space-after-colon-sass/test.js similarity index 88% rename from test/options/space-after-colon-sass.js rename to test/options/space-after-colon-sass/test.js index 98f14be7..d85412d9 100644 --- a/test/options/space-after-colon-sass.js +++ b/test/options/space-after-colon-sass/test.js @@ -1,8 +1,4 @@ describe('options/space-after-colon (sass):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should set proper space if colon is after property name', function() { this.comb.configure({ 'space-after-colon': 2 }); this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); diff --git a/test/options/space-after-colon-scss.js b/test/options/space-after-colon-scss/test.js similarity index 79% rename from test/options/space-after-colon-scss.js rename to test/options/space-after-colon-scss/test.js index 5a9f83b4..b95d7f5d 100644 --- a/test/options/space-after-colon-scss.js +++ b/test/options/space-after-colon-scss/test.js @@ -1,8 +1,4 @@ describe('options/space-after-colon (scss):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Space after colon should not affect pseudo elements', function() { this.comb.configure({ 'space-after-colon': 1 }); this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); diff --git a/test/options/space-after-colon.js b/test/options/space-after-colon/test.js similarity index 96% rename from test/options/space-after-colon.js rename to test/options/space-after-colon/test.js index a0abb4f7..8a6873d9 100644 --- a/test/options/space-after-colon.js +++ b/test/options/space-after-colon/test.js @@ -1,8 +1,4 @@ describe('options/space-after-colon:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-combinator.js b/test/options/space-after-combinator/test.js similarity index 97% rename from test/options/space-after-combinator.js rename to test/options/space-after-combinator/test.js index 8088bca0..7d085b48 100644 --- a/test/options/space-after-combinator.js +++ b/test/options/space-after-combinator/test.js @@ -1,8 +1,4 @@ describe('options/space-after-combinator:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-opening-brace.js b/test/options/space-after-opening-brace/test.js similarity index 97% rename from test/options/space-after-opening-brace.js rename to test/options/space-after-opening-brace/test.js index 06176f31..7b9eb59a 100644 --- a/test/options/space-after-opening-brace.js +++ b/test/options/space-after-opening-brace/test.js @@ -1,8 +1,4 @@ describe('options/space-after-opening-brace:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-selector-delimiter-sass.js b/test/options/space-after-selector-delimiter-sass/test.js similarity index 78% rename from test/options/space-after-selector-delimiter-sass.js rename to test/options/space-after-selector-delimiter-sass/test.js index 0c982826..c0c10e9f 100644 --- a/test/options/space-after-selector-delimiter-sass.js +++ b/test/options/space-after-selector-delimiter-sass/test.js @@ -1,8 +1,4 @@ describe('options/space-after-selector-delimiter (sass):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Issue 238', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n' }); this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); diff --git a/test/options/space-after-selector-delimiter.js b/test/options/space-after-selector-delimiter/test.js similarity index 97% rename from test/options/space-after-selector-delimiter.js rename to test/options/space-after-selector-delimiter/test.js index 8d82ae1f..3eb3b1b0 100644 --- a/test/options/space-after-selector-delimiter.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -1,8 +1,4 @@ describe('options/space-after-selector-delimiter:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-closing-brace.js b/test/options/space-before-closing-brace/test.js similarity index 97% rename from test/options/space-before-closing-brace.js rename to test/options/space-before-closing-brace/test.js index a9d9a6c9..d8d0a62a 100644 --- a/test/options/space-before-closing-brace.js +++ b/test/options/space-before-closing-brace/test.js @@ -1,8 +1,4 @@ describe('options/space-before-closing-brace:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-colon-sass.js b/test/options/space-before-colon-sass/test.js similarity index 84% rename from test/options/space-before-colon-sass.js rename to test/options/space-before-colon-sass/test.js index ede13e35..d9380d5e 100644 --- a/test/options/space-before-colon-sass.js +++ b/test/options/space-before-colon-sass/test.js @@ -1,8 +1,4 @@ describe('options/space-before-colon-sass:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Should correct space', function() { this.comb.configure({ 'space-before-colon': 1 }); this.shouldBeEqual('test.sass', 'test.expected.sass'); diff --git a/test/options/space-before-colon.js b/test/options/space-before-colon/test.js similarity index 96% rename from test/options/space-before-colon.js rename to test/options/space-before-colon/test.js index 1b9d7f88..c545d0c8 100644 --- a/test/options/space-before-colon.js +++ b/test/options/space-before-colon/test.js @@ -1,8 +1,4 @@ describe('options/space-before-colon:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-combinator.js b/test/options/space-before-combinator/test.js similarity index 97% rename from test/options/space-before-combinator.js rename to test/options/space-before-combinator/test.js index a9eccf0b..3883dba8 100644 --- a/test/options/space-before-combinator.js +++ b/test/options/space-before-combinator/test.js @@ -1,8 +1,4 @@ describe('options/space-before-combinator:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-opening-brace-scss.js b/test/options/space-before-opening-brace-scss/test.js similarity index 77% rename from test/options/space-before-opening-brace-scss.js rename to test/options/space-before-opening-brace-scss/test.js index 3e40c5fb..100f0abc 100644 --- a/test/options/space-before-opening-brace-scss.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -1,8 +1,4 @@ describe('options/space-before-opening-brace (scss):', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Issue 231', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); diff --git a/test/options/space-before-opening-brace.js b/test/options/space-before-opening-brace/test.js similarity index 97% rename from test/options/space-before-opening-brace.js rename to test/options/space-before-opening-brace/test.js index f5eb60dc..338e6c1c 100644 --- a/test/options/space-before-opening-brace.js +++ b/test/options/space-before-opening-brace/test.js @@ -1,8 +1,4 @@ describe('options/space-before-opening-brace:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-selector-delimiter.js b/test/options/space-before-selector-delimiter/test.js similarity index 97% rename from test/options/space-before-selector-delimiter.js rename to test/options/space-before-selector-delimiter/test.js index 3770c75b..92e2a959 100644 --- a/test/options/space-before-selector-delimiter.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -1,8 +1,4 @@ describe('options/space-before-selector-delimiter:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-between-declarations.js b/test/options/space-between-declarations/test.js similarity index 96% rename from test/options/space-between-declarations.js rename to test/options/space-between-declarations/test.js index 9f02e544..0434ed5d 100644 --- a/test/options/space-between-declarations.js +++ b/test/options/space-between-declarations/test.js @@ -1,8 +1,4 @@ describe('options/space-between-declarations:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Array value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/strip-spaces.js b/test/options/strip-spaces/test.js similarity index 100% rename from test/options/strip-spaces.js rename to test/options/strip-spaces/test.js diff --git a/test/options/tab-size.js b/test/options/tab-size/test.js similarity index 89% rename from test/options/tab-size.js rename to test/options/tab-size/test.js index 59bb9f09..05560b1f 100644 --- a/test/options/tab-size.js +++ b/test/options/tab-size/test.js @@ -1,8 +1,4 @@ describe('options/tab-size:', function() { - beforeEach(function() { - this.filename = __filename; - }); - it('Test 1: String value => should not change anything', function() { this.comb.configure({ 'tab-size': ' ' }); this.shouldBeEqual('test.css'); diff --git a/test/options/unitless-zero.js b/test/options/unitless-zero/test.js similarity index 100% rename from test/options/unitless-zero.js rename to test/options/unitless-zero/test.js diff --git a/test/options/vendor-prefix-align-sass.js b/test/options/vendor-prefix-align-sass/test.js similarity index 91% rename from test/options/vendor-prefix-align-sass.js rename to test/options/vendor-prefix-align-sass/test.js index 4e3a7467..bd59c6d6 100644 --- a/test/options/vendor-prefix-align-sass.js +++ b/test/options/vendor-prefix-align-sass/test.js @@ -1,6 +1,5 @@ describe('options/vendor-prefix-align', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'vendor-prefix-align': true }); }); diff --git a/test/options/vendor-prefix-align.js b/test/options/vendor-prefix-align/test.js similarity index 99% rename from test/options/vendor-prefix-align.js rename to test/options/vendor-prefix-align/test.js index 353b3e1e..f9ca9b2b 100644 --- a/test/options/vendor-prefix-align.js +++ b/test/options/vendor-prefix-align/test.js @@ -1,6 +1,5 @@ describe('options/vendor-prefix-align', function() { beforeEach(function() { - this.filename = __filename; this.comb.configure({ 'vendor-prefix-align': true }); }); From 1cea6f3fe107839ef6915f0286307bfe192512c7 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 22 Jan 2015 19:47:48 +0300 Subject: [PATCH 007/184] Tests: Skip failing tests --- test/core/configure/test.js | 2 +- test/core/get-config/test.js | 2 +- test/core/less/test.js | 2 +- test/core/scss/test.js | 2 +- test/core/use/test.js | 2 +- test/options/always-semicolon-sass/test.js | 2 +- test/options/block-indent-sass/test.js | 2 +- test/options/block-indent-scss/test.js | 2 +- test/options/block-indent/test.js | 2 +- test/options/color-shorthand/test.js | 2 +- test/options/element-case-scss/test.js | 2 +- test/options/element-case/test.js | 2 +- test/options/eof-newline/test.js | 2 +- test/options/integral/test.js | 2 +- test/options/leading-zero/test.js | 2 +- test/options/quotes/test.js | 2 +- test/options/remove-empty-rulesets-less/test.js | 2 +- test/options/remove-empty-rulesets-scss/test.js | 2 +- test/options/remove-empty-rulesets/test.js | 2 +- test/options/sass/test.js | 2 +- test/options/sort-order-fallback/test.js | 2 +- test/options/sort-order-less/test.js | 2 +- test/options/sort-order-sass/test.js | 2 +- test/options/sort-order-scss/test.js | 2 +- test/options/sort-order/test.js | 2 +- test/options/space-after-colon-sass/test.js | 2 +- test/options/space-after-colon-scss/test.js | 2 +- test/options/space-after-colon/test.js | 2 +- test/options/space-after-combinator/test.js | 2 +- test/options/space-after-opening-brace/test.js | 2 +- test/options/space-after-selector-delimiter-sass/test.js | 2 +- test/options/space-after-selector-delimiter/test.js | 2 +- test/options/space-before-closing-brace/test.js | 2 +- test/options/space-before-colon-sass/test.js | 2 +- test/options/space-before-colon/test.js | 2 +- test/options/space-before-combinator/test.js | 2 +- test/options/space-before-opening-brace-scss/test.js | 2 +- test/options/space-before-opening-brace/test.js | 2 +- test/options/space-before-selector-delimiter/test.js | 2 +- test/options/space-between-declarations/test.js | 2 +- test/options/strip-spaces/test.js | 2 +- test/options/tab-size/test.js | 2 +- test/options/unitless-zero/test.js | 2 +- test/options/vendor-prefix-align-sass/test.js | 2 +- test/options/vendor-prefix-align/test.js | 2 +- 45 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/core/configure/test.js b/test/core/configure/test.js index 9ce774f7..58fde686 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -1,7 +1,7 @@ var Comb = process.env.TEST_COV ? require('../../../lib-cov/csscomb') : require('../../../lib/csscomb'); var assert = require('assert'); -describe('csscomb methods', function() { +describe.skip('csscomb methods', function() { var comb; var input; var output; diff --git a/test/core/get-config/test.js b/test/core/get-config/test.js index 8d69c294..23ec2377 100644 --- a/test/core/get-config/test.js +++ b/test/core/get-config/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('csscomb methods', function() { +describe.skip('csscomb methods', function() { it('getConfig()', function() { var config = require('../../../config/csscomb.json'); diff --git a/test/core/less/test.js b/test/core/less/test.js index defa5353..06688ab3 100644 --- a/test/core/less/test.js +++ b/test/core/less/test.js @@ -1,4 +1,4 @@ -describe('LESS', function() { +describe.skip('LESS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/scss/test.js b/test/core/scss/test.js index 3f2fb42a..eda05b50 100644 --- a/test/core/scss/test.js +++ b/test/core/scss/test.js @@ -1,4 +1,4 @@ -describe('SCSS', function() { +describe.skip('SCSS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/use/test.js b/test/core/use/test.js index d4ccc690..63f0c2cb 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('.use()', function() { +describe.skip('.use()', function() { it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); diff --git a/test/options/always-semicolon-sass/test.js b/test/options/always-semicolon-sass/test.js index 9c78d80a..76f57f5e 100644 --- a/test/options/always-semicolon-sass/test.js +++ b/test/options/always-semicolon-sass/test.js @@ -1,4 +1,4 @@ -describe('options/always-semicolon (scss)', function() { +describe('options/always-semicolon (sass)', function() { beforeEach(function() { this.comb.configure({ 'always-semicolon': true }); }); diff --git a/test/options/block-indent-sass/test.js b/test/options/block-indent-sass/test.js index 182b5a99..b52444c3 100644 --- a/test/options/block-indent-sass/test.js +++ b/test/options/block-indent-sass/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent (sass):', function() { +describe.skip('options/block-indent (sass):', function() { it('First level ruleset\'s block', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('block.sass', 'block.expected.sass'); diff --git a/test/options/block-indent-scss/test.js b/test/options/block-indent-scss/test.js index 41c19afd..6acd4c1e 100644 --- a/test/options/block-indent-scss/test.js +++ b/test/options/block-indent-scss/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent (scss):', function() { +describe.skip('options/block-indent (scss):', function() { it('Issue 213', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index eb2846e9..0f73ab36 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent:', function() { +describe.skip('options/block-indent:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'block-indent': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/test.js index d1708c0c..d8ebffb8 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/color-shorthand', function() { +describe.skip('options/color-shorthand', function() { it('Should shrink hexadecimal colors to 3 symbols', function() { this.comb.configure({ 'color-shorthand': true }); assert.equal( diff --git a/test/options/element-case-scss/test.js b/test/options/element-case-scss/test.js index c2402506..f715e90f 100644 --- a/test/options/element-case-scss/test.js +++ b/test/options/element-case-scss/test.js @@ -1,4 +1,4 @@ -describe('options/element-case (scss):', function() { +describe.skip('options/element-case (scss):', function() { it('Should not touch mixin names', function() { this.comb.configure({ 'element-case': 'lower' }); this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); diff --git a/test/options/element-case/test.js b/test/options/element-case/test.js index fb95287c..cda313bd 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/element-case', function() { +describe.skip('options/element-case', function() { it('Invalid String should not change case of elements', function() { this.comb.configure({ 'element-case': 'foobar' }); assert.equal( diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/test.js index ead5fcf1..436fc782 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/eof-newline', function() { +describe.skip('options/eof-newline', function() { it('Invalid value should not change trim trailing brac', function() { this.comb.configure({ 'eof-newline': 'foobar' }); assert.equal( diff --git a/test/options/integral/test.js b/test/options/integral/test.js index e316f47d..885e33f6 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('integral test', function() { +describe.skip('integral test', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/test.js index dbd5c2b8..2438d280 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/leading-zero', function() { +describe.skip('options/leading-zero', function() { it('Should add leading zero in dimensions', function() { this.comb.configure({ 'leading-zero': true }); assert.equal( diff --git a/test/options/quotes/test.js b/test/options/quotes/test.js index 5ed3a898..363f4d66 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/quotes', function() { +describe.skip('options/quotes', function() { it('Invalid String should not change quotes', function() { this.comb.configure({ quotes: 3 }); assert.equal( diff --git a/test/options/remove-empty-rulesets-less/test.js b/test/options/remove-empty-rulesets-less/test.js index a031071d..e8711aa5 100644 --- a/test/options/remove-empty-rulesets-less/test.js +++ b/test/options/remove-empty-rulesets-less/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/remove-empty-rulesets (less):', function() { +describe.skip('options/remove-empty-rulesets (less):', function() { it('Issue 201. Test 1', function() { this.comb.configure({ 'remove-empty-rulesets': true }); this.shouldBeEqual('1.less', '1.expected.less'); diff --git a/test/options/remove-empty-rulesets-scss/test.js b/test/options/remove-empty-rulesets-scss/test.js index de898210..605a6393 100644 --- a/test/options/remove-empty-rulesets-scss/test.js +++ b/test/options/remove-empty-rulesets-scss/test.js @@ -1,4 +1,4 @@ -describe('options/remove-empty-rulesets (scss)', function() { +describe.skip('options/remove-empty-rulesets (scss)', function() { beforeEach(function() { this.comb.configure({ 'remove-empty-rulesets': true }); }); diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/test.js index a516227c..d6e7ecaa 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/remove-empty-rulesets', function() { +describe.skip('options/remove-empty-rulesets', function() { it('Configured with invalid value, should not remove empty ruleset', function() { this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); assert.equal(this.comb.processString('a { width: 10px; } b {}'), 'a { width: 10px; } b {}'); diff --git a/test/options/sass/test.js b/test/options/sass/test.js index 054ab9dd..1ab534e1 100644 --- a/test/options/sass/test.js +++ b/test/options/sass/test.js @@ -1,4 +1,4 @@ -describe('Sass', function() { +describe.skip('Sass', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index 1262c177..d67b08d6 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order-fallback', function() { +describe.skip('options/sort-order-fallback', function() { it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { 'sort-order-fallback': 'abc', diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index 69208169..f00bca0c 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (less)', function() { +describe.skip('options/sort-order (less)', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 6348c10d..85a58862 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (sass)', function() { +describe.skip('options/sort-order (sass)', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 72911ab8..79395764 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (scss)', function() { +describe.skip('options/sort-order (scss)', function() { it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index f313817a..45371d80 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/sort-order', function() { +describe.skip('options/sort-order', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); this.shouldBeEqual('single-group.css', 'single-group.expected.css'); diff --git a/test/options/space-after-colon-sass/test.js b/test/options/space-after-colon-sass/test.js index d85412d9..e9397920 100644 --- a/test/options/space-after-colon-sass/test.js +++ b/test/options/space-after-colon-sass/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon (sass):', function() { +describe.skip('options/space-after-colon (sass):', function() { it('Should set proper space if colon is after property name', function() { this.comb.configure({ 'space-after-colon': 2 }); this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); diff --git a/test/options/space-after-colon-scss/test.js b/test/options/space-after-colon-scss/test.js index b95d7f5d..f5d9d2b5 100644 --- a/test/options/space-after-colon-scss/test.js +++ b/test/options/space-after-colon-scss/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon (scss):', function() { +describe.skip('options/space-after-colon (scss):', function() { it('Space after colon should not affect pseudo elements', function() { this.comb.configure({ 'space-after-colon': 1 }); this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/test.js index 8a6873d9..364db29c 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon:', function() { +describe.skip('options/space-after-colon:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/test.js index 7d085b48..2128d34c 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-combinator:', function() { +describe.skip('options/space-after-combinator:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 7b9eb59a..22ab0945 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-opening-brace:', function() { +describe.skip('options/space-after-opening-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-after-selector-delimiter-sass/test.js b/test/options/space-after-selector-delimiter-sass/test.js index c0c10e9f..fae87913 100644 --- a/test/options/space-after-selector-delimiter-sass/test.js +++ b/test/options/space-after-selector-delimiter-sass/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-selector-delimiter (sass):', function() { +describe.skip('options/space-after-selector-delimiter (sass):', function() { it('Issue 238', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n' }); this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/test.js index 3eb3b1b0..09f2cd99 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-selector-delimiter:', function() { +describe.skip('options/space-after-selector-delimiter:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/test.js index d8d0a62a..1642c193 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-closing-brace:', function() { +describe.skip('options/space-before-closing-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-colon-sass/test.js b/test/options/space-before-colon-sass/test.js index d9380d5e..bffd6de4 100644 --- a/test/options/space-before-colon-sass/test.js +++ b/test/options/space-before-colon-sass/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-colon-sass:', function() { +describe.skip('options/space-before-colon-sass:', function() { it('Should correct space', function() { this.comb.configure({ 'space-before-colon': 1 }); this.shouldBeEqual('test.sass', 'test.expected.sass'); diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/test.js index c545d0c8..e5025bed 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-colon:', function() { +describe.skip('options/space-before-colon:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index 3883dba8..bbedb8bb 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-combinator:', function() { +describe.skip('options/space-before-combinator:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace-scss/test.js index 100f0abc..0071d9fd 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-opening-brace (scss):', function() { +describe.skip('options/space-before-opening-brace (scss):', function() { it('Issue 231', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/test.js index 338e6c1c..c3fc3c66 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-opening-brace:', function() { +describe.skip('options/space-before-opening-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/test.js index 92e2a959..f360282f 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-selector-delimiter:', function() { +describe.skip('options/space-before-selector-delimiter:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/test.js index 0434ed5d..4d129827 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/test.js @@ -1,4 +1,4 @@ -describe('options/space-between-declarations:', function() { +describe.skip('options/space-between-declarations:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ['', ' '] }); this.shouldBeEqual('test.css'); diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/test.js index b8f19b36..08cbfc0a 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/strip-spaces', function() { +describe.skip('options/strip-spaces', function() { it('Invalid value should not trim trailing spaces', function() { this.comb.configure({ 'strip-spaces': 'foobar' }); assert.equal( diff --git a/test/options/tab-size/test.js b/test/options/tab-size/test.js index 05560b1f..4991e3f6 100644 --- a/test/options/tab-size/test.js +++ b/test/options/tab-size/test.js @@ -1,4 +1,4 @@ -describe('options/tab-size:', function() { +describe.skip('options/tab-size:', function() { it('Test 1: String value => should not change anything', function() { this.comb.configure({ 'tab-size': ' ' }); this.shouldBeEqual('test.css'); diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index f47be91d..177d15df 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/unitless-zero', function() { +describe.skip('options/unitless-zero', function() { it('Should remove units in zero-valued dimensions', function() { this.comb.configure({ 'unitless-zero': true }); assert.equal( diff --git a/test/options/vendor-prefix-align-sass/test.js b/test/options/vendor-prefix-align-sass/test.js index bd59c6d6..f7c9295d 100644 --- a/test/options/vendor-prefix-align-sass/test.js +++ b/test/options/vendor-prefix-align-sass/test.js @@ -1,4 +1,4 @@ -describe('options/vendor-prefix-align', function() { +describe.skip('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index f9ca9b2b..d7c60fcb 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -1,4 +1,4 @@ -describe('options/vendor-prefix-align', function() { +describe.skip('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); From 234e21c44e7623e6dfcbece51073fcf183a4b2ec Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 22 Jan 2015 19:50:51 +0300 Subject: [PATCH 008/184] Gonzales 3.0: Update `color-shorthand` option --- lib/options/color-shorthand.js | 18 ++++++++---------- test/options/color-shorthand/test.js | 10 +++++----- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/options/color-shorthand.js b/lib/options/color-shorthand.js index 14fdcc5c..9d8848e7 100644 --- a/lib/options/color-shorthand.js +++ b/lib/options/color-shorthand.js @@ -7,15 +7,14 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 'vhash') { + process: function(node) { + if (node.type === 'vhash') { if (this.getValue('color-shorthand')) { - node[0] = node[0].replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3'); + node.content = node.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3'); } else { - node[0] = node[0].replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); + node.content = node.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); } } }, @@ -23,14 +22,13 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'vhash') { - if (node[0].match(/^\w{3}$/)) { + detect: function(node) { + if (node.type === 'vhash') { + if (node.content[0].match(/^\w{3}$/)) { return true; - } else if (node[0].match(/^(\w)\1(\w)\2(\w)\3$/)) { + } else if (node.content[0].match(/^(\w)\1(\w)\2(\w)\3$/)) { return false; } } diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/test.js index d8ebffb8..c46a82b0 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/color-shorthand', function() { +describe('options/color-shorthand', function() { it('Should shrink hexadecimal colors to 3 symbols', function() { this.comb.configure({ 'color-shorthand': true }); assert.equal( @@ -32,7 +32,7 @@ describe.skip('options/color-shorthand', function() { }); - it('Should detect non-shorthanded color', function() { + it.skip('Should detect non-shorthanded color', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #FF33EE }', @@ -42,7 +42,7 @@ describe.skip('options/color-shorthand', function() { ); }); - it('Should detect shorthanded color', function() { + it.skip('Should detect shorthanded color', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #fff }', @@ -52,7 +52,7 @@ describe.skip('options/color-shorthand', function() { ); }); - it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { + it.skip('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #F3F3F3 }', @@ -60,7 +60,7 @@ describe.skip('options/color-shorthand', function() { ); }); - it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { + it.skip('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { this.shouldDetect( ['color-shorthand'], 'a { color: rgba(0,0,0,0.5) }', From f00767a635b8d117ef14ec38fe69ea44c5943108 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 22 Jan 2015 19:54:36 +0300 Subject: [PATCH 009/184] Gonzales 3.0: Update `element-case` option --- lib/options/element-case.js | 33 +++++++++++++------------- test/options/element-case-scss/test.js | 2 +- test/options/element-case/test.js | 14 +++++------ 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/options/element-case.js b/lib/options/element-case.js index dae90e4a..51962528 100644 --- a/lib/options/element-case.js +++ b/lib/options/element-case.js @@ -7,25 +7,24 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'selector' && - nodeType !== 'arguments') return; - - for (var x = node.length; x--;) { - var selector = node[x]; - if (selector[0] !== 'simpleselector') continue; - - for (var i = selector.length; i--;) { - var simpleselector = selector[i]; - if (!Array.isArray(simpleselector) || - simpleselector[0] !== 'ident') continue; - - simpleselector[1] = this.getValue('element-case') === 'lower' ? - simpleselector[1].toLowerCase() : - simpleselector[1].toUpperCase(); + process: function(node) { + if (node.type !== 'selector' && + node.type !== 'arguments') return; + + for (var x = node.content.length; x--;) { + var selector = node.content[x]; + if (selector.type !== 'simpleselector') continue; + + for (var i = selector.content.length; i--;) { + var simpleselector = selector.content[i]; + if (!simpleselector || + simpleselector.type !== 'ident') continue; + + simpleselector.content = this.getValue('element-case') === 'lower' ? + simpleselector.content.toLowerCase() : + simpleselector.content.toUpperCase(); } } }, diff --git a/test/options/element-case-scss/test.js b/test/options/element-case-scss/test.js index f715e90f..c2402506 100644 --- a/test/options/element-case-scss/test.js +++ b/test/options/element-case-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/element-case (scss):', function() { +describe('options/element-case (scss):', function() { it('Should not touch mixin names', function() { this.comb.configure({ 'element-case': 'lower' }); this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); diff --git a/test/options/element-case/test.js b/test/options/element-case/test.js index cda313bd..865206d4 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/element-case', function() { +describe('options/element-case', function() { it('Invalid String should not change case of elements', function() { this.comb.configure({ 'element-case': 'foobar' }); assert.equal( @@ -41,7 +41,7 @@ describe.skip('options/element-case', function() { ); }); - it('Should detect lowercase elements', function() { + it.skip('Should detect lowercase elements', function() { this.shouldDetect( ['element-case'], 'a { color: red }', @@ -51,7 +51,7 @@ describe.skip('options/element-case', function() { ); }); - it('Should detect uppercase elements', function() { + it.skip('Should detect uppercase elements', function() { this.shouldDetect( ['element-case'], 'A { color: red }', @@ -61,7 +61,7 @@ describe.skip('options/element-case', function() { ); }); - it('Should detect lowercase elements in a long selector', function() { + it.skip('Should detect lowercase elements in a long selector', function() { this.shouldDetect( ['element-case'], 'ul li:not(:hover) A { color: red }', @@ -71,7 +71,7 @@ describe.skip('options/element-case', function() { ); }); - it('Should detect uppercase elements in a long selector', function() { + it.skip('Should detect uppercase elements in a long selector', function() { this.shouldDetect( ['element-case'], 'ul .lol:not(LI) A { color: red }', @@ -81,7 +81,7 @@ describe.skip('options/element-case', function() { ); }); - it('Shouldn’t detect case of elements in a mixed case', function() { + it.skip('Shouldn’t detect case of elements in a mixed case', function() { this.shouldDetect( ['element-case'], 'aRtIcLe { color: red }', @@ -89,7 +89,7 @@ describe.skip('options/element-case', function() { ); }); - it('Shouldn’t detect case of elements when there are no such', function() { + it.skip('Shouldn’t detect case of elements when there are no such', function() { this.shouldDetect( ['element-case'], '*.lol { color: red }', From 5a278fe261bdd072e74a61021997e728a822ca67 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 22 Jan 2015 20:00:33 +0300 Subject: [PATCH 010/184] Gonzales 3.0: Update `eof-newline` option --- lib/options/eof-newline.js | 17 ++++++++--------- test/options/eof-newline/test.js | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/options/eof-newline.js b/lib/options/eof-newline.js index fa8d34ef..8b65c5fb 100644 --- a/lib/options/eof-newline.js +++ b/lib/options/eof-newline.js @@ -7,18 +7,17 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 'stylesheet') { - var lastChild = node[node.length - 1]; - if (lastChild[0] !== 's') { - lastChild = ['s', '']; - node.push(lastChild); + process: function(node) { + if (node.type === 'stylesheet') { + var lastChild = node.content[node.content.length - 1]; + if (lastChild.type !== 's') { + lastChild = { type: 's', content: '' }; + node.content.push(lastChild); } - lastChild[1] = lastChild[1].replace(/\n$/, ''); - if (this.getValue('eof-newline')) lastChild[1] += '\n'; + lastChild.content = lastChild.content.replace(/\n$/, ''); + if (this.getValue('eof-newline')) lastChild.content += '\n'; } }, diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/test.js index 436fc782..a70050ac 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/eof-newline', function() { +describe('options/eof-newline', function() { it('Invalid value should not change trim trailing brac', function() { this.comb.configure({ 'eof-newline': 'foobar' }); assert.equal( @@ -27,7 +27,7 @@ describe.skip('options/eof-newline', function() { ); }); - it('Shouldn’t detect eof newline', function() { + it.skip('Shouldn’t detect eof newline', function() { this.shouldDetect( ['eof-newline'], 'a { color: red }', @@ -37,7 +37,7 @@ describe.skip('options/eof-newline', function() { ); }); - it('Should detect eof newline', function() { + it.skip('Should detect eof newline', function() { this.shouldDetect( ['eof-newline'], 'a { color: red }\n', @@ -47,7 +47,7 @@ describe.skip('options/eof-newline', function() { ); }); - it('Shouldn’t detect eof newline with spaces at the end', function() { + it.skip('Shouldn’t detect eof newline with spaces at the end', function() { this.shouldDetect( ['eof-newline'], 'a { color: red } ', @@ -57,7 +57,7 @@ describe.skip('options/eof-newline', function() { ); }); - it('Should detect eof newline with mixed spaces at the end', function() { + it.skip('Should detect eof newline with mixed spaces at the end', function() { this.shouldDetect( ['eof-newline'], 'a { color: red } \n ', From f853dcdb0e25cb7ea80473c6576cdf55866b238d Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 23 Jan 2015 18:00:28 +0300 Subject: [PATCH 011/184] Gonzales 3.0: Update `leading-zero` option --- lib/options/leading-zero.js | 11 +++++------ test/options/leading-zero/test.js | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/options/leading-zero.js b/lib/options/leading-zero.js index 07c9de89..25722140 100644 --- a/lib/options/leading-zero.js +++ b/lib/options/leading-zero.js @@ -7,16 +7,15 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 'number') { + process: function(node) { + if (node.type === 'number') { if (this.getValue('leading-zero')) { - if (node[0][0] === '.') - node[0] = '0' + node[0]; + if (node.content[0] === '.') + node.content = '0' + node.content; } else { - node[0] = node[0].replace(/^0+(?=\.)/, ''); + node.content = node.content.replace(/^0+(?=\.)/, ''); } } }, diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/test.js index 2438d280..6040c45d 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/leading-zero', function() { +describe('options/leading-zero', function() { it('Should add leading zero in dimensions', function() { this.comb.configure({ 'leading-zero': true }); assert.equal( @@ -21,7 +21,7 @@ describe.skip('options/leading-zero', function() { ); }); - it('Should detect leading zero option', function() { + it.skip('Should detect leading zero option', function() { this.shouldDetect( ['leading-zero'], 'a { width: 0.5em }', @@ -31,7 +31,7 @@ describe.skip('options/leading-zero', function() { ); }); - it('Should detect leading zero option set to false', function() { + it.skip('Should detect leading zero option set to false', function() { this.shouldDetect( ['leading-zero'], 'a { width: .5em }', @@ -41,7 +41,7 @@ describe.skip('options/leading-zero', function() { ); }); - it('Shouldn’t detect leading zero option', function() { + it.skip('Shouldn’t detect leading zero option', function() { this.shouldDetect( ['leading-zero'], 'a { width: 10.5em }', From ecfd75b8cb686fcf927d3bea9f5294860a67ff4e Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:17:52 +0300 Subject: [PATCH 012/184] Update Gonzales --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9d4ac13..f4a9f7b3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dependencies": { "commander": "2.0.0", "csscomb-core": "~2.0.0", - "gonzales-pe": "3.0.0-10", + "gonzales-pe": "~3.0.0-10", "vow": "0.4.4" }, "devDependencies": { From 96d9ad908d5a1e0902f717a84f9a811985fec019 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:21:36 +0300 Subject: [PATCH 013/184] Skip detection tests --- test/options/always-semicolon/test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js index a20f8d3f..2290343a 100644 --- a/test/options/always-semicolon/test.js +++ b/test/options/always-semicolon/test.js @@ -51,7 +51,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should detect semicolon for last property. Test 1', function() { + it.skip('Should detect semicolon for last property. Test 1', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0 }', @@ -61,7 +61,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should detect semicolon for last property. Test 2', function() { + it.skip('Should detect semicolon for last property. Test 2', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0; }', @@ -71,7 +71,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should detect semicolon for last property. Test 3', function() { + it.skip('Should detect semicolon for last property. Test 3', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0; } div { height: 0 }', @@ -81,7 +81,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should detect semicolon for last property. Test 4', function() { + it.skip('Should detect semicolon for last property. Test 4', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0 } div { height: 0; } div { height: 0 }', @@ -91,7 +91,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should detect semicolon for last property. Test 5', function() { + it.skip('Should detect semicolon for last property. Test 5', function() { this.shouldDetect( ['always-semicolon'], 'div {\nheight: 0 /* Comment */\n} ' + @@ -104,7 +104,7 @@ describe('options/always-semicolon', function() { }); - it('Should detect semicolon for last property. Test 6', function() { + it.skip('Should detect semicolon for last property. Test 6', function() { this.shouldDetect( ['always-semicolon'], 'a{\n border:0;\n}', @@ -114,7 +114,7 @@ describe('options/always-semicolon', function() { ); }); - it('Should not detect semicolon for last property if there are no properties', function() { + it.skip('Should not detect semicolon for last property if there are no properties', function() { this.shouldDetect( ['always-semicolon'], 'div {}', From e41b6d2b0e96df793a642d141382cd67658b8f06 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:21:57 +0300 Subject: [PATCH 014/184] Gonzales 3.0: Update `always-semicolon` option --- lib/options/always-semicolon.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js index 32e84597..2cd55ad7 100644 --- a/lib/options/always-semicolon.js +++ b/lib/options/always-semicolon.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'always-semicolon', @@ -58,7 +60,7 @@ module.exports = { // Temporarily remove last spaces and comments and insert `;` // before them: nodeWithoutSemicolon.content.splice(nodeWithoutSemicolon.content.length - space.length); - var declDelim = { type: 'declDelim', content: null }; + var declDelim = gonzales.createNode({ type: 'declDelim', content: ';' }); var args = [i + 1, 0, declDelim].concat(space); node.splice.apply(node, args); break; @@ -68,14 +70,13 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'block') { - for (var i = node.length; i--;) { - var nodeItem = node[i]; - var type = nodeItem[0]; + detect: function(node) { + if (node.type === 'block') { + for (var i = node.content.length; i--;) { + var nodeItem = node.content[i]; + var type = nodeItem.type; if (type === 'declDelim') return true; if (type === 'declaration') return false; From 5c56ec067f5ea89a7aa7ea61418d03cd888ada38 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 015/184] Gonzales 3.0: Update `quotes` option --- lib/options/quotes.js | 13 ++++++------- test/options/quotes/test.js | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/options/quotes.js b/lib/options/quotes.js index 1c8b979b..b71fb427 100644 --- a/lib/options/quotes.js +++ b/lib/options/quotes.js @@ -7,20 +7,19 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { var value = this.getValue('quotes'); - if (nodeType === 'string') { - if (node[0][0] === '"' && value === 'single') { - node[0] = node[0] + if (node.type === 'string') { + if (node.content[0] === '"' && value === 'single') { + node.content = node.content .replace(/\\"/g, '"') // unescape all escaped double quotes .replace(/([^\\])'/g, '$1\\\'') // escape all the single quotes .replace(/^"|"$/g, '\''); // replace the first and the last quote - } else if (node[0][0] === '\'' && value === 'double') { - node[0] = node[0] + } else if (node.content[0] === '\'' && value === 'double') { + node.content = node.content .replace(/\\'/g, '\'') // unescape all escaped single quotes .replace(/([^\\])"/g, '$1\\\"') // escape all the double quotes .replace(/^'|'$/g, '"'); // replace the first and the last quote diff --git a/test/options/quotes/test.js b/test/options/quotes/test.js index 363f4d66..87a197d6 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/quotes', function() { +describe('options/quotes', function() { it('Invalid String should not change quotes', function() { this.comb.configure({ quotes: 3 }); assert.equal( @@ -70,7 +70,7 @@ describe.skip('options/quotes', function() { ); }); - it('Should not detect quotes when there are none', function() { + it.skip('Should not detect quotes when there are none', function() { this.shouldDetect( ['quotes'], 'a { color:red }', @@ -78,7 +78,7 @@ describe.skip('options/quotes', function() { ); }); - it('Should detect double quotes', function() { + it.skip('Should detect double quotes', function() { this.shouldDetect( ['quotes'], 'a { content: "foo" }', @@ -88,7 +88,7 @@ describe.skip('options/quotes', function() { ); }); - it('Should detect single quotes', function() { + it.skip('Should detect single quotes', function() { this.shouldDetect( ['quotes'], 'a { content: \'foo\' }', @@ -98,7 +98,7 @@ describe.skip('options/quotes', function() { ); }); - it('Should detect single quotes in attribute', function() { + it.skip('Should detect single quotes in attribute', function() { this.shouldDetect( ['quotes'], 'a[class^=\'foo\'] { color: red }', @@ -108,7 +108,7 @@ describe.skip('options/quotes', function() { ); }); - it('Should detect double quotes in url', function() { + it.skip('Should detect double quotes in url', function() { this.shouldDetect( ['quotes'], 'a { background: url("foo.png") }', From 5d0ce4b161e3c2918a69dab9d42d40f5d38d4e7a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 016/184] Gonzales 3.0: Update `remove-empty-rulesets` --- lib/options/remove-empty-rulesets.js | 64 +++++++++---------- .../remove-empty-rulesets-less/test.js | 2 +- .../remove-empty-rulesets-scss/test.js | 2 +- test/options/remove-empty-rulesets/test.js | 4 +- 4 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/options/remove-empty-rulesets.js b/lib/options/remove-empty-rulesets.js index 9573283a..3999def0 100644 --- a/lib/options/remove-empty-rulesets.js +++ b/lib/options/remove-empty-rulesets.js @@ -1,32 +1,30 @@ module.exports = (function() { - function processStylesheetContent(nodeContent) { - removeEmptyRulesets(nodeContent); - mergeAdjacentWhitespace(nodeContent); + function processStylesheetContent(node) { + removeEmptyRulesets(node); + mergeAdjacentWhitespace(node); } - function removeEmptyRulesets(nodeContent) { - var i = nodeContent.length; + function removeEmptyRulesets(stylesheet) { + var i = stylesheet.content.length; // Loop through node and try to find a ruleset: while (i--) { - var node = nodeContent[i]; + var node = stylesheet.content[i]; if (!isRuleset(node)) continue; // If a ruleset is found, try to find its nested rulesets and remove // all empty ones: - var j = node.length; + var j = node.content.length; while (j--) { // Nested rulesets are located inside blocks, that's why look // for blocks only: - var blockNode = node[j]; - if (blockNode[0] !== 'block') continue; - blockNode.shift(); + var blockNode = node.content[j]; + if (blockNode.type !== 'block') continue; processStylesheetContent(blockNode); - blockNode.unshift('block'); - node[j] = blockNode; + node.content[j] = blockNode; } // If after removing all empty nested rulesets the parent has also // become empty, remove it too: if (isEmptyRuleset(node)) { - nodeContent.splice(i, 1); + stylesheet.content.splice(i, 1); } } } @@ -37,42 +35,41 @@ module.exports = (function() { * To ensure correctness of further processing we should merge such nodes into one. * [space, space] => [space] */ - function mergeAdjacentWhitespace(nodeContent) { - var i = nodeContent.length - 1; + function mergeAdjacentWhitespace(node) { + var i = node.content.length - 1; while (i-- > 0) { - if (isWhitespace(nodeContent[i]) && isWhitespace(nodeContent[i + 1])) { - nodeContent[i][1] += nodeContent[i + 1][1]; - nodeContent.splice(i + 1, 1); + if (isWhitespace(node.content[i]) && isWhitespace(node.content[i + 1])) { + node.content[i].content += node.content[i + 1].content; + node.content.splice(i + 1, 1); } } } function isEmptyRuleset(ruleset) { - return ruleset.filter(isBlock).every(isEmptyBlock, this); + return isEmptyBlock(ruleset.first('block')); } /** * Block is considered empty when it has nothing but spaces. */ function isEmptyBlock(node) { - return node.length === 1 || !node.some(isNotWhitespace); - } + if (!node.content.length) return true; - function isRuleset(node) { - return node[0] === 'ruleset'; + var isEmpty = true; + node.forEach(function(childNode) { + if (childNode.type !== 's') isEmpty = false; + }); + return isEmpty; } - function isBlock(node) { - return node[0] === 'block'; + function isRuleset(node) { + return node.type === 'ruleset'; } function isWhitespace(node) { - return node[0] === 's'; + return node.type === 's'; } - function isNotWhitespace(node) { - return typeof node === 'object' && node[0] !== 's'; - } return { name: 'remove-empty-rulesets', @@ -86,12 +83,11 @@ module.exports = (function() { /** * Remove rulesets with no declarations. * - * @param {String} nodeType - * @param {Array} nodeContent + * @param {String} node */ - process: function(nodeType, nodeContent) { - if (nodeType === 'stylesheet') { - processStylesheetContent(nodeContent); + process: function(node) { + if (node.type === 'stylesheet') { + processStylesheetContent(node); } }, diff --git a/test/options/remove-empty-rulesets-less/test.js b/test/options/remove-empty-rulesets-less/test.js index e8711aa5..a031071d 100644 --- a/test/options/remove-empty-rulesets-less/test.js +++ b/test/options/remove-empty-rulesets-less/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/remove-empty-rulesets (less):', function() { +describe('options/remove-empty-rulesets (less):', function() { it('Issue 201. Test 1', function() { this.comb.configure({ 'remove-empty-rulesets': true }); this.shouldBeEqual('1.less', '1.expected.less'); diff --git a/test/options/remove-empty-rulesets-scss/test.js b/test/options/remove-empty-rulesets-scss/test.js index 605a6393..de898210 100644 --- a/test/options/remove-empty-rulesets-scss/test.js +++ b/test/options/remove-empty-rulesets-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/remove-empty-rulesets (scss)', function() { +describe('options/remove-empty-rulesets (scss)', function() { beforeEach(function() { this.comb.configure({ 'remove-empty-rulesets': true }); }); diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/test.js index d6e7ecaa..509c5d60 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/remove-empty-rulesets', function() { +describe('options/remove-empty-rulesets', function() { it('Configured with invalid value, should not remove empty ruleset', function() { this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); assert.equal(this.comb.processString('a { width: 10px; } b {}'), 'a { width: 10px; } b {}'); @@ -28,7 +28,7 @@ describe.skip('options/remove-empty-rulesets', function() { }); }); - describe('detecting the value', function() { + describe.skip('detecting the value', function() { it('Should detect this option set to `true`', function() { this.shouldDetect( ['remove-empty-rulesets'], From 518fb2456ef7c3cbdd71f25ec2a8433f0451e003 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 017/184] Gonzales 3.0: Update `space-after-colon` --- lib/options/space-after-colon.js | 18 ++++++++++-------- test/options/space-after-colon-sass/test.js | 2 +- test/options/space-after-colon-scss/test.js | 2 +- test/options/space-after-colon/test.js | 10 +++++----- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/options/space-after-colon.js b/lib/options/space-after-colon.js index d1466b1a..b6506dc3 100644 --- a/lib/options/space-after-colon.js +++ b/lib/options/space-after-colon.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-after-colon', @@ -13,23 +15,23 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'declaration') return; + process: function(node) { + if (!node.is('declaration')) return; var value = this.getValue('space-after-colon'); - for (var i = node.length; i--;) { - if (node[i][0] !== 'propertyDelim') continue; + for (var i = node.content.length; i--;) { + if (!node.content[i].is('propertyDelim')) continue; - if (this.getSyntax() === 'sass' && !node[i - 1]) break; + if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; // Remove any spaces after colon: - if (node[i + 1][0] === 's') node.splice(i + 1, 1); + if (node.content[i + 1].is('s')) node.content.splice(i + 1, 1); // If the value set in config is not empty, add spaces: - if (value !== '') node.splice(i + 1, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + if (value !== '') node.content.splice(i + 1, 0, space); break; } diff --git a/test/options/space-after-colon-sass/test.js b/test/options/space-after-colon-sass/test.js index e9397920..d85412d9 100644 --- a/test/options/space-after-colon-sass/test.js +++ b/test/options/space-after-colon-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-colon (sass):', function() { +describe('options/space-after-colon (sass):', function() { it('Should set proper space if colon is after property name', function() { this.comb.configure({ 'space-after-colon': 2 }); this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); diff --git a/test/options/space-after-colon-scss/test.js b/test/options/space-after-colon-scss/test.js index f5d9d2b5..b95d7f5d 100644 --- a/test/options/space-after-colon-scss/test.js +++ b/test/options/space-after-colon-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-colon (scss):', function() { +describe('options/space-after-colon (scss):', function() { it('Space after colon should not affect pseudo elements', function() { this.comb.configure({ 'space-after-colon': 1 }); this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/test.js index 364db29c..6e00b929 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-colon:', function() { +describe('options/space-after-colon:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-after-colon:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespaces', function() { + it.skip('Should detect no whitespaces', function() { this.shouldDetect( ['space-after-colon'], 'a { color:red }', @@ -37,7 +37,7 @@ describe.skip('options/space-after-colon:', function() { ); }); - it('Should detect space from two variants', function() { + it.skip('Should detect space from two variants', function() { this.shouldDetect( ['space-after-colon'], 'a { color: red; color :red }', @@ -45,7 +45,7 @@ describe.skip('options/space-after-colon:', function() { ); }); - it('Should detect no whitespaces along three variants', function() { + it.skip('Should detect no whitespaces along three variants', function() { this.shouldDetect( ['space-after-colon'], 'a { color: red; background :red } b { width:10px }', @@ -53,7 +53,7 @@ describe.skip('options/space-after-colon:', function() { ); }); - it('Should detect space', function() { + it.skip('Should detect space', function() { this.shouldDetect( ['space-after-colon'], 'a { color : red; background :red } b { width: 10px }', From ebc032fbfe0907f047abac74a518051ddaf67374 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 018/184] Gonzales 3.0: Update `space-after-combinator` --- lib/options/space-after-combinator.js | 22 +++++++++++---------- test/options/space-after-combinator/test.js | 14 ++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/options/space-after-combinator.js b/lib/options/space-after-combinator.js index 804c5b96..acc4a54e 100644 --- a/lib/options/space-after-combinator.js +++ b/lib/options/space-after-combinator.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-after-combinator', @@ -13,23 +15,23 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'selector') return; + process: function(node) { + if (!node.is('selector')) return; var value = this.getValue('space-after-combinator'); - for (var i = node.length; i--;) { - var subSelector = node[i]; - for (var j = subSelector.length; j--;) { - if (subSelector[j][0] !== 'combinator') continue; + for (var i = node.content.length; i--;) { + var subSelector = node.content[i]; + for (var j = subSelector.content.length; j--;) { + if (!subSelector.content[j].is('combinator')) continue; - if (subSelector[j + 1][0] === 's') { - subSelector[j + 1][1] = value; + if (subSelector.content[j + 1].is('s')) { + subSelector.content[j + 1].content = value; } else { - subSelector.splice(j + 1, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + subSelector.content.splice(j + 1, 0, space); } } } diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/test.js index 2128d34c..4fafab48 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-combinator:', function() { +describe('options/space-after-combinator:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-after-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespaces after combinator', function() { + it.skip('Should detect no whitespaces after combinator', function() { this.shouldDetect( ['space-after-combinator'], 'a+b { color:red }', @@ -37,7 +37,7 @@ describe.skip('options/space-after-combinator:', function() { ); }); - it('Should detect a space after combinator', function() { + it.skip('Should detect a space after combinator', function() { this.shouldDetect( ['space-after-combinator'], 'a + \n b { color:red }', @@ -45,7 +45,7 @@ describe.skip('options/space-after-combinator:', function() { ); }); - it('Should detect a space after combinator in long selector', function() { + it.skip('Should detect a space after combinator in long selector', function() { this.shouldDetect( ['space-after-combinator'], 'a + b ~ c>d { color:red }', @@ -53,7 +53,7 @@ describe.skip('options/space-after-combinator:', function() { ); }); - it('Should detect a space after combinator in long selector, test 2', function() { + it.skip('Should detect a space after combinator in long selector, test 2', function() { this.shouldDetect( ['space-after-combinator'], 'a>b + c + d { color:red }', @@ -61,7 +61,7 @@ describe.skip('options/space-after-combinator:', function() { ); }); - it('Should detect no whitespaces after combinator in long selector', function() { + it.skip('Should detect no whitespaces after combinator in long selector', function() { this.shouldDetect( ['space-after-combinator'], 'a+b ~ c+d { color:red }', @@ -69,7 +69,7 @@ describe.skip('options/space-after-combinator:', function() { ); }); - it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { + it.skip('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { this.shouldDetect( ['space-after-combinator'], 'a { color:red }', From 8b67eaf965cccac534ac9974e6f51c3bd7abd58b Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 019/184] Gonzales 3.0: Update `space-after-opening-brace` --- lib/options/space-after-opening-brace.js | 14 ++++++++------ test/options/space-after-opening-brace/test.js | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/options/space-after-opening-brace.js b/lib/options/space-after-opening-brace.js index 90f30dfa..fae3d7b7 100644 --- a/lib/options/space-after-opening-brace.js +++ b/lib/options/space-after-opening-brace.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-after-opening-brace', @@ -13,19 +15,19 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { // If found block node stop at the next one for space check - if (nodeType !== 'block' && nodeType !== 'atrulers') return; + if (!node.is('block') && !node.is('atrulers')) return; var value = this.getValue('space-after-opening-brace'); - if (node[0][0] === 's') { - node[0][1] = value; + if (node.content[0].is('s')) { + node.content[0].content = value; } else if (value !== '') { - node.unshift(['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + node.content.unshift(space); } }, diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 22ab0945..47f337b1 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-opening-brace:', function() { +describe('options/space-after-opening-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-after-opening-brace:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespace', function() { + it.skip('Should detect no whitespace', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0}', @@ -37,7 +37,7 @@ describe.skip('options/space-after-opening-brace:', function() { ); }); - it('Should detect whitespace', function() { + it.skip('Should detect whitespace', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{\n\ttop:0}', @@ -45,7 +45,7 @@ describe.skip('options/space-after-opening-brace:', function() { ); }); - it('Should detect no whitespace (2 blocks)', function() { + it.skip('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0} b{\n left:0}', @@ -53,7 +53,7 @@ describe.skip('options/space-after-opening-brace:', function() { ); }); - it('Should detect whitespace (2 blocks)', function() { + it.skip('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{ top:0 } b{left:0}', @@ -61,7 +61,7 @@ describe.skip('options/space-after-opening-brace:', function() { ); }); - it('Should detect no whitespace (3 blocks)', function() { + it.skip('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0} b { left: 0 } c{\n\tright:0}', @@ -69,7 +69,7 @@ describe.skip('options/space-after-opening-brace:', function() { ); }); - it('Should detect whitespace (3 blocks)', function() { + it.skip('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{\ntop:0} b{\nleft:0} c{\n right:0}', From 010d3999c60271468223d1c04539727ba6708190 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 020/184] Gonzales 3.0: Update `space-after-selector-delimiter` --- lib/options/space-after-selector-delimiter.js | 22 ++++++++++--------- .../test.js | 2 +- .../space-after-selector-delimiter/test.js | 14 ++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/options/space-after-selector-delimiter.js b/lib/options/space-after-selector-delimiter.js index bf9c3338..0240210b 100644 --- a/lib/options/space-after-selector-delimiter.js +++ b/lib/options/space-after-selector-delimiter.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-after-selector-delimiter', @@ -13,23 +15,23 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'selector') return; + process: function(node) { + if (!node.is('selector')) return; var value = this.getValue('space-after-selector-delimiter'); - for (var i = node.length; i--;) { - if (node[i][0] !== 'delim') continue; + for (var i = node.content.length; i--;) { + if (!node.content[i].is('delim')) continue; - if (node[i + 1][0] === 's') { - node[i + 1][1] = value; - } else if (node[i + 1][1][0] === 's') { - node[i + 1][1][1] = value; + if (node.content[i + 1].is('s')) { + node.content[i + 1].content = value; + } else if (node.content[i + 1].content[0].is('s')) { + node.content[i + 1].content[0].content = value; } else { - node[i + 1].splice(1, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + node.content[i + 1].content.unshift(space); } } }, diff --git a/test/options/space-after-selector-delimiter-sass/test.js b/test/options/space-after-selector-delimiter-sass/test.js index fae87913..c0c10e9f 100644 --- a/test/options/space-after-selector-delimiter-sass/test.js +++ b/test/options/space-after-selector-delimiter-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-selector-delimiter (sass):', function() { +describe('options/space-after-selector-delimiter (sass):', function() { it('Issue 238', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n' }); this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/test.js index 09f2cd99..03563da0 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-after-selector-delimiter:', function() { +describe('options/space-after-selector-delimiter:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespace', function() { + it.skip('Should detect no whitespace', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0}', @@ -37,7 +37,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { ); }); - it('Should detect whitespace', function() { + it.skip('Should detect whitespace', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, \n b {top:0}', @@ -45,7 +45,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { ); }); - it('Should detect no whitespace (2 blocks)', function() { + it.skip('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0} a, b{left:0}', @@ -53,7 +53,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { ); }); - it('Should detect whitespace (2 blocks)', function() { + it.skip('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, b {top:0} b,a{left:0}', @@ -61,7 +61,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { ); }); - it('Should detect no whitespace (3 blocks)', function() { + it.skip('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, b{top:0} b,c{left:0} c,d{right:0}', @@ -69,7 +69,7 @@ describe.skip('options/space-after-selector-delimiter:', function() { ); }); - it('Should detect whitespace (3 blocks)', function() { + it.skip('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0} b, c{left:0} c, sd{right:0}', From 0528cfc336d1fdebbd22da106dffc12fca9603c7 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 021/184] Gonzales 3.0: Update `space-before-colon` --- lib/options/space-before-colon.js | 20 +++++++++++--------- test/options/space-before-colon-sass/test.js | 2 +- test/options/space-before-colon/test.js | 10 +++++----- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/options/space-before-colon.js b/lib/options/space-before-colon.js index a960819b..40ffc47c 100644 --- a/lib/options/space-before-colon.js +++ b/lib/options/space-before-colon.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-before-colon', @@ -13,26 +15,26 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'declaration') return; + process: function(node) { + if (!node.is('declaration')) return; var value = this.getValue('space-before-colon'); - for (var i = node.length; i--;) { - if (node[i][0] !== 'propertyDelim') continue; + for (var i = node.content.length; i--;) { + if (!node.content[i].is('propertyDelim')) continue; - if (this.getSyntax() === 'sass' && !node[i - 1]) break; + if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; // Remove any spaces before colon: - if (node[i - 1][0] === 's') { - node.splice(i - 1, 1); + if (node.content[i - 1].is('s')) { + node.content.splice(i - 1, 1); i--; } // If the value set in config is not empty, add spaces: - if (value !== '') node.splice(i, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + if (value !== '') node.content.splice(i, 0, space); break; } diff --git a/test/options/space-before-colon-sass/test.js b/test/options/space-before-colon-sass/test.js index bffd6de4..d9380d5e 100644 --- a/test/options/space-before-colon-sass/test.js +++ b/test/options/space-before-colon-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-colon-sass:', function() { +describe('options/space-before-colon-sass:', function() { it('Should correct space', function() { this.comb.configure({ 'space-before-colon': 1 }); this.shouldBeEqual('test.sass', 'test.expected.sass'); diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/test.js index e5025bed..f239f168 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-colon:', function() { +describe('options/space-before-colon:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-before-colon:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespaces', function() { + it.skip('Should detect no whitespaces', function() { this.shouldDetect( ['space-before-colon'], 'a { color:red }', @@ -37,7 +37,7 @@ describe.skip('options/space-before-colon:', function() { ); }); - it('Should detect no space from two variants', function() { + it.skip('Should detect no space from two variants', function() { this.shouldDetect( ['space-before-colon'], 'a { color: red; color :red }', @@ -45,7 +45,7 @@ describe.skip('options/space-before-colon:', function() { ); }); - it('Should detect no whitespaces along three variants', function() { + it.skip('Should detect no whitespaces along three variants', function() { this.shouldDetect( ['space-before-colon'], 'a { color: red; background :red } b { width:10px }', @@ -53,7 +53,7 @@ describe.skip('options/space-before-colon:', function() { ); }); - it('Should detect space', function() { + it.skip('Should detect space', function() { this.shouldDetect( ['space-before-colon'], 'a { color : red; background :red } b { width:10px }', From 7b08500a4914a3f2aa52e79a0bd1f95016795da7 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 022/184] Gonzales 3.0: Update `space-before-combinator` --- lib/options/space-before-combinator.js | 18 ++++++++++-------- test/options/space-before-combinator/test.js | 14 +++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/options/space-before-combinator.js b/lib/options/space-before-combinator.js index c73bb120..0eceeb8e 100644 --- a/lib/options/space-before-combinator.js +++ b/lib/options/space-before-combinator.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-before-combinator', @@ -13,22 +15,22 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'selector') return; + process: function(node) { + if (!node.is('selector')) return; var value = this.getValue('space-before-combinator'); for (var i = node.length; i--;) { - var subSelector = node[i]; + var subSelector = node.get(i); for (var j = subSelector.length; j--;) { - if (subSelector[j][0] !== 'combinator') continue; - if (subSelector[j - 1][0] === 's') { - subSelector[j - 1][1] = value; + if (!subSelector.get(j).is('combinator')) continue; + if (subSelector.get(j - 1).is('s')) { + subSelector.get(j - 1).content = value; } else { - subSelector.splice(j, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + subSelector.insert(j, space); } } } diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index bbedb8bb..0a25a3bf 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-combinator:', function() { +describe('options/space-before-combinator:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-before-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespaces before combinator', function() { + it.skip('Should detect no whitespaces before combinator', function() { this.shouldDetect( ['space-before-combinator'], 'a+b { color:red }', @@ -37,7 +37,7 @@ describe.skip('options/space-before-combinator:', function() { ); }); - it('Should detect a space before combinator', function() { + it.skip('Should detect a space before combinator', function() { this.shouldDetect( ['space-before-combinator'], 'a + b { color:red }', @@ -45,7 +45,7 @@ describe.skip('options/space-before-combinator:', function() { ); }); - it('Should detect a space before combinator in long selector', function() { + it.skip('Should detect a space before combinator in long selector', function() { this.shouldDetect( ['space-before-combinator'], 'a + b ~ c>d { color:red }', @@ -53,7 +53,7 @@ describe.skip('options/space-before-combinator:', function() { ); }); - it('Should detect a space before combinator in long selector, test 2', function() { + it.skip('Should detect a space before combinator in long selector, test 2', function() { this.shouldDetect( ['space-before-combinator'], 'a>b + c + d { color:red }', @@ -61,7 +61,7 @@ describe.skip('options/space-before-combinator:', function() { ); }); - it('Should detect no whitespaces before combinator in long selector', function() { + it.skip('Should detect no whitespaces before combinator in long selector', function() { this.shouldDetect( ['space-before-combinator'], 'a+b ~ c+d { color:red }', @@ -69,7 +69,7 @@ describe.skip('options/space-before-combinator:', function() { ); }); - it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { + it.skip('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { this.shouldDetect( ['space-before-combinator'], 'a { color:red }', From a1bcd5fdd202650d9d5b27afd27c9e21020ac817 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 023/184] Gonzales 3.0: Update `space-before-opening-brace` --- lib/options/space-before-opening-brace.js | 29 ++++++++++++------- .../space-before-opening-brace-scss/test.js | 2 +- .../space-before-opening-brace/test.js | 14 ++++----- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index 3aecb14a..c79c8d18 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = (function() { /** * Gets the last (the deepest) whitespace node. @@ -8,9 +10,9 @@ module.exports = (function() { */ function getLastWhitespaceNode(node) { if (typeof node !== 'object') return; - if (node[0] === 's') return node; + if (node.is('s')) return node; - return getLastWhitespaceNode(node[node.length - 1]); + return getLastWhitespaceNode(node.last()); } return { @@ -28,31 +30,38 @@ module.exports = (function() { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { var value = this.getValue('space-before-opening-brace'); // Loop through node from the end to the beginning: for (var i = node.length; i--;) { + if (!node.get(i) || typeof node.get(i) === 'string') continue; + + try { + node.get(i).is('s'); + } catch (e) { + console.log(node); + } // If found block node stop at the next one for space check: - if (node[i][0] !== 'block' && node[i][0] !== 'atrulers') continue; + if (!node.get(i).is('block') && !node.get(i).is('atrulers')) continue; // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) - var whitespaceNode = getLastWhitespaceNode(node[i - 1]); + var whitespaceNode = getLastWhitespaceNode(node.get(i - 1)); // If it's spaces, modify this node. // If it's something different from spaces, add a space node to // the end: if (whitespaceNode) { - whitespaceNode[1] = value; + whitespaceNode.content = value; } else if (value !== '') { - if (node[i - 1][0] === 'atrulerq') { - node[i - 1].push(['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + if (node.get(i - 1).is('atrulerq')) { + node.get(i - 1).content.push(space); } else { - node.splice(i, 0, ['s', value]); + node.insert(i, space); } } } diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace-scss/test.js index 0071d9fd..100f0abc 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-opening-brace (scss):', function() { +describe('options/space-before-opening-brace (scss):', function() { it('Issue 231', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/test.js index c3fc3c66..4143b7a7 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-opening-brace:', function() { +describe('options/space-before-opening-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -34,7 +34,7 @@ describe.skip('options/space-before-opening-brace:', function() { this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); }); - it('Should detect no whitespace', function() { + it.skip('Should detect no whitespace', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0}', @@ -42,7 +42,7 @@ describe.skip('options/space-before-opening-brace:', function() { ); }); - it('Should detect whitespace', function() { + it.skip('Should detect whitespace', function() { this.shouldDetect( ['space-before-opening-brace'], 'a \n {top:0}', @@ -50,7 +50,7 @@ describe.skip('options/space-before-opening-brace:', function() { ); }); - it('Should detect no whitespace (2 blocks)', function() { + it.skip('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0} b {left:0}', @@ -58,7 +58,7 @@ describe.skip('options/space-before-opening-brace:', function() { ); }); - it('Should detect whitespace (2 blocks)', function() { + it.skip('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a {top:0} b{left:0}', @@ -66,7 +66,7 @@ describe.skip('options/space-before-opening-brace:', function() { ); }); - it('Should detect no whitespace (3 blocks)', function() { + it.skip('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a {top:0} b{left:0} c{right:0}', @@ -74,7 +74,7 @@ describe.skip('options/space-before-opening-brace:', function() { ); }); - it('Should detect whitespace (3 blocks)', function() { + it.skip('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0} b {left:0} c {right:0}', From ced8b941a596e8b35ae8b4686a6aecc4d7c6ca01 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 024/184] Gonzales 3.0: Update `space-before-selector-delimiter` --- .../space-before-selector-delimiter.js | 22 +++++++++---------- .../space-before-selector-delimiter/test.js | 14 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/options/space-before-selector-delimiter.js b/lib/options/space-before-selector-delimiter.js index 0a89a5d0..b7366f86 100644 --- a/lib/options/space-before-selector-delimiter.js +++ b/lib/options/space-before-selector-delimiter.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'space-before-selector-delimiter', @@ -13,24 +15,22 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'selector') return; + process: function(node) { + if (!node.is('selector')) return; var value = this.getValue('space-before-selector-delimiter'); - for (var i = node.length; i--;) { - if (node[i][0] !== 'delim') continue; - - var previousNode = node[i - 1]; - if (previousNode[previousNode.length - 1][0] === 's') { - previousNode[previousNode.length - 1][1] = value; + node.forEach('delim', function(delim, i) { + var previousNode = node.get(i - 1); + if (previousNode.last().is('s')) { + previousNode.last().content = value; } else { - previousNode.push(['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + previousNode.content.push(space); } - } + }); }, /** diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/test.js index f360282f..dc3e588e 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-selector-delimiter:', function() { +describe('options/space-before-selector-delimiter:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespace', function() { + it.skip('Should detect no whitespace', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0}', @@ -37,7 +37,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { ); }); - it('Should detect whitespace', function() { + it.skip('Should detect whitespace', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a \n ,b {top:0}', @@ -45,7 +45,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { ); }); - it('Should detect no whitespace (2 blocks)', function() { + it.skip('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0} a ,b{left:0}', @@ -53,7 +53,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { ); }); - it('Should detect whitespace (2 blocks)', function() { + it.skip('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a ,b {top:0} b,a{left:0}', @@ -61,7 +61,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { ); }); - it('Should detect no whitespace (3 blocks)', function() { + it.skip('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a ,b{top:0} b,c{left:0} c,d{right:0}', @@ -69,7 +69,7 @@ describe.skip('options/space-before-selector-delimiter:', function() { ); }); - it('Should detect whitespace (3 blocks)', function() { + it.skip('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0} b ,c{left:0} c ,d{right:0}', From 722779eeb71a347d67e0a581d47f45439ca98372 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 025/184] Gonzales 3.0: Update `space-between-declarations` --- lib/options/space-between-declarations.js | 46 +++++++++---------- .../space-between-declarations/test.js | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/options/space-between-declarations.js b/lib/options/space-between-declarations.js index 1b7a832c..f7debf52 100644 --- a/lib/options/space-between-declarations.js +++ b/lib/options/space-between-declarations.js @@ -1,20 +1,22 @@ +var gonzales = require('gonzales-pe'); + module.exports = (function() { function getDeclarationEnd(node, i) { for (;i < node.length; i++) { - if (!node[i + 1]) { + if (!node.get(i + 1) || typeof node.get(i + 1) === 'string') { return 0; - } else if (node[i + 1][0] === 's') { - if (node[i + 1][1].indexOf('\n') > -1) { - if (node[i + 2] && node[i + 2][0] === 'declaration') { + } else if (node.get(i + 1).is('s')) { + if (node.get(i + 1).content.indexOf('\n') > -1) { + if (node.get(i + 2) && node.get(i + 2).is('declaration')) { return i; } else { return 0; } - } else if (node[i + 2] && node[i + 2][0] === 'commentML') { - if (node[i + 3] && node[i + 3][0] === 'declaration') { + } else if (node.get(i + 2) && node.get(i + 2).is('commentML')) { + if (node.get(i + 3) && node.get(i + 3).is('declaration')) { return i + 2; - } else if (node[i + 3] && node[i + 3][0] === 's') { - if (node[i + 4] && node[i + 4][0] === 'declaration') { + } else if (node.get(i + 3) && node.get(i + 3).is('s')) { + if (node.get(i + 4) && node.get(i + 4).is('declaration')) { return i + 2; } else { return 0; @@ -22,16 +24,16 @@ module.exports = (function() { } else { return 0; } - } else if (node[i + 2] && node[i + 2][0] === 'declaration') { + } else if (node.get(i + 2) && node.get(i + 2).is('declaration')) { return i; } - } else if (node[i + 1][0] === 'declaration') { + } else if (node.get(i + 1).is('declaration')) { return i; - } else if (node[i + 1][0] === 'commentML') { - if (node[i + 2] && node[i + 2][0] === 'declaration') { + } else if (node.get(i + 1).is('commentML')) { + if (node.get(i + 2) && node.get(i + 2).is('declaration')) { return i + 1; - } else if (node[i + 2] && node[i + 2][0] === 's') { - if (node[i + 3] && node[i + 3][0] === 'declaration') { + } else if (node.get(i + 2) && node.get(i + 2).is('s')) { + if (node.get(i + 3) && node.get(i + 3).is('declaration')) { return i + 1; } } else { @@ -58,18 +60,15 @@ module.exports = (function() { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { var value = this.getValue('space-between-declarations'); // TODO: Limit nodes to blocks, stylesheet, etc. for (var i = 0, l = node.length; i < l; i++) { - var currentNode = node[i]; - - if (currentNode[0] !== 'declDelim') continue; + if (!node.get(i) || !node.get(i).is('declDelim')) continue; // Grom user's point of view "declaration" includes semicolons // and comments placed on the same line. @@ -81,13 +80,14 @@ module.exports = (function() { i = declarationEnd; } - var nextNode = node[i + 1]; - if (nextNode[0] === 's') { - nextNode[1] = value; + var nextNode = node.get(i + 1); + if (nextNode.is('s')) { + nextNode.content = value; } else { i++; l++; - node.splice(i, 0, ['s', value]); + var space = gonzales.createNode({ type: 's', content: value }); + node.insert(i, space); } } } diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/test.js index 4d129827..0434ed5d 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-between-declarations:', function() { +describe('options/space-between-declarations:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ['', ' '] }); this.shouldBeEqual('test.css'); From 978350d0be1d0c3762c8b93b64ced22efbec3974 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 026/184] Gonzales 3.0: Update `strip-spaces` --- lib/options/strip-spaces.js | 16 ++++++++-------- test/options/strip-spaces/test.js | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/options/strip-spaces.js b/lib/options/strip-spaces.js index 81967e9c..6ad80126 100644 --- a/lib/options/strip-spaces.js +++ b/lib/options/strip-spaces.js @@ -18,17 +18,17 @@ module.exports = (function() { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 's') { - node[0] = trim(node[0]); + process: function(node) { + if (node.is('s')) { + node.content = trim(node.content); } - if (nodeType === 'stylesheet') { - var lastChild = node[node.length - 1]; - if (lastChild[0] === 's') { - lastChild[1] = trim(lastChild[1]) + + if (node.is('stylesheet')) { + var lastChild = node.last(); + if (lastChild.is('s')) { + lastChild.content = trim(lastChild.content) .replace(/[ \t]+$/, '') .replace(/[\n]+/g, '\n'); } diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/test.js index 08cbfc0a..082fc4e0 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/strip-spaces', function() { +describe('options/strip-spaces', function() { it('Invalid value should not trim trailing spaces', function() { this.comb.configure({ 'strip-spaces': 'foobar' }); assert.equal( @@ -31,7 +31,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `true`', function() { + it.skip('Should detect strip-spaces option set to `true`', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }', @@ -41,7 +41,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `false`', function() { + it.skip('Should detect strip-spaces option set to `false`', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red } ', @@ -51,7 +51,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `true` with newline', function() { + it.skip('Should detect strip-spaces option set to `true` with newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\nb { color: blue }', @@ -61,7 +61,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `false` with newline', function() { + it.skip('Should detect strip-spaces option set to `false` with newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red } \nb { color: blue }', @@ -71,7 +71,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `true` inside a value', function() { + it.skip('Should detect strip-spaces option set to `true` inside a value', function() { this.shouldDetect( ['strip-spaces'], 'a {\n color:\n red }', @@ -81,7 +81,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `false` inside a value', function() { + it.skip('Should detect strip-spaces option set to `false` inside a value', function() { this.shouldDetect( ['strip-spaces'], 'a {\n color: \n red }', @@ -91,7 +91,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { + it.skip('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\n', @@ -101,7 +101,7 @@ describe.skip('options/strip-spaces', function() { ); }); - it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { + it.skip('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\n\n', From a848aa35c0ef514fc535b6779f7ac4d3024dedf3 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 027/184] Gonzales 3.0: Update `tab-size` option --- lib/options/tab-size.js | 7 +++---- test/options/tab-size/test.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/options/tab-size.js b/lib/options/tab-size.js index d8e641d9..191d1cc6 100644 --- a/lib/options/tab-size.js +++ b/lib/options/tab-size.js @@ -10,11 +10,10 @@ module.exports = { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 's') return; - node[0] = node[0].replace(/\t/, this.getValue('tab-size')); + process: function(node) { + if (!node.is('s')) return; + node.content = node.content.replace(/\t/, this.getValue('tab-size')); } }; diff --git a/test/options/tab-size/test.js b/test/options/tab-size/test.js index 4991e3f6..05560b1f 100644 --- a/test/options/tab-size/test.js +++ b/test/options/tab-size/test.js @@ -1,4 +1,4 @@ -describe.skip('options/tab-size:', function() { +describe('options/tab-size:', function() { it('Test 1: String value => should not change anything', function() { this.comb.configure({ 'tab-size': ' ' }); this.shouldBeEqual('test.css'); From d39942e2f5f5a3de15910162738562622565c273 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 028/184] Gonzales 3.0: Update `unitless-zero` option --- lib/options/unitless-zero.js | 28 +++++++++++++++++++--------- test/options/unitless-zero/test.js | 16 ++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index a581e20e..61fcc651 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -7,17 +7,27 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType + * * @param {node} node */ - process: function(nodeType, node) { - if (nodeType === 'value' || nodeType === 'braces') { - node.forEach(function(child, index) { - if ( - (child[0] === 'percentage' || - child[0] === 'dimension' && ['cm', 'em', 'ex', 'pt', 'px'].indexOf(child[2][1]) !== -1) && - child[1][1] === '0') { - node[index] = child[1]; + process: function(node) { + var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; + + if (node.is('value') || node.is('braces')) { + node.forEach(function(child) { + if (typeof child === 'string') return; + + if (child.is('dimension')) { + var unit = child.get(1).content; + if (child.get(0).content[0] === '0' && UNITS.indexOf(unit) !== -1) { + child.content.splice(1, 1); + } + } else if (child.is('percentage')) { + var number = child.get(0).content; + if (number[0] === '0') { + child.type = 'number'; + child.content = number; + } } }); } diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index 177d15df..12c5bd83 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/unitless-zero', function() { +describe('options/unitless-zero', function() { it('Should remove units in zero-valued dimensions', function() { this.comb.configure({ 'unitless-zero': true }); assert.equal( @@ -35,7 +35,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Should detect unitless zero option', function() { + it.skip('Should detect unitless zero option', function() { this.shouldDetect( ['unitless-zero'], 'a { width: 0 }', @@ -45,7 +45,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Should detect zero with unit', function() { + it.skip('Should detect zero with unit', function() { this.shouldDetect( ['unitless-zero'], 'a { width: 0px }', @@ -55,7 +55,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Should detect unitless zero option with multiple values', function() { + it.skip('Should detect unitless zero option with multiple values', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0px 0 0 }', @@ -65,7 +65,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Should detect zero with unit and multiple values', function() { + it.skip('Should detect zero with unit and multiple values', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0px 0 0em }', @@ -75,7 +75,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Shouldn’t detect unitless zero option if there is no unit', function() { + it.skip('Shouldn’t detect unitless zero option if there is no unit', function() { this.shouldDetect( ['unitless-zero'], 'a { color: red }', @@ -83,7 +83,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { + it.skip('Shouldn’t detect unitless zero option if there is `deg` unit', function() { this.shouldDetect( ['unitless-zero'], 'a { transform: rotate(0deg) }', @@ -91,7 +91,7 @@ describe.skip('options/unitless-zero', function() { ); }); - it('Should detect unitless zero option with percents', function() { + it.skip('Should detect unitless zero option with percents', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0% 0 0 }', From 9be754b25085e7df5734403c1e431e52b51ac02f Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 029/184] Gonzales 3.0: Update `vendor-prefix-align` --- lib/options/vendor-prefix-align.js | 93 ++++++++----------- test/options/vendor-prefix-align-sass/test.js | 2 +- test/options/vendor-prefix-align/test.js | 22 ++--- 3 files changed, 53 insertions(+), 64 deletions(-) diff --git a/lib/options/vendor-prefix-align.js b/lib/options/vendor-prefix-align.js index b44e9780..832c4fbb 100644 --- a/lib/options/vendor-prefix-align.js +++ b/lib/options/vendor-prefix-align.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = (function() { // Vendor prefixes list: var PREFIXES = [ @@ -73,30 +75,27 @@ module.exports = (function() { for (var i = nodes.length; i--;) { node = nodes[i]; - if (!Array.isArray(node)) - continue; - - if (!node[1]) { + if (!node.content) { crPos = -1; } else { - crPos = node[1].lastIndexOf('\n'); - tabPos = node[1].lastIndexOf('\t'); + crPos = node.content.lastIndexOf('\n'); + tabPos = node.content.lastIndexOf('\t'); if (tabPos > crPos) crPos = tabPos; } if (crPos !== -1) oneline = false; - if (node[0] === 's') { - result += node[1].length - crPos - 1; + if (node.is('s')) { + result += node.content.length - crPos - 1; if (crPos !== -1) break; } - if (node[0] === 'commentML') { + if (node.is('commentML')) { if (crPos === -1) { - result += node[1].length + 4 /* comment symbols length */ ; + result += node.content.length + 4 /* comment symbols length */ ; } else { - result += node[1].length - crPos + 1 /* only last comment symbols length - 1(not count \n)*/; + result += node.content.length - crPos + 1 /* only last comment symbols length - 1(not count \n)*/; break; } } @@ -114,9 +113,9 @@ module.exports = (function() { function extraIndentProperty(nodes, i) { var subset = []; while (i--) { - if (!nodes[i] || nodes[i][0] === 'declDelim') + if (!nodes.get(i) || nodes.get(i).is('declDelim')) break; - subset.unshift(nodes[i]); + subset.unshift(nodes.get(i)); } return extraIndent(subset); } @@ -129,15 +128,16 @@ module.exports = (function() { */ function extraIndentVal(nodes, i) { var subset = []; - var declaration = nodes[i]; + var declaration = nodes.get(i); + if (!declaration.is('declaration')) return; for (var x = declaration.length; x--;) { - if (declaration[x][0] !== 'value') continue; + if (!declaration.get(x).is('value')) continue; x--; - while (declaration[x][0] !== 'propertyDelim') { - subset.push(declaration[x]); + while (!declaration.get(x).is('propertyDelim')) { + subset.push(declaration.get(x)); x--; } @@ -161,11 +161,10 @@ module.exports = (function() { function walk(args) { args.node.forEach(function(item, i) { var name = args.selector(item); - var info = name && getPrefixInfo( - name, - args.namespaceSelector && makeNamespace(args.namespaceSelector(item)), - args.getExtraSymbols(args.node, i) - ); + var namespace = args.namespaceSelector && makeNamespace(args.namespaceSelector(item)); + var extraSymbols = args.getExtraSymbols(args.node, i); + + var info = name && getPrefixInfo(name, namespace, extraSymbols); if (!info) return; args.payload(info, i); }); @@ -181,9 +180,9 @@ module.exports = (function() { * @returns {String|undefined} */ function getPropertyName(node) { - if (node[0] !== 'declaration') return; + if (!node.is('declaration')) return; // TODO: Check that it's not a variable - return node[1][1][1]; + return node.get(0).get(0).content; } /** @@ -198,21 +197,11 @@ module.exports = (function() { * @returns {String|undefined} */ function getValName(node) { - if (node[0] !== 'declaration') return; - - var valueNode; - var value; - - for (var i = node.length; i--;) { - valueNode = node[i]; - - if (valueNode[0] !== 'value') continue; + if (!node.is('declaration')) return; - value = valueNode[1]; - - if (value[0] === 'ident') return value[1]; - if (value[0] === 'function') return value[1][1]; - } + var value = node.first('value'); + if (value.get(0).is('ident')) return value.get(0).content; + if (value.get(0).is('function')) return value.get(0).get(0).content; } /** @@ -271,11 +260,10 @@ module.exports = (function() { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { - if (nodeType !== 'block') return; + process: function(node) { + if (!node.is('block')) return; oneline = true; var dict = {}; @@ -309,16 +297,17 @@ module.exports = (function() { namespaceSelector: getPropertyName, getExtraSymbols: extraIndentVal, payload: function(info, i) { - for (var x = node[i].length; x--;) { - if (node[i][x][0] === 'value') break; + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; } - if (node[i][x - 1][0] !== 's') { - node[i].splice(x, 0, ['s', '']); + if (!node.get(i).get(x - 1).is('s')) { + var space = gonzales.createNode({ type: 's', content: '' }); + node.get(i).insert(x, space); ++x; } - node[i][x - 1][1] = updateIndent(info, dict, node[i][x - 1][1]); + node.get(i).get(x - 1).content = updateIndent(info, dict, node.get(i).get(x - 1).content); } }); @@ -329,15 +318,15 @@ module.exports = (function() { selector: getPropertyName, getExtraSymbols: extraIndentProperty, payload: function(info, i) { - // `node[i - 1]` can be either space or comment: - var whitespaceNode = node[i - 1]; + // `node.get(i - 1)` can be either space or comment: + var whitespaceNode = node.get(i - 1); if (!whitespaceNode) return; // If it's a comment, insert an empty space node: - if (whitespaceNode[0] !== 's') { - whitespaceNode = ['s', '']; - node.splice(i - 1, 0, whitespaceNode); + if (!whitespaceNode.is('s')) { + whitespaceNode = gonzales.createNode({ type: 's', content: '' }); + node.insert(i - 1, whitespaceNode); } - whitespaceNode[1] = updateIndent(info, dict, whitespaceNode[1]); + whitespaceNode.content = updateIndent(info, dict, whitespaceNode.content); } }); }, diff --git a/test/options/vendor-prefix-align-sass/test.js b/test/options/vendor-prefix-align-sass/test.js index f7c9295d..bd59c6d6 100644 --- a/test/options/vendor-prefix-align-sass/test.js +++ b/test/options/vendor-prefix-align-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/vendor-prefix-align', function() { +describe('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index d7c60fcb..6118bad2 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -1,4 +1,4 @@ -describe.skip('options/vendor-prefix-align', function() { +describe('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); @@ -59,7 +59,7 @@ describe.skip('options/vendor-prefix-align', function() { this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); }); - it('Issue 241: should not break tabs', function() { + it.skip('Issue 241: should not break tabs', function() { this.comb.configure({ 'block-indent': '\t', 'vendor-prefix-align': true @@ -67,7 +67,7 @@ describe.skip('options/vendor-prefix-align', function() { this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); }); - it('Shouldn not detect anything if there are no prefixed groups', function() { + it.skip('Shouldn not detect anything if there are no prefixed groups', function() { this.shouldDetect( ['vendor-prefix-align'], 'a{ color: red }a{ -webkit-transform: translateZ(0) }', @@ -75,7 +75,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as false in properties', function() { + it.skip('Shouldn detect vendor-prefix-align as false in properties', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('property-align.css'), @@ -85,7 +85,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as true in properties', function() { + it.skip('Shouldn detect vendor-prefix-align as true in properties', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('property-align.expected.css'), @@ -95,7 +95,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as false in values', function() { + it.skip('Shouldn detect vendor-prefix-align as false in values', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('value-align.css'), @@ -105,7 +105,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as true in values', function() { + it.skip('Shouldn detect vendor-prefix-align as true in values', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('value-align.expected.css'), @@ -115,7 +115,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as true, test 1', function() { + it.skip('Shouldn detect vendor-prefix-align as true, test 1', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('already-aligned.css'), @@ -125,7 +125,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as true, test 2', function() { + it.skip('Shouldn detect vendor-prefix-align as true, test 2', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('complex.expected.css'), @@ -135,7 +135,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Shouldn detect vendor-prefix-align as false', function() { + it.skip('Shouldn detect vendor-prefix-align as false', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('complex.css'), @@ -145,7 +145,7 @@ describe.skip('options/vendor-prefix-align', function() { ); }); - it('Should not detect anything in simple case', function() { + it.skip('Should not detect anything in simple case', function() { this.shouldDetect( ['vendor-prefix-align'], 'a{border:0;}', From c8dd88083a0941992af175acd290b9f1e75f1dee Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 030/184] Gonzales 3.0: Update `block-indent` option --- lib/options/block-indent.js | 72 ++++++++++++++++---------- test/options/block-indent-sass/test.js | 2 +- test/options/block-indent-scss/test.js | 2 +- test/options/block-indent/test.js | 12 ++--- 4 files changed, 53 insertions(+), 35 deletions(-) diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index 4cc9e054..5b165daa 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -1,22 +1,50 @@ module.exports = (function() { + var syntax; + var value; + function processStylesheet(node) { var spaces; var whitespaceNode; var i; for (i = node.length; i--;) { - whitespaceNode = node[i]; + whitespaceNode = node.get(i); - if (whitespaceNode[0] !== 's') continue; + if (!whitespaceNode.is('s')) continue; - spaces = whitespaceNode[1].replace(/\n[ \t]+/gm, '\n'); + spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); if (spaces === '') { - node.splice(i, 1); + node.content.splice(i, 1); } else { - whitespaceNode[1] = spaces; + whitespaceNode.content = spaces; + } + } + + function processBlock(x, level) { + level = level || 0; + + for (var i = 0; i < x.content.length; i++) { + var n = x.get(i); + if (!n) continue; + + + if (syntax === 'sass' && n.is('block')) { + processSassBlock(n, level, value); + } + + // Continue only with space nodes inside {...}: + if (syntax !== 'sass' && level !== 0 && n.is('s')) { + processSpaceNode(n, level, value); + } + + if (n.is('block') || n.is('atrulers')) level++; + + processBlock(n, level); } } + + processBlock(node); } function processSassBlock(node, level, value) { @@ -25,15 +53,15 @@ module.exports = (function() { var i; for (i = node.length; i--;) { - whitespaceNode = node[i]; + whitespaceNode = node.get(i); - if (whitespaceNode[0] !== 's') continue; + if (!whitespaceNode.is('s')) continue; - if (whitespaceNode[1] === '\n') continue; + if (whitespaceNode.content === '\n') continue; - spaces = whitespaceNode[1].replace(/[ \t]/gm, ''); + spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); spaces += new Array(level + 2).join(value); - whitespaceNode[1] = spaces; + whitespaceNode.content = spaces; } } @@ -41,12 +69,12 @@ module.exports = (function() { var spaces; // Remove all whitespaces and tabs, leave only new lines: - spaces = node[0].replace(/[ \t]/gm, ''); + spaces = node.content.replace(/[ \t]/gm, ''); if (!spaces) return; spaces += new Array(level + 1).join(value); - node[0] = spaces; + node.content = spaces; } return { @@ -64,26 +92,16 @@ module.exports = (function() { /** * Processes tree node. * - * @param {String} nodeType * @param {node} node - * @param {Number} level */ - process: function process(nodeType, node, level) { - var syntax = this.getSyntax(); - var value = this.getValue('block-indent'); + process: function process(node) { + if (!node.is('stylesheet')) return; - if (nodeType === 'stylesheet') { - return processStylesheet(node); - } + syntax = this.getSyntax(); + value = this.getValue('block-indent'); - if (syntax === 'sass' && nodeType === 'block') { - return processSassBlock(node, level, value); - } + processStylesheet(node); - // Continue only with space nodes inside {...}: - if (syntax !== 'sass' && level !== 0 && nodeType === 's') { - processSpaceNode(node, level, value); - } }, /** diff --git a/test/options/block-indent-sass/test.js b/test/options/block-indent-sass/test.js index b52444c3..182b5a99 100644 --- a/test/options/block-indent-sass/test.js +++ b/test/options/block-indent-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/block-indent (sass):', function() { +describe('options/block-indent (sass):', function() { it('First level ruleset\'s block', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('block.sass', 'block.expected.sass'); diff --git a/test/options/block-indent-scss/test.js b/test/options/block-indent-scss/test.js index 6acd4c1e..41c19afd 100644 --- a/test/options/block-indent-scss/test.js +++ b/test/options/block-indent-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/block-indent (scss):', function() { +describe('options/block-indent (scss):', function() { it('Issue 213', function() { this.comb.configure({ 'block-indent': 2 }); this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index 0f73ab36..62dd45f9 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -1,4 +1,4 @@ -describe.skip('options/block-indent:', function() { +describe('options/block-indent:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'block-indent': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -24,7 +24,7 @@ describe.skip('options/block-indent:', function() { this.shouldBeEqual('test.css', 'test-2.expected.css'); }); - it('Should detect nothing with an empty block, test 1', function() { + it.skip('Should detect nothing with an empty block, test 1', function() { this.shouldDetect( ['block-indent'], 'a{ }', @@ -32,7 +32,7 @@ describe.skip('options/block-indent:', function() { ); }); - it('Should detect nothing with an empty block, test 2', function() { + it.skip('Should detect nothing with an empty block, test 2', function() { this.shouldDetect( ['block-indent'], 'a{}', @@ -40,7 +40,7 @@ describe.skip('options/block-indent:', function() { ); }); - it('Should detect correct number of spaces', function() { + it.skip('Should detect correct number of spaces', function() { this.shouldDetect( ['block-indent'], 'a{\n top: 0;\n color: tomato;\n}', @@ -48,14 +48,14 @@ describe.skip('options/block-indent:', function() { ); }); - it('Should detect no indent for one-line code', function() { + it.skip('Should detect no indent for one-line code', function() { this.shouldDetect( ['block-indent'], 'a{ top: 0; color: tomato; }', {} ); }); - it('Valid string value => should set proper space after combnator', function() { + it.skip('Valid string value => should set proper space after combnator', function() { this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); this.shouldBeEqual('test.css', 'test-3.expected.css'); }); From 587a877319d26cd0f3859185afc0dace764f304f Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 1 Feb 2015 03:45:33 +0300 Subject: [PATCH 031/184] Tests: Uncomment sass tests --- test/options/sass/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/options/sass/test.js b/test/options/sass/test.js index 1ab534e1..cb934407 100644 --- a/test/options/sass/test.js +++ b/test/options/sass/test.js @@ -1,4 +1,4 @@ -describe.skip('Sass', function() { +describe('Sass', function() { beforeEach(function() { this.comb.configure({}); }); @@ -23,7 +23,7 @@ describe.skip('Sass', function() { this.shouldBeEqual('interpolated-variable-1.sass'); }); - it('Should parse interpolated variables inside values', function() { + it.skip('Should parse interpolated variables inside values', function() { this.shouldBeEqual('interpolated-variable-2.sass'); }); From 76732e4bbe2e3ee89e91a71e2b15f69efa5d416e Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 1 Feb 2015 15:19:01 +0300 Subject: [PATCH 032/184] Tests: Add `readFile` to public methods --- test/mocha.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mocha.js b/test/mocha.js index ee094005..47d2eae8 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -66,6 +66,7 @@ function shouldDetect(options, input, expected) { mocha.suite.beforeEach(function() { this.Comb = Comb; this.comb = new Comb(); + this.readFile = readFile; this.shouldBeEqual = shouldBeEqual; this.shouldDetect = shouldDetect; }); From a25249aeb06f03c86fc2da5ba3180bc655092a75 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 033/184] Gonzales 3.0: Update `sort-order` option --- lib/options/sort-order.js | 87 +++++++++++++----------- test/options/sort-order-fallback/test.js | 2 +- test/options/sort-order-less/test.js | 2 +- test/options/sort-order-sass/test.js | 2 +- test/options/sort-order-scss/test.js | 2 +- test/options/sort-order/test.js | 16 ++--- 6 files changed, 60 insertions(+), 51 deletions(-) diff --git a/lib/options/sort-order.js b/lib/options/sort-order.js index a3e817d3..391c6466 100644 --- a/lib/options/sort-order.js +++ b/lib/options/sort-order.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'sort-order', @@ -33,10 +35,9 @@ module.exports = { /** * Processes tree node. - * @param {String} nodeType * @param {node} node */ - process: function(nodeType, node) { + process: function(node) { var _this = this; // Types of nodes that can be sorted: var NODES = ['atruleb', 'atruler', 'atrules', 'commentML', 'commentSL', @@ -73,7 +74,7 @@ module.exports = { * @param {node} node Space node. */ var removeEmptyLines = function(node) { - node[1] = node[1].replace(/\n[\s\t\n\r]*\n/, '\n'); + node.content = node.content.replace(/\n[\s\t\n\r]*\n/, '\n'); }; /** @@ -88,7 +89,7 @@ module.exports = { var d = []; for (; i < l; i++) { - currentNode = node[i]; + currentNode = node.get(i); // If there is no node left, // stop and do nothing with previously found spaces/comments: if (!currentNode) { @@ -97,7 +98,7 @@ module.exports = { // If the node is declaration or @-rule, stop and return all // found nodes with spaces and comments (if there are any): - if (SC.indexOf(currentNode[0]) === -1) break; + if (SC.indexOf(currentNode.type) === -1) break; sc.push(currentNode); d.push(i); @@ -124,17 +125,17 @@ module.exports = { // Check every next node: for (; i < l; i++) { - currentNode = node[i + 1]; + currentNode = node.get(i + 1); // If there is no node, or it is nor spaces neither comment, stop: - if (!currentNode || SC.indexOf(currentNode[0]) === -1) break; + if (!currentNode || SC.indexOf(currentNode.type) === -1) break; - if (['commentML', 'commentSL'].indexOf(currentNode[0]) > -1) { + if (currentNode.is('commentML') || currentNode.is('commentSL')) { sc.push(currentNode); d.push(i + 1); continue; } - lbIndex = currentNode[1].indexOf('\n'); + lbIndex = currentNode.content.indexOf('\n'); // If there are any line breaks in a node with spaces, stop and // split the node into two: one with spaces before line break @@ -142,8 +143,10 @@ module.exports = { // Combine the first one with declaration/@-rule's node: if (lbIndex > -1) { // TODO: Don't push an empty array - sc.push(['s', currentNode[1].substring(0, lbIndex)]); - currentNode[1] = currentNode[1].substring(lbIndex); + var s = currentNode.content.substring(0, lbIndex); + var space = gonzales.createNode({ type: 's', content: s }); + sc.push(space); + currentNode.content = currentNode.content.substring(lbIndex); break; } @@ -162,8 +165,8 @@ module.exports = { * @returns {Object} Extended node */ var extendNode = function() { - currentNode = node[i]; - var nextNode = node[i + 1]; + currentNode = node.get(i); + var nextNode = node.get(i + 1); // Object containing current node, all corresponding spaces, // comments and other information: var extendedNode; @@ -195,13 +198,13 @@ module.exports = { extendedNode.sc1 = checkSC1(); if (extendedNode.sc1.length) { - currentNode = node[i]; - nextNode = node[i + 1]; + currentNode = node.get(i); + nextNode = node.get(i + 1); } // If there is `;` right after the declaration, save it with the // declaration and mark it for removing from parent node: - if (currentNode && nextNode && nextNode[0] === 'declDelim') { + if (currentNode && nextNode && nextNode.is('declDelim')) { extendedNode.delim.push(nextNode); deleted.push(i + 1); i++; @@ -229,8 +232,8 @@ module.exports = { var prefixesRegExp = /^(-webkit-|-moz-|-ms-|-o-)(.*)$/; // Get property name (i.e. `color`, `-o-animation`): - a = a.node[1][1][1]; - b = b.node[1][1][1]; + a = a.node.get(0).get(0).content; + b = b.node.get(0).get(0).content; // Get prefix and unprefixed part. For example: // ['-o-animation', '-o-', 'animation'] @@ -252,7 +255,7 @@ module.exports = { // TODO: Think it through! // Sort properties only inside blocks: - if (nodeType !== 'block') return; + if (!node.is('block')) return; // Check every child node. // If it is declaration (property-value pair, e.g. `color: tomato`), @@ -260,7 +263,7 @@ module.exports = { // combine it with spaces, semicolon and comments and move them from // current node to a separate list for further sorting: for (i = 0, l = node.length; i < l; i++) { - if (NODES.indexOf(node[i][0]) === -1) continue; + if (NODES.indexOf(node.get(i).type) === -1) continue; // Save preceding spaces and comments, if there are any, and mark // them for removing from parent node: @@ -268,7 +271,7 @@ module.exports = { if (!sc0) continue; // If spaces/comments are the last nodes, stop and go to sorting: - if (!node[i]) { + if (!node.get(i)) { deleted.splice(deleted.length - sc0.length, deleted.length + 1); break; } @@ -279,17 +282,19 @@ module.exports = { // If not, proceed with the next node: propertyName = null; // Look for includes: - if (node[i][0] === 'include') { + if (node.get(i).is('include')) { propertyName = '$include'; } else { - for (j = 1, nl = node[i].length; j < nl; j++) { - currentNode = node[i][j]; - if (currentNode[0] === 'property') { - propertyName = currentNode[1][0] === 'variable' ? - '$variable' : currentNode[1][1]; + for (j = 0, nl = node.get(i).length; j < nl; j++) { + currentNode = node.get(i).get(j); + if (!currentNode) continue; + + if (currentNode.is('property')) { + propertyName = currentNode.get(0).is('variable') ? + '$variable' : currentNode.get(0).content; break; - } else if (currentNode[0] === 'atkeyword' && - currentNode[1][1] === 'import') { // Look for imports + } else if (currentNode.is('atkeyword') && + currentNode.get(0).content === 'import') { // Look for imports propertyName = '$import'; break; } @@ -310,7 +315,7 @@ module.exports = { // Remove all nodes, that were moved to a `sorted` list, from parent node: for (i = deleted.length - 1; i > -1; i--) { - node.splice(deleted[i], 1); + node.content.splice(deleted[i], 1); } // Sort declarations saved for sorting: @@ -353,25 +358,29 @@ module.exports = { // Divide declarations from different groups with an empty line: if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { - if (sc0[0] && sc0[0][0] === 's' && + if (sc0[0] && sc0[0].is('s') && (this.syntax === 'sass' || - sc0[0][1].match(/\n/g) && - sc0[0][1].match(/\n/g).length < 2)) { - sc0[0][1] = '\n' + sc0[0][1]; + sc0[0].content.match(/\n/g) && + sc0[0].content.match(/\n/g).length < 2)) { + sc0[0].content = '\n' + sc0[0].content; } } for (j = 0, nl = sc2.length; j < nl; j++) { - node.unshift(sc2[j]); + node.content.unshift(sc2[j]); + } + if (currentNode.delim.length > 0) { + var delim = this.syntax === 'sass' ? '\n' : ';'; + var declDelim = gonzales.createNode({ type: 'declDelim', content: delim }); + node.content.unshift(declDelim); } - if (currentNode.delim.length > 0) node.unshift(['declDelim']); for (j = 0, nl = sc1.length; j < nl; j++) { - node.unshift(sc1[j]); + node.content.unshift(sc1[j]); } - node.unshift(currentNode.node); + node.content.unshift(currentNode.node); for (j = 0, nl = sc0.length; j < nl; j++) { - node.unshift(sc0[j]); + node.content.unshift(sc0[j]); } } } diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index d67b08d6..1262c177 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order-fallback', function() { +describe('options/sort-order-fallback', function() { it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { 'sort-order-fallback': 'abc', diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index f00bca0c..69208169 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (less)', function() { +describe('options/sort-order (less)', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 85a58862..6348c10d 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (sass)', function() { +describe('options/sort-order (sass)', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 79395764..72911ab8 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (scss)', function() { +describe('options/sort-order (scss)', function() { it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index 45371d80..29debdef 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/sort-order', function() { +describe('options/sort-order', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); this.shouldBeEqual('single-group.css', 'single-group.expected.css'); @@ -61,31 +61,31 @@ describe.skip('options/sort-order', function() { assert.equal(input, expected); }); - it('Issue 94. Test 1', function() { + it.skip('Issue 94. Test 1', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); }); - it('Issue 94. Test 2', function() { + it.skip('Issue 94. Test 2', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); }); - it('Issue 94. Test 3', function() { + it.skip('Issue 94. Test 3', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); }); - it('Should place the leftovers in the end', function() { + it.skip('Should place the leftovers in the end', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); }); - it('Should place the leftovers in the beginning', function() { + it.skip('Should place the leftovers in the beginning', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][0].unshift(['...']); this.comb.configure(config); @@ -93,7 +93,7 @@ describe.skip('options/sort-order', function() { config['sort-order'][0].shift(); }); - it('Should place the leftovers in the beginning of its group', function() { + it.skip('Should place the leftovers in the beginning of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].unshift('...'); this.comb.configure(config); @@ -101,7 +101,7 @@ describe.skip('options/sort-order', function() { config['sort-order'][1].shift(); }); - it('Should place the leftovers in the middle of its group', function() { + it.skip('Should place the leftovers in the middle of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].splice(1, 0, '...'); this.comb.configure(config); From 2ece912faa5a383bd836f34c0a686d8288d78f0d Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 31 Jan 2015 21:26:56 +0300 Subject: [PATCH 034/184] Gonzales 3.0: Update `space-before-closing-brace` --- lib/options/space-before-closing-brace.js | 65 ++++++++++++------- .../space-before-closing-brace/test.js | 12 ++-- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index 321a2dc6..9952365e 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -1,9 +1,13 @@ +var gonzales = require('gonzales-pe'); + module.exports = (function() { function getLastWhitespaceNode(node) { - var lastNode = node[node.length - 1]; + var lastNode = node.last(); + + if (!lastNode || !lastNode.content) return null; - if (typeof lastNode !== 'object' || lastNode[0] === 'block') return null; - if (lastNode[0] === 's') return lastNode; + if (lastNode.is('block')) return null; + if (lastNode.is('s')) return lastNode; return getLastWhitespaceNode(lastNode); } @@ -22,33 +26,50 @@ module.exports = (function() { /** * Processes tree node. - * @param {String} nodeType * @param {node} node - * @param {Number} level */ - process: function(nodeType, node, level) { - if (nodeType !== 'block' && nodeType !== 'atrulers') return; - + process: function(node) { var value = this.getValue('space-before-closing-brace'); + var blockIndent = this.getValue('block-indent'); - // If found block node stop at the next one for space check - // For the pre-block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node); + if (!node.is('stylesheet')) return; - if (value.indexOf('\n') > -1) { - var blockIndent = this.getValue('block-indent'); - // TODO: Check that it works for '' block indent value - if (blockIndent) value += new Array(level + 1).join(blockIndent); - } + function processBlock(x, level) { + level = level || 0; + + for (var i = 0; i < x.content.length; i++) { + node = x.get(i); + if (!node) continue; - // If it's spaces, modify this node - // If it's something different from spaces, add a space node to the end + if (node.is('block') || node.is('atrulers')) { + // If found block node stop at the next one for space check + // For the pre-block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); - if (whitespaceNode) { - whitespaceNode[1] = value; - } else if (value !== '') { - node.push(['s', value]); + if (value.indexOf('\n') > -1) { + // TODO: Check that it works for '' block indent value + if (blockIndent) value += new Array(level + 1).join(blockIndent); + } + + // If it's spaces, modify this node + // If it's something different from spaces, add a space node to the end + + if (whitespaceNode) { + whitespaceNode.content = value; + } else if (value !== '') { + var space = gonzales.createNode({ type: 's', content: value }); + if (Array.isArray(node.content)) + node.content.push(space); + } + + level++; + } + + processBlock(node, level); + } } + + processBlock(node); }, /** diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/test.js index 1642c193..75f72c47 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/test.js @@ -1,4 +1,4 @@ -describe.skip('options/space-before-closing-brace:', function() { +describe('options/space-before-closing-brace:', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); this.shouldBeEqual('test.css'); @@ -29,7 +29,7 @@ describe.skip('options/space-before-closing-brace:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Should detect no whitespace', function() { + it.skip('Should detect no whitespace', function() { this.shouldDetect( ['space-before-closing-brace'], 'a{top:0}', @@ -37,7 +37,7 @@ describe.skip('options/space-before-closing-brace:', function() { ); }); - it('Should detect no whitespace (2 blocks)', function() { + it.skip('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-closing-brace'], 'a{top:0} b { color: tomato; }', @@ -45,7 +45,7 @@ describe.skip('options/space-before-closing-brace:', function() { ); }); - it('Should detect whitespace', function() { + it.skip('Should detect whitespace', function() { this.shouldDetect( ['space-before-closing-brace'], 'a { top:0 }', @@ -53,7 +53,7 @@ describe.skip('options/space-before-closing-brace:', function() { ); }); - it('Should detect whitespace (2 blocks)', function() { + it.skip('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-closing-brace'], 'a { top:0 } b{color:tomato;}', @@ -61,7 +61,7 @@ describe.skip('options/space-before-closing-brace:', function() { ); }); - it('Should detect whitespace (mix with block indent)', function() { + it.skip('Should detect whitespace (mix with block indent)', function() { this.shouldDetect( ['space-before-closing-brace', 'block-indent'], 'a {\n top:0\n }\nb{\n color:tomato;\n }', From 5efd46b9e78260394787e3fc22e13a9f82bcb722 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 1 Feb 2015 16:33:44 +0300 Subject: [PATCH 035/184] Tests: Unskip green tests --- test/options/sort-order/test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index 29debdef..f313817a 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -61,31 +61,31 @@ describe('options/sort-order', function() { assert.equal(input, expected); }); - it.skip('Issue 94. Test 1', function() { + it('Issue 94. Test 1', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); }); - it.skip('Issue 94. Test 2', function() { + it('Issue 94. Test 2', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); }); - it.skip('Issue 94. Test 3', function() { + it('Issue 94. Test 3', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); }); - it.skip('Should place the leftovers in the end', function() { + it('Should place the leftovers in the end', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); }); - it.skip('Should place the leftovers in the beginning', function() { + it('Should place the leftovers in the beginning', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][0].unshift(['...']); this.comb.configure(config); @@ -93,7 +93,7 @@ describe('options/sort-order', function() { config['sort-order'][0].shift(); }); - it.skip('Should place the leftovers in the beginning of its group', function() { + it('Should place the leftovers in the beginning of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].unshift('...'); this.comb.configure(config); @@ -101,7 +101,7 @@ describe('options/sort-order', function() { config['sort-order'][1].shift(); }); - it.skip('Should place the leftovers in the middle of its group', function() { + it('Should place the leftovers in the middle of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].splice(1, 0, '...'); this.comb.configure(config); From 93b2e7f904dacda58da7c7f633adf830377648de Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 1 Feb 2015 23:32:39 +0300 Subject: [PATCH 036/184] Update dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4a9f7b3..78c45805 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "dependencies": { "commander": "2.0.0", - "csscomb-core": "~2.0.0", + "csscomb-core": "~3.0.0-1", "gonzales-pe": "~3.0.0-10", "vow": "0.4.4" }, From 6960b032829730204d18167e6bc64004f8b65859 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 2 Feb 2015 11:34:50 +0300 Subject: [PATCH 037/184] Update names of node types --- lib/options/always-semicolon.js | 6 +++--- lib/options/block-indent.js | 6 +++--- lib/options/color-case.js | 2 +- lib/options/color-shorthand.js | 2 +- lib/options/element-case.js | 2 +- lib/options/eof-newline.js | 4 ++-- lib/options/remove-empty-rulesets.js | 4 ++-- lib/options/sort-order.js | 14 +++++++------- lib/options/space-after-colon.js | 6 +++--- lib/options/space-after-combinator.js | 4 ++-- lib/options/space-after-opening-brace.js | 6 +++--- lib/options/space-after-selector-delimiter.js | 8 ++++---- lib/options/space-before-closing-brace.js | 4 ++-- lib/options/space-before-colon.js | 6 +++--- lib/options/space-before-combinator.js | 4 ++-- lib/options/space-before-opening-brace.js | 6 +++--- lib/options/space-before-selector-delimiter.js | 6 +++--- lib/options/space-between-declarations.js | 16 ++++++++-------- lib/options/strip-spaces.js | 4 ++-- lib/options/tab-size.js | 2 +- lib/options/vendor-prefix-align.js | 16 ++++++++-------- 21 files changed, 64 insertions(+), 64 deletions(-) diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js index 2cd55ad7..02eb83f2 100644 --- a/lib/options/always-semicolon.js +++ b/lib/options/always-semicolon.js @@ -21,7 +21,7 @@ module.exports = { var nodeWithoutSemicolon; // Skip nodes that already have `;` at the end: - if (currentNodeType === 'declDelim') break; + if (currentNodeType === 'declarationDelimiter') break; // Add semicolon only after declarations and includes. // If current node is include, insert semicolon right into it. @@ -50,7 +50,7 @@ module.exports = { if (lastNode === 'block') { isBlock = true; break; - } else if (['s', 'commentML', 'commentSL'].indexOf(lastNode) === -1) break; + } else if (['space', 'multilineComment', 'singlelineComment'].indexOf(lastNode) === -1) break; space.unshift(nodeWithoutSemicolon.content[j]); } @@ -60,7 +60,7 @@ module.exports = { // Temporarily remove last spaces and comments and insert `;` // before them: nodeWithoutSemicolon.content.splice(nodeWithoutSemicolon.content.length - space.length); - var declDelim = gonzales.createNode({ type: 'declDelim', content: ';' }); + var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: ';' }); var args = [i + 1, 0, declDelim].concat(space); node.splice.apply(node, args); break; diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index 5b165daa..4d820f92 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -10,7 +10,7 @@ module.exports = (function() { for (i = node.length; i--;) { whitespaceNode = node.get(i); - if (!whitespaceNode.is('s')) continue; + if (!whitespaceNode.is('space')) continue; spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); @@ -34,7 +34,7 @@ module.exports = (function() { } // Continue only with space nodes inside {...}: - if (syntax !== 'sass' && level !== 0 && n.is('s')) { + if (syntax !== 'sass' && level !== 0 && n.is('space')) { processSpaceNode(n, level, value); } @@ -55,7 +55,7 @@ module.exports = (function() { for (i = node.length; i--;) { whitespaceNode = node.get(i); - if (!whitespaceNode.is('s')) continue; + if (!whitespaceNode.is('space')) continue; if (whitespaceNode.content === '\n') continue; diff --git a/lib/options/color-case.js b/lib/options/color-case.js index 1fa2cb92..2d09c3b6 100644 --- a/lib/options/color-case.js +++ b/lib/options/color-case.js @@ -11,7 +11,7 @@ module.exports = { */ process: function(node) { var value = this.getValue('color-case'); - if (node.type === 'vhash') { + if (node.type === 'color') { if (value === 'lower') { node.content = node.content.toLowerCase(); } else if (value === 'upper') { diff --git a/lib/options/color-shorthand.js b/lib/options/color-shorthand.js index 9d8848e7..1c19dce8 100644 --- a/lib/options/color-shorthand.js +++ b/lib/options/color-shorthand.js @@ -10,7 +10,7 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type === 'vhash') { + if (node.type === 'color') { if (this.getValue('color-shorthand')) { node.content = node.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3'); } else { diff --git a/lib/options/element-case.js b/lib/options/element-case.js index 51962528..774d0f0a 100644 --- a/lib/options/element-case.js +++ b/lib/options/element-case.js @@ -15,7 +15,7 @@ module.exports = { for (var x = node.content.length; x--;) { var selector = node.content[x]; - if (selector.type !== 'simpleselector') continue; + if (selector.type !== 'simpleSelector') continue; for (var i = selector.content.length; i--;) { var simpleselector = selector.content[i]; diff --git a/lib/options/eof-newline.js b/lib/options/eof-newline.js index 8b65c5fb..feca6678 100644 --- a/lib/options/eof-newline.js +++ b/lib/options/eof-newline.js @@ -12,8 +12,8 @@ module.exports = { process: function(node) { if (node.type === 'stylesheet') { var lastChild = node.content[node.content.length - 1]; - if (lastChild.type !== 's') { - lastChild = { type: 's', content: '' }; + if (lastChild.type !== 'space') { + lastChild = { type: 'space', content: '' }; node.content.push(lastChild); } lastChild.content = lastChild.content.replace(/\n$/, ''); diff --git a/lib/options/remove-empty-rulesets.js b/lib/options/remove-empty-rulesets.js index 3999def0..05b21846 100644 --- a/lib/options/remove-empty-rulesets.js +++ b/lib/options/remove-empty-rulesets.js @@ -57,7 +57,7 @@ module.exports = (function() { var isEmpty = true; node.forEach(function(childNode) { - if (childNode.type !== 's') isEmpty = false; + if (childNode.type !== 'space') isEmpty = false; }); return isEmpty; } @@ -67,7 +67,7 @@ module.exports = (function() { } function isWhitespace(node) { - return node.type === 's'; + return node.type === 'space'; } diff --git a/lib/options/sort-order.js b/lib/options/sort-order.js index 391c6466..03adb288 100644 --- a/lib/options/sort-order.js +++ b/lib/options/sort-order.js @@ -40,10 +40,10 @@ module.exports = { process: function(node) { var _this = this; // Types of nodes that can be sorted: - var NODES = ['atruleb', 'atruler', 'atrules', 'commentML', 'commentSL', - 'declaration', 's', 'include']; + var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', 'singlelineComment', + 'declaration', 'space', 'include']; // Spaces and comments: - var SC = ['commentML', 'commentSL', 's']; + var SC = ['multilineComment', 'singlelineComment', 'space']; var currentNode; // Sort order of properties: @@ -129,7 +129,7 @@ module.exports = { // If there is no node, or it is nor spaces neither comment, stop: if (!currentNode || SC.indexOf(currentNode.type) === -1) break; - if (currentNode.is('commentML') || currentNode.is('commentSL')) { + if (currentNode.is('multilineComment') || currentNode.is('singlelineComment')) { sc.push(currentNode); d.push(i + 1); continue; @@ -204,7 +204,7 @@ module.exports = { // If there is `;` right after the declaration, save it with the // declaration and mark it for removing from parent node: - if (currentNode && nextNode && nextNode.is('declDelim')) { + if (currentNode && nextNode && nextNode.is('declarationDelimiter')) { extendedNode.delim.push(nextNode); deleted.push(i + 1); i++; @@ -358,7 +358,7 @@ module.exports = { // Divide declarations from different groups with an empty line: if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { - if (sc0[0] && sc0[0].is('s') && + if (sc0[0] && sc0[0].is('space') && (this.syntax === 'sass' || sc0[0].content.match(/\n/g) && sc0[0].content.match(/\n/g).length < 2)) { @@ -371,7 +371,7 @@ module.exports = { } if (currentNode.delim.length > 0) { var delim = this.syntax === 'sass' ? '\n' : ';'; - var declDelim = gonzales.createNode({ type: 'declDelim', content: delim }); + var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: delim }); node.content.unshift(declDelim); } for (j = 0, nl = sc1.length; j < nl; j++) { diff --git a/lib/options/space-after-colon.js b/lib/options/space-after-colon.js index b6506dc3..eca88b9a 100644 --- a/lib/options/space-after-colon.js +++ b/lib/options/space-after-colon.js @@ -23,14 +23,14 @@ module.exports = { var value = this.getValue('space-after-colon'); for (var i = node.content.length; i--;) { - if (!node.content[i].is('propertyDelim')) continue; + if (!node.content[i].is('propertyDelimiter')) continue; if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; // Remove any spaces after colon: - if (node.content[i + 1].is('s')) node.content.splice(i + 1, 1); + if (node.content[i + 1].is('space')) node.content.splice(i + 1, 1); // If the value set in config is not empty, add spaces: - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); if (value !== '') node.content.splice(i + 1, 0, space); break; diff --git a/lib/options/space-after-combinator.js b/lib/options/space-after-combinator.js index acc4a54e..7c4db7c6 100644 --- a/lib/options/space-after-combinator.js +++ b/lib/options/space-after-combinator.js @@ -27,10 +27,10 @@ module.exports = { for (var j = subSelector.content.length; j--;) { if (!subSelector.content[j].is('combinator')) continue; - if (subSelector.content[j + 1].is('s')) { + if (subSelector.content[j + 1].is('space')) { subSelector.content[j + 1].content = value; } else { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); subSelector.content.splice(j + 1, 0, space); } } diff --git a/lib/options/space-after-opening-brace.js b/lib/options/space-after-opening-brace.js index fae3d7b7..0dd5c601 100644 --- a/lib/options/space-after-opening-brace.js +++ b/lib/options/space-after-opening-brace.js @@ -23,10 +23,10 @@ module.exports = { var value = this.getValue('space-after-opening-brace'); - if (node.content[0].is('s')) { + if (node.content[0].is('space')) { node.content[0].content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); node.content.unshift(space); } }, @@ -40,7 +40,7 @@ module.exports = { detect: function(nodeType, node) { if (nodeType !== 'block' && nodeType !== 'atrulers') return; - if (node[0][0] === 's') { + if (node[0][0] === 'space') { return node[0][1]; } else { return ''; diff --git a/lib/options/space-after-selector-delimiter.js b/lib/options/space-after-selector-delimiter.js index 0240210b..3d72e391 100644 --- a/lib/options/space-after-selector-delimiter.js +++ b/lib/options/space-after-selector-delimiter.js @@ -23,14 +23,14 @@ module.exports = { var value = this.getValue('space-after-selector-delimiter'); for (var i = node.content.length; i--;) { - if (!node.content[i].is('delim')) continue; + if (!node.content[i].is('delimiter')) continue; - if (node.content[i + 1].is('s')) { + if (node.content[i + 1].is('space')) { node.content[i + 1].content = value; - } else if (node.content[i + 1].content[0].is('s')) { + } else if (node.content[i + 1].content[0].is('space')) { node.content[i + 1].content[0].content = value; } else { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); node.content[i + 1].content.unshift(space); } } diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index 9952365e..fb2fb7d6 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -7,7 +7,7 @@ module.exports = (function() { if (!lastNode || !lastNode.content) return null; if (lastNode.is('block')) return null; - if (lastNode.is('s')) return lastNode; + if (lastNode.is('space')) return lastNode; return getLastWhitespaceNode(lastNode); } @@ -57,7 +57,7 @@ module.exports = (function() { if (whitespaceNode) { whitespaceNode.content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); if (Array.isArray(node.content)) node.content.push(space); } diff --git a/lib/options/space-before-colon.js b/lib/options/space-before-colon.js index 40ffc47c..c0648a25 100644 --- a/lib/options/space-before-colon.js +++ b/lib/options/space-before-colon.js @@ -23,17 +23,17 @@ module.exports = { var value = this.getValue('space-before-colon'); for (var i = node.content.length; i--;) { - if (!node.content[i].is('propertyDelim')) continue; + if (!node.content[i].is('propertyDelimiter')) continue; if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; // Remove any spaces before colon: - if (node.content[i - 1].is('s')) { + if (node.content[i - 1].is('space')) { node.content.splice(i - 1, 1); i--; } // If the value set in config is not empty, add spaces: - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); if (value !== '') node.content.splice(i, 0, space); break; diff --git a/lib/options/space-before-combinator.js b/lib/options/space-before-combinator.js index 0eceeb8e..7628134c 100644 --- a/lib/options/space-before-combinator.js +++ b/lib/options/space-before-combinator.js @@ -26,10 +26,10 @@ module.exports = { var subSelector = node.get(i); for (var j = subSelector.length; j--;) { if (!subSelector.get(j).is('combinator')) continue; - if (subSelector.get(j - 1).is('s')) { + if (subSelector.get(j - 1).is('space')) { subSelector.get(j - 1).content = value; } else { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); subSelector.insert(j, space); } } diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index c79c8d18..edbe291c 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -10,7 +10,7 @@ module.exports = (function() { */ function getLastWhitespaceNode(node) { if (typeof node !== 'object') return; - if (node.is('s')) return node; + if (node.is('space')) return node; return getLastWhitespaceNode(node.last()); } @@ -40,7 +40,7 @@ module.exports = (function() { if (!node.get(i) || typeof node.get(i) === 'string') continue; try { - node.get(i).is('s'); + node.get(i).is('space'); } catch (e) { console.log(node); } @@ -57,7 +57,7 @@ module.exports = (function() { if (whitespaceNode) { whitespaceNode.content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); if (node.get(i - 1).is('atrulerq')) { node.get(i - 1).content.push(space); } else { diff --git a/lib/options/space-before-selector-delimiter.js b/lib/options/space-before-selector-delimiter.js index b7366f86..f0db13a2 100644 --- a/lib/options/space-before-selector-delimiter.js +++ b/lib/options/space-before-selector-delimiter.js @@ -22,12 +22,12 @@ module.exports = { var value = this.getValue('space-before-selector-delimiter'); - node.forEach('delim', function(delim, i) { + node.forEach('delimiter', function(delim, i) { var previousNode = node.get(i - 1); - if (previousNode.last().is('s')) { + if (previousNode.last().is('space')) { previousNode.last().content = value; } else { - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); previousNode.content.push(space); } }); diff --git a/lib/options/space-between-declarations.js b/lib/options/space-between-declarations.js index f7debf52..c85ee6a4 100644 --- a/lib/options/space-between-declarations.js +++ b/lib/options/space-between-declarations.js @@ -5,17 +5,17 @@ module.exports = (function() { for (;i < node.length; i++) { if (!node.get(i + 1) || typeof node.get(i + 1) === 'string') { return 0; - } else if (node.get(i + 1).is('s')) { + } else if (node.get(i + 1).is('space')) { if (node.get(i + 1).content.indexOf('\n') > -1) { if (node.get(i + 2) && node.get(i + 2).is('declaration')) { return i; } else { return 0; } - } else if (node.get(i + 2) && node.get(i + 2).is('commentML')) { + } else if (node.get(i + 2) && node.get(i + 2).is('multilineComment')) { if (node.get(i + 3) && node.get(i + 3).is('declaration')) { return i + 2; - } else if (node.get(i + 3) && node.get(i + 3).is('s')) { + } else if (node.get(i + 3) && node.get(i + 3).is('space')) { if (node.get(i + 4) && node.get(i + 4).is('declaration')) { return i + 2; } else { @@ -29,10 +29,10 @@ module.exports = (function() { } } else if (node.get(i + 1).is('declaration')) { return i; - } else if (node.get(i + 1).is('commentML')) { + } else if (node.get(i + 1).is('multilineComment')) { if (node.get(i + 2) && node.get(i + 2).is('declaration')) { return i + 1; - } else if (node.get(i + 2) && node.get(i + 2).is('s')) { + } else if (node.get(i + 2) && node.get(i + 2).is('space')) { if (node.get(i + 3) && node.get(i + 3).is('declaration')) { return i + 1; } @@ -68,7 +68,7 @@ module.exports = (function() { // TODO: Limit nodes to blocks, stylesheet, etc. for (var i = 0, l = node.length; i < l; i++) { - if (!node.get(i) || !node.get(i).is('declDelim')) continue; + if (!node.get(i) || !node.get(i).is('declarationDelimiter')) continue; // Grom user's point of view "declaration" includes semicolons // and comments placed on the same line. @@ -81,12 +81,12 @@ module.exports = (function() { } var nextNode = node.get(i + 1); - if (nextNode.is('s')) { + if (nextNode.is('space')) { nextNode.content = value; } else { i++; l++; - var space = gonzales.createNode({ type: 's', content: value }); + var space = gonzales.createNode({ type: 'space', content: value }); node.insert(i, space); } } diff --git a/lib/options/strip-spaces.js b/lib/options/strip-spaces.js index 6ad80126..b672ec58 100644 --- a/lib/options/strip-spaces.js +++ b/lib/options/strip-spaces.js @@ -21,13 +21,13 @@ module.exports = (function() { * @param {node} node */ process: function(node) { - if (node.is('s')) { + if (node.is('space')) { node.content = trim(node.content); } if (node.is('stylesheet')) { var lastChild = node.last(); - if (lastChild.is('s')) { + if (lastChild.is('space')) { lastChild.content = trim(lastChild.content) .replace(/[ \t]+$/, '') .replace(/[\n]+/g, '\n'); diff --git a/lib/options/tab-size.js b/lib/options/tab-size.js index 191d1cc6..1ab29359 100644 --- a/lib/options/tab-size.js +++ b/lib/options/tab-size.js @@ -13,7 +13,7 @@ module.exports = { * @param {node} node */ process: function(node) { - if (!node.is('s')) return; + if (!node.is('space')) return; node.content = node.content.replace(/\t/, this.getValue('tab-size')); } }; diff --git a/lib/options/vendor-prefix-align.js b/lib/options/vendor-prefix-align.js index 832c4fbb..2cde89b3 100644 --- a/lib/options/vendor-prefix-align.js +++ b/lib/options/vendor-prefix-align.js @@ -86,12 +86,12 @@ module.exports = (function() { if (crPos !== -1) oneline = false; - if (node.is('s')) { + if (node.is('space')) { result += node.content.length - crPos - 1; if (crPos !== -1) break; } - if (node.is('commentML')) { + if (node.is('multilineComment')) { if (crPos === -1) { result += node.content.length + 4 /* comment symbols length */ ; } else { @@ -113,7 +113,7 @@ module.exports = (function() { function extraIndentProperty(nodes, i) { var subset = []; while (i--) { - if (!nodes.get(i) || nodes.get(i).is('declDelim')) + if (!nodes.get(i) || nodes.get(i).is('declarationDelimiter')) break; subset.unshift(nodes.get(i)); } @@ -136,7 +136,7 @@ module.exports = (function() { x--; - while (!declaration.get(x).is('propertyDelim')) { + while (!declaration.get(x).is('propertyDelimiter')) { subset.push(declaration.get(x)); x--; } @@ -301,8 +301,8 @@ module.exports = (function() { if (node.get(i).get(x).is('value')) break; } - if (!node.get(i).get(x - 1).is('s')) { - var space = gonzales.createNode({ type: 's', content: '' }); + if (!node.get(i).get(x - 1).is('space')) { + var space = gonzales.createNode({ type: 'space', content: '' }); node.get(i).insert(x, space); ++x; } @@ -322,8 +322,8 @@ module.exports = (function() { var whitespaceNode = node.get(i - 1); if (!whitespaceNode) return; // If it's a comment, insert an empty space node: - if (!whitespaceNode.is('s')) { - whitespaceNode = gonzales.createNode({ type: 's', content: '' }); + if (!whitespaceNode.is('space')) { + whitespaceNode = gonzales.createNode({ type: 'space', content: '' }); node.insert(i - 1, whitespaceNode); } whitespaceNode.content = updateIndent(info, dict, whitespaceNode.content); From 6af71bed4d67eae3cd043ea70c3634bd5c41a63d Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 2 Feb 2015 13:49:34 +0300 Subject: [PATCH 038/184] Update options --- lib/options/always-semicolon.js | 51 +++++-------- lib/options/block-indent.js | 69 ++++++++--------- lib/options/color-case.js | 13 ++-- lib/options/color-shorthand.js | 12 ++- lib/options/element-case.js | 29 +++----- lib/options/eof-newline.js | 18 +++-- lib/options/leading-zero.js | 14 ++-- lib/options/quotes.js | 25 ++++--- lib/options/remove-empty-rulesets.js | 68 +++++------------ lib/options/space-after-colon.js | 10 +-- lib/options/space-after-combinator.js | 17 ++--- lib/options/space-after-opening-brace.js | 6 +- lib/options/space-after-selector-delimiter.js | 16 ++-- lib/options/space-before-closing-brace.js | 74 +++++++++---------- lib/options/space-before-colon.js | 19 ++--- lib/options/space-before-combinator.js | 16 ++-- lib/options/space-before-opening-brace.js | 22 +++--- lib/options/strip-spaces.js | 10 +-- lib/options/unitless-zero.js | 33 +++++---- 19 files changed, 228 insertions(+), 294 deletions(-) diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js index 02eb83f2..8cdd56af 100644 --- a/lib/options/always-semicolon.js +++ b/lib/options/always-semicolon.js @@ -12,57 +12,46 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type !== 'block') return; + var nodeWithoutSemicolon; - node = node.content; + if (!node.is('block')) return; + + mainLoop: for (var i = node.length; i--;) { - var currentNode = node[i]; - var currentNodeType = currentNode.type; - var nodeWithoutSemicolon; + var currentNode = node.get(i); // Skip nodes that already have `;` at the end: - if (currentNodeType === 'declarationDelimiter') break; + if (currentNode.is('declarationDelimiter')) break; // Add semicolon only after declarations and includes. // If current node is include, insert semicolon right into it. // If it's declaration, look for value node: - if (currentNodeType === 'include') { + if (currentNode.is('include')) { nodeWithoutSemicolon = currentNode; - } else if (currentNodeType === 'declaration') { - for (var k = currentNode.content.length; k--;) { - if (currentNode.content[k].type === 'value') { - nodeWithoutSemicolon = currentNode.content[k]; - break; - } - } + } else if (currentNode.is('declaration')) { + nodeWithoutSemicolon = currentNode.last('value'); } else { continue; } - var space = []; - var isBlock = false; - // Check if there are spaces and comments at the end of the node: - for (var j = nodeWithoutSemicolon.content.length; j--;) { - var lastNode = nodeWithoutSemicolon.content[j].type; + for (var j = nodeWithoutSemicolon.length; j--; ) { + var lastNode = nodeWithoutSemicolon.get(j); + // If the node's last child is block, do not add semicolon: // TODO: Add syntax check and run the code only for scss - if (lastNode === 'block') { - isBlock = true; + if (lastNode.is('block')) { + break mainLoop; + } else if (!lastNode.is('space') && + !lastNode.is('multilineComment') && + !lastNode.is('singlelineComment')) { + j++; break; - } else if (['space', 'multilineComment', 'singlelineComment'].indexOf(lastNode) === -1) break; - - space.unshift(nodeWithoutSemicolon.content[j]); + } } - if (isBlock) break; - - // Temporarily remove last spaces and comments and insert `;` - // before them: - nodeWithoutSemicolon.content.splice(nodeWithoutSemicolon.content.length - space.length); var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: ';' }); - var args = [i + 1, 0, declDelim].concat(space); - node.splice.apply(node, args); + nodeWithoutSemicolon.insert(j, declDelim); break; } }, diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index 4d820f92..d39106c7 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -2,49 +2,26 @@ module.exports = (function() { var syntax; var value; - function processStylesheet(node) { - var spaces; - var whitespaceNode; - var i; + function processNode(node, level) { + level = level || 0; - for (i = node.length; i--;) { - whitespaceNode = node.get(i); - - if (!whitespaceNode.is('space')) continue; + for (var i = 0; i < node.length; i++) { + var n = node.get(i); + if (!n) continue; - spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); - - if (spaces === '') { - node.content.splice(i, 1); - } else { - whitespaceNode.content = spaces; + if (syntax === 'sass' && n.is('block')) { + processSassBlock(n, level, value); } - } - - function processBlock(x, level) { - level = level || 0; - for (var i = 0; i < x.content.length; i++) { - var n = x.get(i); - if (!n) continue; - - - if (syntax === 'sass' && n.is('block')) { - processSassBlock(n, level, value); - } - - // Continue only with space nodes inside {...}: - if (syntax !== 'sass' && level !== 0 && n.is('space')) { - processSpaceNode(n, level, value); - } + // Continue only with space nodes inside {...}: + if (syntax !== 'sass' && level !== 0 && n.is('space')) { + processSpaceNode(n, level, value); + } - if (n.is('block') || n.is('atrulers')) level++; + if (n.is('block') || n.is('atrulers')) level++; - processBlock(n, level); - } + processNode(n, level); } - - processBlock(node); } function processSassBlock(node, level, value) { @@ -95,13 +72,31 @@ module.exports = (function() { * @param {node} node */ process: function process(node) { + var spaces; + var whitespaceNode; + var i; + if (!node.is('stylesheet')) return; syntax = this.getSyntax(); value = this.getValue('block-indent'); - processStylesheet(node); + for (i = node.length; i--;) { + whitespaceNode = node.get(i); + + if (!whitespaceNode.is('space')) continue; + + spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); + + if (spaces === '') { + node.remove(i); + } else { + whitespaceNode.content = spaces; + } + } + + processNode(node); }, /** diff --git a/lib/options/color-case.js b/lib/options/color-case.js index 2d09c3b6..25bf08da 100644 --- a/lib/options/color-case.js +++ b/lib/options/color-case.js @@ -10,14 +10,11 @@ module.exports = { * @param {node} node */ process: function(node) { - var value = this.getValue('color-case'); - if (node.type === 'color') { - if (value === 'lower') { - node.content = node.content.toLowerCase(); - } else if (value === 'upper') { - node.content = node.content.toUpperCase(); - } - } + if (!node.is('color')) return; + + node.content = this.getValue('color-case') === 'lower' ? + node.content.toLowerCase() : + node.content.toUpperCase(); }, /** diff --git a/lib/options/color-shorthand.js b/lib/options/color-shorthand.js index 1c19dce8..9cd4b8df 100644 --- a/lib/options/color-shorthand.js +++ b/lib/options/color-shorthand.js @@ -10,13 +10,11 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type === 'color') { - if (this.getValue('color-shorthand')) { - node.content = node.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3'); - } else { - node.content = node.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); - } - } + if (!node.is('color')) return; + + node.content = this.getValue('color-shorthand') ? + node.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : + node.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); }, /** diff --git a/lib/options/element-case.js b/lib/options/element-case.js index 774d0f0a..76fe79e4 100644 --- a/lib/options/element-case.js +++ b/lib/options/element-case.js @@ -10,23 +10,18 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type !== 'selector' && - node.type !== 'arguments') return; - - for (var x = node.content.length; x--;) { - var selector = node.content[x]; - if (selector.type !== 'simpleSelector') continue; - - for (var i = selector.content.length; i--;) { - var simpleselector = selector.content[i]; - if (!simpleselector || - simpleselector.type !== 'ident') continue; - - simpleselector.content = this.getValue('element-case') === 'lower' ? - simpleselector.content.toLowerCase() : - simpleselector.content.toUpperCase(); - } - } + if (!node.is('selector') && + !node.is('arguments')) return; + + var value = this.getValue('element-case'); + + node.forEach('simpleSelector', function(selector) { + selector.forEach('ident', function(ident) { + ident.content = value === 'lower' ? + ident.content.toLowerCase() : + ident.content.toUpperCase(); + }); + }); }, /** diff --git a/lib/options/eof-newline.js b/lib/options/eof-newline.js index feca6678..eb0e1fb5 100644 --- a/lib/options/eof-newline.js +++ b/lib/options/eof-newline.js @@ -1,3 +1,5 @@ +var gonzales = require('gonzales-pe'); + module.exports = { name: 'eof-newline', @@ -10,15 +12,15 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type === 'stylesheet') { - var lastChild = node.content[node.content.length - 1]; - if (lastChild.type !== 'space') { - lastChild = { type: 'space', content: '' }; - node.content.push(lastChild); - } - lastChild.content = lastChild.content.replace(/\n$/, ''); - if (this.getValue('eof-newline')) lastChild.content += '\n'; + if (!node.is('stylesheet')) return; + + var lastChild = node.last(); + if (!lastChild.is('space')) { + lastChild = gonzales.CreateNode({ type: 'space', content: '' }); + node.content.push(lastChild); } + lastChild.content = lastChild.content.replace(/\n$/, ''); + if (this.getValue('eof-newline')) lastChild.content += '\n'; }, /** diff --git a/lib/options/leading-zero.js b/lib/options/leading-zero.js index 25722140..e6485084 100644 --- a/lib/options/leading-zero.js +++ b/lib/options/leading-zero.js @@ -10,13 +10,13 @@ module.exports = { * @param {node} node */ process: function(node) { - if (node.type === 'number') { - if (this.getValue('leading-zero')) { - if (node.content[0] === '.') - node.content = '0' + node.content; - } else { - node.content = node.content.replace(/^0+(?=\.)/, ''); - } + if (!node.is('number')) return; + + if (this.getValue('leading-zero')) { + if (node.content[0] === '.') + node.content = '0' + node.content; + } else { + node.content = node.content.replace(/^0+(?=\.)/, ''); } }, diff --git a/lib/options/quotes.js b/lib/options/quotes.js index b71fb427..30eea8d9 100644 --- a/lib/options/quotes.js +++ b/lib/options/quotes.js @@ -10,20 +10,21 @@ module.exports = { * @param {node} node */ process: function(node) { + if (!node.is('string')) return; + var value = this.getValue('quotes'); - if (node.type === 'string') { - if (node.content[0] === '"' && value === 'single') { - node.content = node.content - .replace(/\\"/g, '"') // unescape all escaped double quotes - .replace(/([^\\])'/g, '$1\\\'') // escape all the single quotes - .replace(/^"|"$/g, '\''); // replace the first and the last quote - } else if (node.content[0] === '\'' && value === 'double') { - node.content = node.content - .replace(/\\'/g, '\'') // unescape all escaped single quotes - .replace(/([^\\])"/g, '$1\\\"') // escape all the double quotes - .replace(/^'|'$/g, '"'); // replace the first and the last quote - } + if (node.content[0] === '"' && value === 'single') { + node.content = node.content + .replace(/\\"/g, '"') // unescape all escaped double quotes + .replace(/([^\\])'/g, '$1\\\'') // escape all the single quotes + .replace(/^"|"$/g, '\''); // replace the first and the last quote + + } else if (node.content[0] === '\'' && value === 'double') { + node.content = node.content + .replace(/\\'/g, '\'') // unescape all escaped single quotes + .replace(/([^\\])"/g, '$1\\\"') // escape all the double quotes + .replace(/^'|'$/g, '"'); // replace the first and the last quote } }, diff --git a/lib/options/remove-empty-rulesets.js b/lib/options/remove-empty-rulesets.js index 05b21846..c42f45e0 100644 --- a/lib/options/remove-empty-rulesets.js +++ b/lib/options/remove-empty-rulesets.js @@ -1,76 +1,46 @@ module.exports = (function() { - function processStylesheetContent(node) { + function processNode(node) { removeEmptyRulesets(node); mergeAdjacentWhitespace(node); } function removeEmptyRulesets(stylesheet) { - var i = stylesheet.content.length; - // Loop through node and try to find a ruleset: - while (i--) { - var node = stylesheet.content[i]; - if (!isRuleset(node)) continue; - // If a ruleset is found, try to find its nested rulesets and remove - // all empty ones: - var j = node.content.length; - while (j--) { - // Nested rulesets are located inside blocks, that's why look - // for blocks only: - var blockNode = node.content[j]; - if (blockNode.type !== 'block') continue; - processStylesheetContent(blockNode); - node.content[j] = blockNode; - } - // If after removing all empty nested rulesets the parent has also - // become empty, remove it too: - if (isEmptyRuleset(node)) { - stylesheet.content.splice(i, 1); - } - } + stylesheet.forEach('ruleset', function(ruleset, i) { + var block = ruleset.first('block'); + processNode(block); + if (isEmptyBlock(block)) stylesheet.remove(i); + }); } /** - * Removing ruleset nodes from tree may result in two adjacent whitespace nodes which is not correct AST: + * Removing ruleset nodes from tree may result in two adjacent whitespace + * nodes which is not correct AST: * [space, ruleset, space] => [space, space] - * To ensure correctness of further processing we should merge such nodes into one. + * To ensure correctness of further processing we should merge such nodes + * into one: * [space, space] => [space] */ function mergeAdjacentWhitespace(node) { var i = node.content.length - 1; while (i-- > 0) { - if (isWhitespace(node.content[i]) && isWhitespace(node.content[i + 1])) { - node.content[i].content += node.content[i + 1].content; - node.content.splice(i + 1, 1); + if (node.get(i).is('space') && node.get(i + 1).is('space')) { + node.get(i).content += node.get(i + 1).content; + node.remove(i + 1); } } } - function isEmptyRuleset(ruleset) { - return isEmptyBlock(ruleset.first('block')); - } - /** * Block is considered empty when it has nothing but spaces. */ function isEmptyBlock(node) { - if (!node.content.length) return true; + if (!node.length) return true; - var isEmpty = true; - node.forEach(function(childNode) { - if (childNode.type !== 'space') isEmpty = false; + return !node.content.some(function(node) { + return !node.is('space'); }); - return isEmpty; } - function isRuleset(node) { - return node.type === 'ruleset'; - } - - function isWhitespace(node) { - return node.type === 'space'; - } - - return { name: 'remove-empty-rulesets', @@ -86,9 +56,9 @@ module.exports = (function() { * @param {String} node */ process: function(node) { - if (node.type === 'stylesheet') { - processStylesheetContent(node); - } + if (!node.is('stylesheet')) return; + + processNode(node); }, /** diff --git a/lib/options/space-after-colon.js b/lib/options/space-after-colon.js index eca88b9a..96ad497b 100644 --- a/lib/options/space-after-colon.js +++ b/lib/options/space-after-colon.js @@ -22,16 +22,16 @@ module.exports = { var value = this.getValue('space-after-colon'); - for (var i = node.content.length; i--;) { - if (!node.content[i].is('propertyDelimiter')) continue; + for (var i = node.length; i--;) { + if (!node.get(i).is('propertyDelimiter')) continue; - if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; + if (this.getSyntax() === 'sass' && !node.get(i - 1)) break; // Remove any spaces after colon: - if (node.content[i + 1].is('space')) node.content.splice(i + 1, 1); + if (node.get(i + 1).is('space')) node.remove(i + 1); // If the value set in config is not empty, add spaces: var space = gonzales.createNode({ type: 'space', content: value }); - if (value !== '') node.content.splice(i + 1, 0, space); + if (value !== '') node.insert(i + 1, space); break; } diff --git a/lib/options/space-after-combinator.js b/lib/options/space-after-combinator.js index 7c4db7c6..8258f5f4 100644 --- a/lib/options/space-after-combinator.js +++ b/lib/options/space-after-combinator.js @@ -22,19 +22,16 @@ module.exports = { var value = this.getValue('space-after-combinator'); - for (var i = node.content.length; i--;) { - var subSelector = node.content[i]; - for (var j = subSelector.content.length; j--;) { - if (!subSelector.content[j].is('combinator')) continue; - - if (subSelector.content[j + 1].is('space')) { - subSelector.content[j + 1].content = value; + node.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + simpleSelector.get(i + 1).content = value; } else { var space = gonzales.createNode({ type: 'space', content: value }); - subSelector.content.splice(j + 1, 0, space); + simpleSelector.insert(i + 1, space); } - } - } + }); + }); }, /** diff --git a/lib/options/space-after-opening-brace.js b/lib/options/space-after-opening-brace.js index 0dd5c601..2dc9e3ab 100644 --- a/lib/options/space-after-opening-brace.js +++ b/lib/options/space-after-opening-brace.js @@ -23,11 +23,11 @@ module.exports = { var value = this.getValue('space-after-opening-brace'); - if (node.content[0].is('space')) { - node.content[0].content = value; + if (node.first().is('space')) { + node.first().content = value; } else if (value !== '') { var space = gonzales.createNode({ type: 'space', content: value }); - node.content.unshift(space); + node.insert(0, space); } }, diff --git a/lib/options/space-after-selector-delimiter.js b/lib/options/space-after-selector-delimiter.js index 3d72e391..b110f751 100644 --- a/lib/options/space-after-selector-delimiter.js +++ b/lib/options/space-after-selector-delimiter.js @@ -22,18 +22,18 @@ module.exports = { var value = this.getValue('space-after-selector-delimiter'); - for (var i = node.content.length; i--;) { - if (!node.content[i].is('delimiter')) continue; + node.forEach('delimiter', function(delimiter, i) { + var nextNode = node.get(i + 1); - if (node.content[i + 1].is('space')) { - node.content[i + 1].content = value; - } else if (node.content[i + 1].content[0].is('space')) { - node.content[i + 1].content[0].content = value; + if (nextNode.is('space')) { + nextNode.content = value; + } else if (nextNode.first().is('space')) { + nextNode.first().content = value; } else { var space = gonzales.createNode({ type: 'space', content: value }); - node.content[i + 1].content.unshift(space); + nextNode.insert(0, space); } - } + }); }, /** diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index fb2fb7d6..891d1105 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -1,6 +1,9 @@ var gonzales = require('gonzales-pe'); module.exports = (function() { + var value; + var blockIndent; + function getLastWhitespaceNode(node) { var lastNode = node.last(); @@ -12,6 +15,38 @@ module.exports = (function() { return getLastWhitespaceNode(lastNode); } + function processBlock(x, level) { + level = level || 0; + + x.forEach(function(node) { + if (!node.is('block') && + !node.is('atrulers')) return processBlock(node, level); + + level++; + + if (value.indexOf('\n') > -1) { + // TODO: Check that it works for '' block indent value + if (blockIndent) value += new Array(level).join(blockIndent); + } + + // If found block node stop at the next one for space check + // For the pre-block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); + + // If it's spaces, modify this node + // If it's something different from spaces, add a space node to the end + if (whitespaceNode) { + whitespaceNode.content = value; + } else if (value !== '') { + var space = gonzales.createNode({ type: 'space', content: value }); + node.content.push(space); + } + + processBlock(node, level); + }); + } + + return { name: 'space-before-closing-brace', @@ -29,46 +64,11 @@ module.exports = (function() { * @param {node} node */ process: function(node) { - var value = this.getValue('space-before-closing-brace'); - var blockIndent = this.getValue('block-indent'); + value = this.getValue('space-before-closing-brace'); + blockIndent = this.getValue('block-indent'); if (!node.is('stylesheet')) return; - function processBlock(x, level) { - level = level || 0; - - for (var i = 0; i < x.content.length; i++) { - node = x.get(i); - if (!node) continue; - - if (node.is('block') || node.is('atrulers')) { - // If found block node stop at the next one for space check - // For the pre-block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node); - - if (value.indexOf('\n') > -1) { - // TODO: Check that it works for '' block indent value - if (blockIndent) value += new Array(level + 1).join(blockIndent); - } - - // If it's spaces, modify this node - // If it's something different from spaces, add a space node to the end - - if (whitespaceNode) { - whitespaceNode.content = value; - } else if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); - if (Array.isArray(node.content)) - node.content.push(space); - } - - level++; - } - - processBlock(node, level); - } - } - processBlock(node); }, diff --git a/lib/options/space-before-colon.js b/lib/options/space-before-colon.js index c0648a25..50630614 100644 --- a/lib/options/space-before-colon.js +++ b/lib/options/space-before-colon.js @@ -21,23 +21,20 @@ module.exports = { if (!node.is('declaration')) return; var value = this.getValue('space-before-colon'); + var syntax = this.getSyntax(); - for (var i = node.content.length; i--;) { - if (!node.content[i].is('propertyDelimiter')) continue; - - if (this.getSyntax() === 'sass' && !node.content[i - 1]) break; + node.forEach('propertyDelimiter', function(delimiter, i) { + if (syntax === 'sass' && !node.get(i - 1)) return; // Remove any spaces before colon: - if (node.content[i - 1].is('space')) { - node.content.splice(i - 1, 1); - i--; + if (node.get(i - 1).is('space')) { + node.remove(--i); } + // If the value set in config is not empty, add spaces: var space = gonzales.createNode({ type: 'space', content: value }); - if (value !== '') node.content.splice(i, 0, space); - - break; - } + if (value !== '') node.insert(i, space); + }); }, /** diff --git a/lib/options/space-before-combinator.js b/lib/options/space-before-combinator.js index 7628134c..7e65746b 100644 --- a/lib/options/space-before-combinator.js +++ b/lib/options/space-before-combinator.js @@ -22,18 +22,16 @@ module.exports = { var value = this.getValue('space-before-combinator'); - for (var i = node.length; i--;) { - var subSelector = node.get(i); - for (var j = subSelector.length; j--;) { - if (!subSelector.get(j).is('combinator')) continue; - if (subSelector.get(j - 1).is('space')) { - subSelector.get(j - 1).content = value; + node.forEach(function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i - 1).is('space')) { + simpleSelector.get(i - 1).content = value; } else { var space = gonzales.createNode({ type: 'space', content: value }); - subSelector.insert(j, space); + simpleSelector.insert(i, space); } - } - } + }); + }); }, /** diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index edbe291c..ecc4f21f 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -35,21 +35,17 @@ module.exports = (function() { process: function(node) { var value = this.getValue('space-before-opening-brace'); - // Loop through node from the end to the beginning: - for (var i = node.length; i--;) { - if (!node.get(i) || typeof node.get(i) === 'string') continue; + node.forEach(function(block, i) { + // XXX: Hack for braces + if (typeof block === 'string') return; - try { - node.get(i).is('space'); - } catch (e) { - console.log(node); - } // If found block node stop at the next one for space check: - if (!node.get(i).is('block') && !node.get(i).is('atrulers')) continue; + if (!block.is('block') && !block.is('atrulers')) return; // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) - var whitespaceNode = getLastWhitespaceNode(node.get(i - 1)); + var previousNode = node.get(i - 1); + var whitespaceNode = getLastWhitespaceNode(previousNode); // If it's spaces, modify this node. // If it's something different from spaces, add a space node to @@ -58,13 +54,13 @@ module.exports = (function() { whitespaceNode.content = value; } else if (value !== '') { var space = gonzales.createNode({ type: 'space', content: value }); - if (node.get(i - 1).is('atrulerq')) { - node.get(i - 1).content.push(space); + if (previousNode.is('atrulerq')) { + previousNode.content.push(space); } else { node.insert(i, space); } } - } + }); }, /** diff --git a/lib/options/strip-spaces.js b/lib/options/strip-spaces.js index b672ec58..91c98c93 100644 --- a/lib/options/strip-spaces.js +++ b/lib/options/strip-spaces.js @@ -2,11 +2,11 @@ module.exports = (function() { /** * Trim trailing spaces on each line. * @private - * @param {String} s Spaceful string + * @param {String} string Spaceful string * @returns {String} */ - function trim(s) { - return s.replace(/[ \t]+\n/g, '\n'); + function trim(string) { + return string.replace(/[ \t]+\n/g, '\n'); } return { @@ -23,9 +23,7 @@ module.exports = (function() { process: function(node) { if (node.is('space')) { node.content = trim(node.content); - } - - if (node.is('stylesheet')) { + } else if (node.is('stylesheet')) { var lastChild = node.last(); if (lastChild.is('space')) { lastChild.content = trim(lastChild.content) diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index 61fcc651..439b18ee 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -13,24 +13,25 @@ module.exports = { process: function(node) { var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - if (node.is('value') || node.is('braces')) { - node.forEach(function(child) { - if (typeof child === 'string') return; + if (!node.is('value') && !node.is('braces')) return; - if (child.is('dimension')) { - var unit = child.get(1).content; - if (child.get(0).content[0] === '0' && UNITS.indexOf(unit) !== -1) { - child.content.splice(1, 1); - } - } else if (child.is('percentage')) { - var number = child.get(0).content; - if (number[0] === '0') { - child.type = 'number'; - child.content = number; - } + node.forEach(function(value) { + if (typeof value === 'string') return; + + if (value.is('dimension')) { + var unit = value.first('ident').content; + if (value.first('number').content[0] === '0' && + UNITS.indexOf(unit) !== -1) { + value.remove(1); } - }); - } + } else if (value.is('percentage')) { + var number = value.first('number').content; + if (number[0] === '0') { + value.type = 'number'; + value.content = number; + } + } + }); }, /** From f556116bde3e645e180f868bb18a937716bd736b Mon Sep 17 00:00:00 2001 From: 1000ch Date: Thu, 12 Feb 2015 09:37:06 +0900 Subject: [PATCH 039/184] add iojs & 0.12 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4a5a560e..650c6dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,10 @@ language: node_js node_js: + - "iojs" - "0.10" - "0.11" + - "0.12" matrix: allow_failures: From 52501c74a4b87acda9648a844b913f0de4be3d1e Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 May 2015 22:30:43 +0200 Subject: [PATCH 040/184] Fix #319: Nested properties --- lib/options/space-before-opening-brace.js | 2 +- .../issue-319.expected.scss | 9 +++++++++ .../space-before-opening-brace-scss/issue-319.scss | 9 +++++++++ test/options/space-before-opening-brace-scss/test.js | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/options/space-before-opening-brace-scss/issue-319.expected.scss create mode 100644 test/options/space-before-opening-brace-scss/issue-319.scss diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index ecc4f21f..1ba30f19 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -54,7 +54,7 @@ module.exports = (function() { whitespaceNode.content = value; } else if (value !== '') { var space = gonzales.createNode({ type: 'space', content: value }); - if (previousNode.is('atrulerq')) { + if (previousNode && previousNode.is('atrulerq')) { previousNode.content.push(space); } else { node.insert(i, space); diff --git a/test/options/space-before-opening-brace-scss/issue-319.expected.scss b/test/options/space-before-opening-brace-scss/issue-319.expected.scss new file mode 100644 index 00000000..4b0777bf --- /dev/null +++ b/test/options/space-before-opening-brace-scss/issue-319.expected.scss @@ -0,0 +1,9 @@ +@import '../../helpers/__helpers'; + +.funky { + font: { + family: fantasy; + size: 30em; + weight: bold; + } +} diff --git a/test/options/space-before-opening-brace-scss/issue-319.scss b/test/options/space-before-opening-brace-scss/issue-319.scss new file mode 100644 index 00000000..068141cc --- /dev/null +++ b/test/options/space-before-opening-brace-scss/issue-319.scss @@ -0,0 +1,9 @@ +@import '../../helpers/__helpers'; + +.funky{ + font:{ + family: fantasy; + size: 30em; + weight: bold; + } +} diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace-scss/test.js index 100f0abc..19a7a059 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -3,4 +3,9 @@ describe('options/space-before-opening-brace (scss):', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); }); + + it('Issue 319', function() { + this.comb.configure({ 'space-before-opening-brace': 1 }); + this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); + }); }); From 7c4f5cb79c94f539532268e04f7b304de4bfba87 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 May 2015 22:42:29 +0200 Subject: [PATCH 041/184] Add test for #333 --- test/options/sort-order-scss/issue-333.scss | 5 +++++ test/options/sort-order-scss/test.js | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 test/options/sort-order-scss/issue-333.scss diff --git a/test/options/sort-order-scss/issue-333.scss b/test/options/sort-order-scss/issue-333.scss new file mode 100644 index 00000000..28a52fde --- /dev/null +++ b/test/options/sort-order-scss/issue-333.scss @@ -0,0 +1,5 @@ +@mixin opacity($opacity) { + $opacity-ie: $opacity * 100; + opacity: $opacity; + filter: alpha(opacity=50); +} diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 72911ab8..66a7d7df 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -114,4 +114,9 @@ describe('options/sort-order (scss)', function() { this.comb.configure({ 'sort-order': ['...'] }); this.shouldBeEqual('issue-317.scss'); }); + + it('Issue 333', function() { + this.comb.configure({ 'sort-order': ['...'] }); + this.shouldBeEqual('issue-333.scss'); + }); }); From dc1cffd8875771847ef8255e52619e45cb9eeeee Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 17 May 2015 21:24:35 +0200 Subject: [PATCH 042/184] Gonzales 3.0: Fix detection tests --- lib/csscomb.js | 16 +++------ lib/options/always-semicolon.js | 12 +++---- lib/options/block-indent.js | 21 +++++------ lib/options/color-case.js | 12 +++---- lib/options/color-shorthand.js | 12 +++---- lib/options/element-case.js | 25 ++++++------- lib/options/eof-newline.js | 18 +++++----- lib/options/leading-zero.js | 15 ++++---- lib/options/quotes.js | 15 ++++---- lib/options/remove-empty-rulesets.js | 14 ++++---- lib/options/space-after-colon.js | 11 +++--- lib/options/space-after-combinator.js | 20 +++++------ lib/options/space-after-opening-brace.js | 9 +++-- lib/options/space-after-selector-delimiter.js | 18 +++++----- lib/options/space-before-closing-brace.js | 36 +++++++++---------- lib/options/space-before-colon.js | 19 +++++----- lib/options/space-before-combinator.js | 20 +++++------ lib/options/space-before-opening-brace.js | 24 ++++++++----- .../space-before-selector-delimiter.js | 17 ++++----- lib/options/strip-spaces.js | 23 ++++++------ lib/options/unitless-zero.js | 29 +++++++-------- lib/options/vendor-prefix-align.js | 25 ++++++------- test/options/always-semicolon/test.js | 14 ++++---- test/options/block-indent/test.js | 11 +++--- test/options/color-case/test.js | 12 +++---- test/options/color-shorthand/test.js | 8 ++--- test/options/element-case/test.js | 12 +++---- test/options/eof-newline/test.js | 8 ++--- test/options/leading-zero/test.js | 6 ++-- test/options/quotes/test.js | 10 +++--- test/options/remove-empty-rulesets/test.js | 2 +- test/options/space-after-colon/test.js | 8 ++--- test/options/space-after-combinator/test.js | 12 +++---- .../options/space-after-opening-brace/test.js | 12 +++---- .../space-after-selector-delimiter/test.js | 12 +++---- .../space-before-closing-brace/test.js | 10 +++--- test/options/space-before-colon/test.js | 8 ++--- test/options/space-before-combinator/test.js | 12 +++---- .../space-before-opening-brace/test.js | 12 +++---- .../space-before-selector-delimiter/test.js | 12 +++---- test/options/strip-spaces/test.js | 16 ++++----- test/options/unitless-zero/test.js | 14 ++++---- test/options/vendor-prefix-align/test.js | 18 +++++----- 43 files changed, 312 insertions(+), 328 deletions(-) diff --git a/lib/csscomb.js b/lib/csscomb.js index bdcf3ca4..607b2c04 100644 --- a/lib/csscomb.js +++ b/lib/csscomb.js @@ -17,7 +17,7 @@ function cssToAST(text, syntax, filename) { var tree; try { - tree = gonzales.srcToAST({ syntax: syntax, src: text }); + tree = gonzales.parse(text, { syntax: syntax }); } catch (e) { throw new Error('Parsing error' + fileInfo + ': ' + e.message); } @@ -56,22 +56,16 @@ function getHandler(optionName) { * @param {Object} detectedOptions */ function detectInNode(node, level, handler, detectedOptions) { - node.forEach(function(node) { - if (!Array.isArray(node)) return; - - var nodeType = node.shift(); - var detected = handler.detect(nodeType, node, level); + node.map(function(tree) { + var detected = handler.detect(tree); var variants = detectedOptions[handler.name]; if (typeof detected === 'object') { variants.push.apply(variants, detected); } else if (typeof detected !== 'undefined') { variants.push(detected); } - node.unshift(nodeType); - - if (nodeType === 'atrulers' || nodeType === 'block') level++; - detectInNode(node, level, handler, detectedOptions); + //if (nodeType === 'atrulers' || nodeType === 'block') level++; }); } @@ -91,7 +85,7 @@ function detectInTree(tree, handlers) { handlers.forEach(function(handler) { detectedOptions[handler.name] = []; // TODO: Pass all parameters as one object? - detectInNode(['tree', tree], 0, handler, detectedOptions); + detectInNode(tree, 0, handler, detectedOptions); }); return detectedOptions; } diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js index 8cdd56af..e84716d0 100644 --- a/lib/options/always-semicolon.js +++ b/lib/options/always-semicolon.js @@ -62,14 +62,12 @@ module.exports = { * @param {node} node */ detect: function(node) { - if (node.type === 'block') { - for (var i = node.content.length; i--;) { - var nodeItem = node.content[i]; - var type = nodeItem.type; - if (type === 'declDelim') return true; + if (!node.is('block')) return; - if (type === 'declaration') return false; - } + for (var i = node.length; i--;) { + var nodeItem = node.get(i); + if (nodeItem.is('declarationDelimiter')) return true; + if (nodeItem.is('declaration')) return false; } } }; diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index d39106c7..1547a454 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -5,6 +5,9 @@ module.exports = (function() { function processNode(node, level) { level = level || 0; + // XXX: Hack for braces + if (node.is('braces')) return; + for (var i = 0; i < node.length; i++) { var n = node.get(i); if (!n) continue; @@ -102,30 +105,28 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node - * @param {Number} level */ - detect: function(nodeType, node, level) { + detect: function(node) { var result = []; // Continue only with non-empty {...} blocks: - if (nodeType !== 'atrulers' && nodeType !== 'block' || !node.length) return; + if (!node.is('atrulers') && !node.is('block') || !node.length) + return; for (var i = node.length; i--;) { - var whitespaceNode = node[i]; - if (whitespaceNode[0] !== 's') continue; + var whitespaceNode = node.get(i); + if (!whitespaceNode.is('space')) continue; - var spaces = whitespaceNode[1]; + var spaces = whitespaceNode.content; var lastIndex = spaces.lastIndexOf('\n'); // Do not continue if there is no line break: if (lastIndex < 0) continue; // Number of spaces from beginning of line: - var spacesLength = spaces.slice(lastIndex + 1).length; - var arrayLength = Math.floor(spacesLength / (level + 1)) + 1; - result.push(new Array(arrayLength).join(' ')); + var spacesLength = spaces.slice(lastIndex + 1).length + 1; + result.push(new Array(spacesLength).join(' ')); } return result; diff --git a/lib/options/color-case.js b/lib/options/color-case.js index 25bf08da..ef1345c9 100644 --- a/lib/options/color-case.js +++ b/lib/options/color-case.js @@ -23,12 +23,12 @@ module.exports = { * @param {node} node */ detect: function(node) { - if (node.type === 'vhash') { - if (node.content[0].match(/^[^A-F]*[a-f][^A-F]*$/)) { - return 'lower'; - } else if (node.content[0].match(/^[^a-f]*[A-F][^a-f]*$/)) { - return 'upper'; - } + if (!node.is('color')) return; + + if (node.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { + return 'lower'; + } else if (node.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { + return 'upper'; } } }; diff --git a/lib/options/color-shorthand.js b/lib/options/color-shorthand.js index 9cd4b8df..4e723bd1 100644 --- a/lib/options/color-shorthand.js +++ b/lib/options/color-shorthand.js @@ -23,12 +23,12 @@ module.exports = { * @param {node} node */ detect: function(node) { - if (node.type === 'vhash') { - if (node.content[0].match(/^\w{3}$/)) { - return true; - } else if (node.content[0].match(/^(\w)\1(\w)\2(\w)\3$/)) { - return false; - } + if (!node.is('color')) return; + + if (node.content.match(/^\w{3}$/)) { + return true; + } else if (node.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { + return false; } } }; diff --git a/lib/options/element-case.js b/lib/options/element-case.js index 76fe79e4..ab8b0fb7 100644 --- a/lib/options/element-case.js +++ b/lib/options/element-case.js @@ -27,22 +27,23 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'simpleselector') return; + detect: function(node) { + if (!node.is('selector') && + !node.is('arguments')) return; var variants = []; - for (var i = node.length; i--;) { - var nodeItem = node[i]; - if (nodeItem[0] !== 'ident') continue; - if (nodeItem[1].match(/^[a-z]+$/)) { - variants.push('lower'); - } else if (nodeItem[1].match(/^[A-Z]+$/)) { - variants.push('upper'); - } - } + + node.forEach('simpleSelector', function(selector) { + selector.forEach('ident', function(ident) { + if (ident.content.match(/^[a-z]+$/)) { + variants.push('lower'); + } else if (ident.content.match(/^[A-Z]+$/)) { + variants.push('upper'); + } + }); + }); return variants; } }; diff --git a/lib/options/eof-newline.js b/lib/options/eof-newline.js index eb0e1fb5..7b914c93 100644 --- a/lib/options/eof-newline.js +++ b/lib/options/eof-newline.js @@ -16,7 +16,7 @@ module.exports = { var lastChild = node.last(); if (!lastChild.is('space')) { - lastChild = gonzales.CreateNode({ type: 'space', content: '' }); + lastChild = gonzales.createNode({ type: 'space', content: '' }); node.content.push(lastChild); } lastChild.content = lastChild.content.replace(/\n$/, ''); @@ -26,16 +26,16 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'stylesheet') { - if (node[node.length - 1][0] === 's' && node[node.length - 1][1].indexOf('\n') !== -1) { - return true; - } else { - return false; - } + detect: function(node) { + if (!node.is('stylesheet')) return; + + var lastChild = node.last(); + if (lastChild.is('space') && lastChild.content.indexOf('\n') !== -1) { + return true; + } else { + return false; } } }; diff --git a/lib/options/leading-zero.js b/lib/options/leading-zero.js index e6485084..bf982367 100644 --- a/lib/options/leading-zero.js +++ b/lib/options/leading-zero.js @@ -23,16 +23,15 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'number') { - if (node.toString().match(/^\.[0-9]+/)) { - return false; - } else if (node.toString().match(/^0\.[0-9]+/)) { - return true; - } + detect: function(node) { + if (!node.is('number')) return; + + if (node.content.match(/^\.[0-9]+/)) { + return false; + } else if (node.content.match(/^0\.[0-9]+/)) { + return true; } } }; diff --git a/lib/options/quotes.js b/lib/options/quotes.js index 30eea8d9..ee657c60 100644 --- a/lib/options/quotes.js +++ b/lib/options/quotes.js @@ -31,16 +31,15 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType === 'string') { - if (node[0][0] === '"') { - return 'double'; - } else if (node[0][0] === '\'') { - return 'single'; - } + detect: function(node) { + if (!node.is('string')) return; + + if (node.content[0] === '"') { + return 'double'; + } else if (node.content[0] === '\'') { + return 'single'; } } }; diff --git a/lib/options/remove-empty-rulesets.js b/lib/options/remove-empty-rulesets.js index c42f45e0..180e2306 100644 --- a/lib/options/remove-empty-rulesets.js +++ b/lib/options/remove-empty-rulesets.js @@ -61,20 +61,20 @@ module.exports = (function() { processNode(node); }, + detectDefault: true, + /** * Detects the value of an option at the tree node. * This option is treated as `true` by default, but any trailing space would invalidate it. * - * @param {String} nodeType * @param {node} node */ - detectDefault: true, + detect: function(node) { + if (!node.is('atrulers') && !node.is('block')) return; - detect: function(nodeType, node) { - if (nodeType === 'atrulers' || nodeType === 'block') { - if (node.length === 0 || (node.length === 1 && node[0][0] === 's')) { - return false; - } + if (node.length === 0 || + (node.length === 1 && node.first().is('space'))) { + return false; } } }; diff --git a/lib/options/space-after-colon.js b/lib/options/space-after-colon.js index 96ad497b..86fab0e9 100644 --- a/lib/options/space-after-colon.js +++ b/lib/options/space-after-colon.js @@ -40,17 +40,16 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'declaration') return; + detect: function(node) { + if (!node.is('declaration')) return; for (var i = node.length; i--;) { - if (node[i][0] !== 'propertyDelim') continue; + if (!node.get(i).is('propertyDelimiter')) continue; - if (node[i + 1][0] === 's') { - return node[i + 1][1]; + if (node.get(i + 1).is('space')) { + return node.get(i + 1).content; } else { return ''; } diff --git a/lib/options/space-after-combinator.js b/lib/options/space-after-combinator.js index 8258f5f4..7d1d54a9 100644 --- a/lib/options/space-after-combinator.js +++ b/lib/options/space-after-combinator.js @@ -37,26 +37,22 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'selector') return; + detect: function(node) { + if (!node.is('selector')) return; var variants = []; - for (var i = node.length; i--;) { - var subSelector = node[i]; - for (var j = subSelector.length; j--;) { - if (subSelector[j][0] !== 'combinator') continue; - - if (subSelector[j + 1][0] === 's') { - variants.push(subSelector[j + 1][1]); + node.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + variants.push(simpleSelector.get(i + 1).content); } else { variants.push(''); } - } - } + }); + }); return variants; } diff --git a/lib/options/space-after-opening-brace.js b/lib/options/space-after-opening-brace.js index 2dc9e3ab..2fe353a6 100644 --- a/lib/options/space-after-opening-brace.js +++ b/lib/options/space-after-opening-brace.js @@ -34,14 +34,13 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'block' && nodeType !== 'atrulers') return; + detect: function(node) { + if (!node.is('block') && !node.is('atrulers')) return; - if (node[0][0] === 'space') { - return node[0][1]; + if (node.first().is('space')) { + return node.first().content; } else { return ''; } diff --git a/lib/options/space-after-selector-delimiter.js b/lib/options/space-after-selector-delimiter.js index b110f751..e35bfdd2 100644 --- a/lib/options/space-after-selector-delimiter.js +++ b/lib/options/space-after-selector-delimiter.js @@ -39,23 +39,23 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'selector') return; + detect: function(node) { + if (!node.is('selector')) return; var variants = []; - for (var i = node.length; i--;) { - if (node[i][0] !== 'delim') continue; - - if (node[i + 1][1][0] === 's') { - variants.push(node[i + 1][1][1]); + node.forEach('delimiter', function(delimiter, i) { + var nextNode = node.get(i + 1); + if (nextNode && nextNode.is('space')) { + variants.push(nextNode.content); + } else if (nextNode.first() && nextNode.first().is('space')) { + variants.push(nextNode.first().content); } else { variants.push(''); } - } + }); return variants; } diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index 891d1105..907dc3ed 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -1,7 +1,7 @@ var gonzales = require('gonzales-pe'); module.exports = (function() { - var value; + var valueFromSettings; var blockIndent; function getLastWhitespaceNode(node) { @@ -18,15 +18,21 @@ module.exports = (function() { function processBlock(x, level) { level = level || 0; + // XXX: Hack for braces + if (x.is('braces')) return; + x.forEach(function(node) { if (!node.is('block') && !node.is('atrulers')) return processBlock(node, level); level++; + var value = valueFromSettings; if (value.indexOf('\n') > -1) { // TODO: Check that it works for '' block indent value - if (blockIndent) value += new Array(level).join(blockIndent); + if (blockIndent) { + value += new Array(level).join(blockIndent); + } } // If found block node stop at the next one for space check @@ -64,7 +70,7 @@ module.exports = (function() { * @param {node} node */ process: function(node) { - value = this.getValue('space-before-closing-brace'); + valueFromSettings = this.getValue('space-before-closing-brace'); blockIndent = this.getValue('block-indent'); if (!node.is('stylesheet')) return; @@ -75,25 +81,19 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - var variants = []; - - // Loop through node from the end to the beginning: - for (var i = node.length; i--;) { - // If found block node stop for space check: - if (node[i][0] !== 'block' && node[i][0] !== 'atrulers') continue; + detect: function(node) { + if (!node.is('block') && !node.is('atrulers')) return; - // For the block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node[i]); + var variants = []; - if (whitespaceNode) { - variants.push(whitespaceNode[1]); - } else { - variants.push(''); - } + // For the block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); + if (whitespaceNode) { + variants.push(whitespaceNode.content); + } else { + variants.push(''); } return variants; diff --git a/lib/options/space-before-colon.js b/lib/options/space-before-colon.js index 50630614..ed332f42 100644 --- a/lib/options/space-before-colon.js +++ b/lib/options/space-before-colon.js @@ -40,20 +40,21 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'declaration') return; + detect: function(node) { + if (!node.is('declaration')) return; - for (var i = node.length; i--;) { - if (node[i][0] !== 'propertyDelim') continue; + var result; - if (node[i - 1][0] === 's') { - return node[i - 1][1]; + node.forEach('propertyDelimiter', function(delimiter, i) { + if (node.get(i - 1).is('space')) { + result = node.get(i - 1).content; } else { - return ''; + result = ''; } - } + }); + + return result; } }; diff --git a/lib/options/space-before-combinator.js b/lib/options/space-before-combinator.js index 7e65746b..a3b95d25 100644 --- a/lib/options/space-before-combinator.js +++ b/lib/options/space-before-combinator.js @@ -37,26 +37,22 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'selector') return; + detect: function(node) { + if (!node.is('selector')) return; var variants = []; - for (var i = node.length; i--;) { - var subSelector = node[i]; - for (var j = subSelector.length; j--;) { - if (subSelector[j][0] !== 'combinator') continue; - - if (subSelector[j - 1][0] === 's') { - variants.push(subSelector[j - 1][1]); + node.forEach(function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i - 1).is('space')) { + variants.push(simpleSelector.get(i - 1).content); } else { variants.push(''); } - } - } + }); + }); return variants; } diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index 1ba30f19..b8209356 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -66,26 +66,32 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { + detect: function(node) { var variants = []; - // Loop through node from the end to the beginning: - for (var i = node.length; i--;) { + node.forEach(function(block, i) { + // XXX: Hack for braces + if (typeof block === 'string') return; + // If found block node stop at the next one for space check: - if (node[i][0] !== 'block' && node[i][0] !== 'atrulers') continue; + if (!block.is('block') && !block.is('atrulers')) return; - // For the pre-block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node[i - 1]); + // For the pre-block node, find its last (the deepest) child: + // TODO: Exclude nodes with braces (for example, arguments) + var previousNode = node.get(i - 1); + var whitespaceNode = getLastWhitespaceNode(previousNode); + // If it's spaces, modify this node. + // If it's something different from spaces, add a space node to + // the end: if (whitespaceNode) { - variants.push(whitespaceNode[1]); + variants.push(whitespaceNode.content); } else { variants.push(''); } - } + }); return variants; } diff --git a/lib/options/space-before-selector-delimiter.js b/lib/options/space-before-selector-delimiter.js index f0db13a2..21204d01 100644 --- a/lib/options/space-before-selector-delimiter.js +++ b/lib/options/space-before-selector-delimiter.js @@ -36,24 +36,21 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'selector') return; + detect: function(node) { + if (!node.is('selector')) return; var variants = []; - for (var i = node.length; i--;) { - if (node[i][0] !== 'delim') continue; - - var previousNode = node[i - 1]; - if (previousNode[previousNode.length - 1][0] === 's') { - variants.push(previousNode[previousNode.length - 1][1]); + node.forEach('delimiter', function(delim, i) { + var previousNode = node.get(i - 1); + if (previousNode.last().is('space')) { + variants.push(previousNode.last().content); } else { variants.push(''); } - } + }); return variants; } diff --git a/lib/options/strip-spaces.js b/lib/options/strip-spaces.js index 91c98c93..36f3f83b 100644 --- a/lib/options/strip-spaces.js +++ b/lib/options/strip-spaces.js @@ -33,24 +33,23 @@ module.exports = (function() { } }, + detectDefault: true, + /** * Detects the value of an option at the tree node. * This option is treated as `true` by default, but any trailing space would invalidate it. * - * @param {String} nodeType * @param {node} node */ - detectDefault: true, - - detect: function(nodeType, node) { - if (nodeType === 's') { - if (node[0].match(/[ \t]\n/)) { - return false; - } - } - if (nodeType === 'stylesheet') { - var lastChild = node[node.length - 1]; - if (lastChild[0] === 's' && lastChild[1] !== '\n' && lastChild[1].match(/^[ \n\t]+$/)) { + detect: function(node) { + if (node.is('space') && + node.content.match(/[ \t]\n/)) { + return false; + } else if (node.is('stylesheet')) { + var lastChild = node.last(); + if (lastChild.is('space') && + lastChild.content !== '\n' && + lastChild.content.match(/^[ \n\t]+$/)) { return false; } } diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index 439b18ee..1f0a03ed 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -37,35 +37,32 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - var result = null; + detect: function(node) { + var result; // If we see a zero with unit and it is not degree, then we don’t have an option - if ( - nodeType === 'percentage' && node[0][1] === '0' || - nodeType === 'dimension' && node[0][1] === '0' && node[1][1] !== 'deg' - ) { + + if (node.is('percentage') && node.first('number').content[1] === '0') { + result = false; + } else if (node.is('dimension') && + node.first('number').content[0] === '0' && + node.first('ident').content !== 'deg') { result = false; } // If we see a zero and previous node is not percentage or dimension, then we have an option - if ( - nodeType === 'number' && - node[0] === '0' && + if (node.is('number') && + node.content[0] === '0' && this._prev !== 'percentage' && - this._prev !== 'dimension' - ) { + this._prev !== 'dimension') { result = true; } // Store the previous nodeType - this._prev = nodeType; + this._prev = node.type; - if (result !== null) { - return result; - } + return result; } }; diff --git a/lib/options/vendor-prefix-align.js b/lib/options/vendor-prefix-align.js index 2cde89b3..39d15d3b 100644 --- a/lib/options/vendor-prefix-align.js +++ b/lib/options/vendor-prefix-align.js @@ -334,16 +334,15 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. * - * @param {String} nodeType * @param {node} node */ - detect: function(nodeType, node) { - if (nodeType !== 'block') return; + detect: function(node) { + if (!node.is('block')) return; var result = { - true: 0, - false: 0 - }; + true: 0, + false: 0 + }; var maybePrefix = false; var prevPrefixLength = false; @@ -400,8 +399,9 @@ module.exports = (function() { selector: getPropertyName, getExtraSymbols: extraIndentProperty, payload: function(info, i) { - if (node[i - 1] && node[i - 1][1]) { - var sum = node[i - 1][1].replace(/^[ \t]*\n+/, '').length + info.prefixLength; + if (node.get(i - 1) && node.get(i - 1).content) { + var sum = node.get(i - 1).content. + replace(/^[ \t]*\n+/, '').length + info.prefixLength; getResult(node, sum, info, i); } } @@ -412,12 +412,13 @@ module.exports = (function() { selector: getValName, getExtraSymbols: extraIndentVal, payload: function(info, i) { - for (var x = node[i].length; x--;) { - if (node[i][x][0] === 'value') break; + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; } - if (node[i][x - 1][1]) { - var sum = node[i][x - 1][1].replace(/^[ \t]*\n+/, '').length + info.prefixLength; + if (node.get(i).get(x - 1)) { + var sum = node.get(i).get(x - 1).content + .replace(/^[ \t]*\n+/, '').length + info.prefixLength; getResult(node, sum, info, i); } } diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js index 2290343a..a20f8d3f 100644 --- a/test/options/always-semicolon/test.js +++ b/test/options/always-semicolon/test.js @@ -51,7 +51,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should detect semicolon for last property. Test 1', function() { + it('Should detect semicolon for last property. Test 1', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0 }', @@ -61,7 +61,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should detect semicolon for last property. Test 2', function() { + it('Should detect semicolon for last property. Test 2', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0; }', @@ -71,7 +71,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should detect semicolon for last property. Test 3', function() { + it('Should detect semicolon for last property. Test 3', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0; } div { height: 0 }', @@ -81,7 +81,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should detect semicolon for last property. Test 4', function() { + it('Should detect semicolon for last property. Test 4', function() { this.shouldDetect( ['always-semicolon'], 'div { height: 0 } div { height: 0; } div { height: 0 }', @@ -91,7 +91,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should detect semicolon for last property. Test 5', function() { + it('Should detect semicolon for last property. Test 5', function() { this.shouldDetect( ['always-semicolon'], 'div {\nheight: 0 /* Comment */\n} ' + @@ -104,7 +104,7 @@ describe('options/always-semicolon', function() { }); - it.skip('Should detect semicolon for last property. Test 6', function() { + it('Should detect semicolon for last property. Test 6', function() { this.shouldDetect( ['always-semicolon'], 'a{\n border:0;\n}', @@ -114,7 +114,7 @@ describe('options/always-semicolon', function() { ); }); - it.skip('Should not detect semicolon for last property if there are no properties', function() { + it('Should not detect semicolon for last property if there are no properties', function() { this.shouldDetect( ['always-semicolon'], 'div {}', diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index 62dd45f9..e0a44618 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -24,7 +24,7 @@ describe('options/block-indent:', function() { this.shouldBeEqual('test.css', 'test-2.expected.css'); }); - it.skip('Should detect nothing with an empty block, test 1', function() { + it('Should detect nothing with an empty block, test 1', function() { this.shouldDetect( ['block-indent'], 'a{ }', @@ -32,7 +32,7 @@ describe('options/block-indent:', function() { ); }); - it.skip('Should detect nothing with an empty block, test 2', function() { + it('Should detect nothing with an empty block, test 2', function() { this.shouldDetect( ['block-indent'], 'a{}', @@ -40,7 +40,7 @@ describe('options/block-indent:', function() { ); }); - it.skip('Should detect correct number of spaces', function() { + it('Should detect correct number of spaces', function() { this.shouldDetect( ['block-indent'], 'a{\n top: 0;\n color: tomato;\n}', @@ -48,14 +48,15 @@ describe('options/block-indent:', function() { ); }); - it.skip('Should detect no indent for one-line code', function() { + it('Should detect no indent for one-line code', function() { this.shouldDetect( ['block-indent'], 'a{ top: 0; color: tomato; }', {} ); }); - it.skip('Valid string value => should set proper space after combnator', function() { + + it('Valid string value => should set proper space after combnator', function() { this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); this.shouldBeEqual('test.css', 'test-3.expected.css'); }); diff --git a/test/options/color-case/test.js b/test/options/color-case/test.js index 3893d6f4..e94af2ff 100644 --- a/test/options/color-case/test.js +++ b/test/options/color-case/test.js @@ -43,7 +43,7 @@ describe('options/color-case', function() { ); }); - it.skip('Should detect uppercase color', function() { + it('Should detect uppercase color', function() { this.shouldDetect( ['color-case'], 'a { color: #F3F3F3 }', @@ -53,7 +53,7 @@ describe('options/color-case', function() { ); }); - it.skip('Should detect lowercase color', function() { + it('Should detect lowercase color', function() { this.shouldDetect( ['color-case'], 'a { color: #f6f6f6 }', @@ -63,7 +63,7 @@ describe('options/color-case', function() { ); }); - it.skip('Should detect uppercase color in a shorthand', function() { + it('Should detect uppercase color in a shorthand', function() { this.shouldDetect( ['color-case'], 'a { color: #FFF }', @@ -73,7 +73,7 @@ describe('options/color-case', function() { ); }); - it.skip('Should detect lowercase color in a shorthand', function() { + it('Should detect lowercase color in a shorthand', function() { this.shouldDetect( ['color-case'], 'a { color: #fff }', @@ -83,7 +83,7 @@ describe('options/color-case', function() { ); }); - it.skip('Shouldn’t detect color case if it contains only digits', function() { + it('Shouldn’t detect color case if it contains only digits', function() { this.shouldDetect( ['color-case'], 'a { color: #333 }', @@ -91,7 +91,7 @@ describe('options/color-case', function() { ); }); - it.skip('Shouldn’t detect color case if it is in mixed case', function() { + it('Shouldn’t detect color case if it is in mixed case', function() { this.shouldDetect( ['color-case'], 'a { color: #fFfFfF }', diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/test.js index c46a82b0..d1708c0c 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/test.js @@ -32,7 +32,7 @@ describe('options/color-shorthand', function() { }); - it.skip('Should detect non-shorthanded color', function() { + it('Should detect non-shorthanded color', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #FF33EE }', @@ -42,7 +42,7 @@ describe('options/color-shorthand', function() { ); }); - it.skip('Should detect shorthanded color', function() { + it('Should detect shorthanded color', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #fff }', @@ -52,7 +52,7 @@ describe('options/color-shorthand', function() { ); }); - it.skip('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { + it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { this.shouldDetect( ['color-shorthand'], 'a { color: #F3F3F3 }', @@ -60,7 +60,7 @@ describe('options/color-shorthand', function() { ); }); - it.skip('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { + it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { this.shouldDetect( ['color-shorthand'], 'a { color: rgba(0,0,0,0.5) }', diff --git a/test/options/element-case/test.js b/test/options/element-case/test.js index 865206d4..fb95287c 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/test.js @@ -41,7 +41,7 @@ describe('options/element-case', function() { ); }); - it.skip('Should detect lowercase elements', function() { + it('Should detect lowercase elements', function() { this.shouldDetect( ['element-case'], 'a { color: red }', @@ -51,7 +51,7 @@ describe('options/element-case', function() { ); }); - it.skip('Should detect uppercase elements', function() { + it('Should detect uppercase elements', function() { this.shouldDetect( ['element-case'], 'A { color: red }', @@ -61,7 +61,7 @@ describe('options/element-case', function() { ); }); - it.skip('Should detect lowercase elements in a long selector', function() { + it('Should detect lowercase elements in a long selector', function() { this.shouldDetect( ['element-case'], 'ul li:not(:hover) A { color: red }', @@ -71,7 +71,7 @@ describe('options/element-case', function() { ); }); - it.skip('Should detect uppercase elements in a long selector', function() { + it('Should detect uppercase elements in a long selector', function() { this.shouldDetect( ['element-case'], 'ul .lol:not(LI) A { color: red }', @@ -81,7 +81,7 @@ describe('options/element-case', function() { ); }); - it.skip('Shouldn’t detect case of elements in a mixed case', function() { + it('Shouldn’t detect case of elements in a mixed case', function() { this.shouldDetect( ['element-case'], 'aRtIcLe { color: red }', @@ -89,7 +89,7 @@ describe('options/element-case', function() { ); }); - it.skip('Shouldn’t detect case of elements when there are no such', function() { + it('Shouldn’t detect case of elements when there are no such', function() { this.shouldDetect( ['element-case'], '*.lol { color: red }', diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/test.js index a70050ac..ead5fcf1 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/test.js @@ -27,7 +27,7 @@ describe('options/eof-newline', function() { ); }); - it.skip('Shouldn’t detect eof newline', function() { + it('Shouldn’t detect eof newline', function() { this.shouldDetect( ['eof-newline'], 'a { color: red }', @@ -37,7 +37,7 @@ describe('options/eof-newline', function() { ); }); - it.skip('Should detect eof newline', function() { + it('Should detect eof newline', function() { this.shouldDetect( ['eof-newline'], 'a { color: red }\n', @@ -47,7 +47,7 @@ describe('options/eof-newline', function() { ); }); - it.skip('Shouldn’t detect eof newline with spaces at the end', function() { + it('Shouldn’t detect eof newline with spaces at the end', function() { this.shouldDetect( ['eof-newline'], 'a { color: red } ', @@ -57,7 +57,7 @@ describe('options/eof-newline', function() { ); }); - it.skip('Should detect eof newline with mixed spaces at the end', function() { + it('Should detect eof newline with mixed spaces at the end', function() { this.shouldDetect( ['eof-newline'], 'a { color: red } \n ', diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/test.js index 6040c45d..dbd5c2b8 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/test.js @@ -21,7 +21,7 @@ describe('options/leading-zero', function() { ); }); - it.skip('Should detect leading zero option', function() { + it('Should detect leading zero option', function() { this.shouldDetect( ['leading-zero'], 'a { width: 0.5em }', @@ -31,7 +31,7 @@ describe('options/leading-zero', function() { ); }); - it.skip('Should detect leading zero option set to false', function() { + it('Should detect leading zero option set to false', function() { this.shouldDetect( ['leading-zero'], 'a { width: .5em }', @@ -41,7 +41,7 @@ describe('options/leading-zero', function() { ); }); - it.skip('Shouldn’t detect leading zero option', function() { + it('Shouldn’t detect leading zero option', function() { this.shouldDetect( ['leading-zero'], 'a { width: 10.5em }', diff --git a/test/options/quotes/test.js b/test/options/quotes/test.js index 87a197d6..5ed3a898 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/test.js @@ -70,7 +70,7 @@ describe('options/quotes', function() { ); }); - it.skip('Should not detect quotes when there are none', function() { + it('Should not detect quotes when there are none', function() { this.shouldDetect( ['quotes'], 'a { color:red }', @@ -78,7 +78,7 @@ describe('options/quotes', function() { ); }); - it.skip('Should detect double quotes', function() { + it('Should detect double quotes', function() { this.shouldDetect( ['quotes'], 'a { content: "foo" }', @@ -88,7 +88,7 @@ describe('options/quotes', function() { ); }); - it.skip('Should detect single quotes', function() { + it('Should detect single quotes', function() { this.shouldDetect( ['quotes'], 'a { content: \'foo\' }', @@ -98,7 +98,7 @@ describe('options/quotes', function() { ); }); - it.skip('Should detect single quotes in attribute', function() { + it('Should detect single quotes in attribute', function() { this.shouldDetect( ['quotes'], 'a[class^=\'foo\'] { color: red }', @@ -108,7 +108,7 @@ describe('options/quotes', function() { ); }); - it.skip('Should detect double quotes in url', function() { + it('Should detect double quotes in url', function() { this.shouldDetect( ['quotes'], 'a { background: url("foo.png") }', diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/test.js index 509c5d60..a516227c 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/test.js @@ -28,7 +28,7 @@ describe('options/remove-empty-rulesets', function() { }); }); - describe.skip('detecting the value', function() { + describe('detecting the value', function() { it('Should detect this option set to `true`', function() { this.shouldDetect( ['remove-empty-rulesets'], diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/test.js index 6e00b929..8a6873d9 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/test.js @@ -29,7 +29,7 @@ describe('options/space-after-colon:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespaces', function() { + it('Should detect no whitespaces', function() { this.shouldDetect( ['space-after-colon'], 'a { color:red }', @@ -37,7 +37,7 @@ describe('options/space-after-colon:', function() { ); }); - it.skip('Should detect space from two variants', function() { + it('Should detect space from two variants', function() { this.shouldDetect( ['space-after-colon'], 'a { color: red; color :red }', @@ -45,7 +45,7 @@ describe('options/space-after-colon:', function() { ); }); - it.skip('Should detect no whitespaces along three variants', function() { + it('Should detect no whitespaces along three variants', function() { this.shouldDetect( ['space-after-colon'], 'a { color: red; background :red } b { width:10px }', @@ -53,7 +53,7 @@ describe('options/space-after-colon:', function() { ); }); - it.skip('Should detect space', function() { + it('Should detect space', function() { this.shouldDetect( ['space-after-colon'], 'a { color : red; background :red } b { width: 10px }', diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/test.js index 4fafab48..7d085b48 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/test.js @@ -29,7 +29,7 @@ describe('options/space-after-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespaces after combinator', function() { + it('Should detect no whitespaces after combinator', function() { this.shouldDetect( ['space-after-combinator'], 'a+b { color:red }', @@ -37,7 +37,7 @@ describe('options/space-after-combinator:', function() { ); }); - it.skip('Should detect a space after combinator', function() { + it('Should detect a space after combinator', function() { this.shouldDetect( ['space-after-combinator'], 'a + \n b { color:red }', @@ -45,7 +45,7 @@ describe('options/space-after-combinator:', function() { ); }); - it.skip('Should detect a space after combinator in long selector', function() { + it('Should detect a space after combinator in long selector', function() { this.shouldDetect( ['space-after-combinator'], 'a + b ~ c>d { color:red }', @@ -53,7 +53,7 @@ describe('options/space-after-combinator:', function() { ); }); - it.skip('Should detect a space after combinator in long selector, test 2', function() { + it('Should detect a space after combinator in long selector, test 2', function() { this.shouldDetect( ['space-after-combinator'], 'a>b + c + d { color:red }', @@ -61,7 +61,7 @@ describe('options/space-after-combinator:', function() { ); }); - it.skip('Should detect no whitespaces after combinator in long selector', function() { + it('Should detect no whitespaces after combinator in long selector', function() { this.shouldDetect( ['space-after-combinator'], 'a+b ~ c+d { color:red }', @@ -69,7 +69,7 @@ describe('options/space-after-combinator:', function() { ); }); - it.skip('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { + it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { this.shouldDetect( ['space-after-combinator'], 'a { color:red }', diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 47f337b1..7b9eb59a 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -29,7 +29,7 @@ describe('options/space-after-opening-brace:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespace', function() { + it('Should detect no whitespace', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0}', @@ -37,7 +37,7 @@ describe('options/space-after-opening-brace:', function() { ); }); - it.skip('Should detect whitespace', function() { + it('Should detect whitespace', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{\n\ttop:0}', @@ -45,7 +45,7 @@ describe('options/space-after-opening-brace:', function() { ); }); - it.skip('Should detect no whitespace (2 blocks)', function() { + it('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0} b{\n left:0}', @@ -53,7 +53,7 @@ describe('options/space-after-opening-brace:', function() { ); }); - it.skip('Should detect whitespace (2 blocks)', function() { + it('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{ top:0 } b{left:0}', @@ -61,7 +61,7 @@ describe('options/space-after-opening-brace:', function() { ); }); - it.skip('Should detect no whitespace (3 blocks)', function() { + it('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{top:0} b { left: 0 } c{\n\tright:0}', @@ -69,7 +69,7 @@ describe('options/space-after-opening-brace:', function() { ); }); - it.skip('Should detect whitespace (3 blocks)', function() { + it('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-opening-brace'], 'a{\ntop:0} b{\nleft:0} c{\n right:0}', diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/test.js index 03563da0..3eb3b1b0 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -29,7 +29,7 @@ describe('options/space-after-selector-delimiter:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespace', function() { + it('Should detect no whitespace', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0}', @@ -37,7 +37,7 @@ describe('options/space-after-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace', function() { + it('Should detect whitespace', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, \n b {top:0}', @@ -45,7 +45,7 @@ describe('options/space-after-selector-delimiter:', function() { ); }); - it.skip('Should detect no whitespace (2 blocks)', function() { + it('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0} a, b{left:0}', @@ -53,7 +53,7 @@ describe('options/space-after-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace (2 blocks)', function() { + it('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, b {top:0} b,a{left:0}', @@ -61,7 +61,7 @@ describe('options/space-after-selector-delimiter:', function() { ); }); - it.skip('Should detect no whitespace (3 blocks)', function() { + it('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a, b{top:0} b,c{left:0} c,d{right:0}', @@ -69,7 +69,7 @@ describe('options/space-after-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace (3 blocks)', function() { + it('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-after-selector-delimiter'], 'a,b{top:0} b, c{left:0} c, sd{right:0}', diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/test.js index 75f72c47..d8d0a62a 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/test.js @@ -29,7 +29,7 @@ describe('options/space-before-closing-brace:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespace', function() { + it('Should detect no whitespace', function() { this.shouldDetect( ['space-before-closing-brace'], 'a{top:0}', @@ -37,7 +37,7 @@ describe('options/space-before-closing-brace:', function() { ); }); - it.skip('Should detect no whitespace (2 blocks)', function() { + it('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-closing-brace'], 'a{top:0} b { color: tomato; }', @@ -45,7 +45,7 @@ describe('options/space-before-closing-brace:', function() { ); }); - it.skip('Should detect whitespace', function() { + it('Should detect whitespace', function() { this.shouldDetect( ['space-before-closing-brace'], 'a { top:0 }', @@ -53,7 +53,7 @@ describe('options/space-before-closing-brace:', function() { ); }); - it.skip('Should detect whitespace (2 blocks)', function() { + it('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-closing-brace'], 'a { top:0 } b{color:tomato;}', @@ -61,7 +61,7 @@ describe('options/space-before-closing-brace:', function() { ); }); - it.skip('Should detect whitespace (mix with block indent)', function() { + it('Should detect whitespace (mix with block indent)', function() { this.shouldDetect( ['space-before-closing-brace', 'block-indent'], 'a {\n top:0\n }\nb{\n color:tomato;\n }', diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/test.js index f239f168..c545d0c8 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/test.js @@ -29,7 +29,7 @@ describe('options/space-before-colon:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespaces', function() { + it('Should detect no whitespaces', function() { this.shouldDetect( ['space-before-colon'], 'a { color:red }', @@ -37,7 +37,7 @@ describe('options/space-before-colon:', function() { ); }); - it.skip('Should detect no space from two variants', function() { + it('Should detect no space from two variants', function() { this.shouldDetect( ['space-before-colon'], 'a { color: red; color :red }', @@ -45,7 +45,7 @@ describe('options/space-before-colon:', function() { ); }); - it.skip('Should detect no whitespaces along three variants', function() { + it('Should detect no whitespaces along three variants', function() { this.shouldDetect( ['space-before-colon'], 'a { color: red; background :red } b { width:10px }', @@ -53,7 +53,7 @@ describe('options/space-before-colon:', function() { ); }); - it.skip('Should detect space', function() { + it('Should detect space', function() { this.shouldDetect( ['space-before-colon'], 'a { color : red; background :red } b { width:10px }', diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index 0a25a3bf..3883dba8 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -29,7 +29,7 @@ describe('options/space-before-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespaces before combinator', function() { + it('Should detect no whitespaces before combinator', function() { this.shouldDetect( ['space-before-combinator'], 'a+b { color:red }', @@ -37,7 +37,7 @@ describe('options/space-before-combinator:', function() { ); }); - it.skip('Should detect a space before combinator', function() { + it('Should detect a space before combinator', function() { this.shouldDetect( ['space-before-combinator'], 'a + b { color:red }', @@ -45,7 +45,7 @@ describe('options/space-before-combinator:', function() { ); }); - it.skip('Should detect a space before combinator in long selector', function() { + it('Should detect a space before combinator in long selector', function() { this.shouldDetect( ['space-before-combinator'], 'a + b ~ c>d { color:red }', @@ -53,7 +53,7 @@ describe('options/space-before-combinator:', function() { ); }); - it.skip('Should detect a space before combinator in long selector, test 2', function() { + it('Should detect a space before combinator in long selector, test 2', function() { this.shouldDetect( ['space-before-combinator'], 'a>b + c + d { color:red }', @@ -61,7 +61,7 @@ describe('options/space-before-combinator:', function() { ); }); - it.skip('Should detect no whitespaces before combinator in long selector', function() { + it('Should detect no whitespaces before combinator in long selector', function() { this.shouldDetect( ['space-before-combinator'], 'a+b ~ c+d { color:red }', @@ -69,7 +69,7 @@ describe('options/space-before-combinator:', function() { ); }); - it.skip('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { + it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { this.shouldDetect( ['space-before-combinator'], 'a { color:red }', diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/test.js index 4143b7a7..338e6c1c 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/test.js @@ -34,7 +34,7 @@ describe('options/space-before-opening-brace:', function() { this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); }); - it.skip('Should detect no whitespace', function() { + it('Should detect no whitespace', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0}', @@ -42,7 +42,7 @@ describe('options/space-before-opening-brace:', function() { ); }); - it.skip('Should detect whitespace', function() { + it('Should detect whitespace', function() { this.shouldDetect( ['space-before-opening-brace'], 'a \n {top:0}', @@ -50,7 +50,7 @@ describe('options/space-before-opening-brace:', function() { ); }); - it.skip('Should detect no whitespace (2 blocks)', function() { + it('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0} b {left:0}', @@ -58,7 +58,7 @@ describe('options/space-before-opening-brace:', function() { ); }); - it.skip('Should detect whitespace (2 blocks)', function() { + it('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a {top:0} b{left:0}', @@ -66,7 +66,7 @@ describe('options/space-before-opening-brace:', function() { ); }); - it.skip('Should detect no whitespace (3 blocks)', function() { + it('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a {top:0} b{left:0} c{right:0}', @@ -74,7 +74,7 @@ describe('options/space-before-opening-brace:', function() { ); }); - it.skip('Should detect whitespace (3 blocks)', function() { + it('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-opening-brace'], 'a{top:0} b {left:0} c {right:0}', diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/test.js index dc3e588e..92e2a959 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -29,7 +29,7 @@ describe('options/space-before-selector-delimiter:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.skip('Should detect no whitespace', function() { + it('Should detect no whitespace', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0}', @@ -37,7 +37,7 @@ describe('options/space-before-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace', function() { + it('Should detect whitespace', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a \n ,b {top:0}', @@ -45,7 +45,7 @@ describe('options/space-before-selector-delimiter:', function() { ); }); - it.skip('Should detect no whitespace (2 blocks)', function() { + it('Should detect no whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0} a ,b{left:0}', @@ -53,7 +53,7 @@ describe('options/space-before-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace (2 blocks)', function() { + it('Should detect whitespace (2 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a ,b {top:0} b,a{left:0}', @@ -61,7 +61,7 @@ describe('options/space-before-selector-delimiter:', function() { ); }); - it.skip('Should detect no whitespace (3 blocks)', function() { + it('Should detect no whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a ,b{top:0} b,c{left:0} c,d{right:0}', @@ -69,7 +69,7 @@ describe('options/space-before-selector-delimiter:', function() { ); }); - it.skip('Should detect whitespace (3 blocks)', function() { + it('Should detect whitespace (3 blocks)', function() { this.shouldDetect( ['space-before-selector-delimiter'], 'a,b{top:0} b ,c{left:0} c ,d{right:0}', diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/test.js index 082fc4e0..b8f19b36 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/test.js @@ -31,7 +31,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `true`', function() { + it('Should detect strip-spaces option set to `true`', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }', @@ -41,7 +41,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `false`', function() { + it('Should detect strip-spaces option set to `false`', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red } ', @@ -51,7 +51,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `true` with newline', function() { + it('Should detect strip-spaces option set to `true` with newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\nb { color: blue }', @@ -61,7 +61,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `false` with newline', function() { + it('Should detect strip-spaces option set to `false` with newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red } \nb { color: blue }', @@ -71,7 +71,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `true` inside a value', function() { + it('Should detect strip-spaces option set to `true` inside a value', function() { this.shouldDetect( ['strip-spaces'], 'a {\n color:\n red }', @@ -81,7 +81,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `false` inside a value', function() { + it('Should detect strip-spaces option set to `false` inside a value', function() { this.shouldDetect( ['strip-spaces'], 'a {\n color: \n red }', @@ -91,7 +91,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { + it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\n', @@ -101,7 +101,7 @@ describe('options/strip-spaces', function() { ); }); - it.skip('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { + it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { this.shouldDetect( ['strip-spaces'], 'a { color: red }\n\n', diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index 12c5bd83..f47be91d 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -35,7 +35,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Should detect unitless zero option', function() { + it('Should detect unitless zero option', function() { this.shouldDetect( ['unitless-zero'], 'a { width: 0 }', @@ -45,7 +45,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Should detect zero with unit', function() { + it('Should detect zero with unit', function() { this.shouldDetect( ['unitless-zero'], 'a { width: 0px }', @@ -55,7 +55,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Should detect unitless zero option with multiple values', function() { + it('Should detect unitless zero option with multiple values', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0px 0 0 }', @@ -65,7 +65,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Should detect zero with unit and multiple values', function() { + it('Should detect zero with unit and multiple values', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0px 0 0em }', @@ -75,7 +75,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Shouldn’t detect unitless zero option if there is no unit', function() { + it('Shouldn’t detect unitless zero option if there is no unit', function() { this.shouldDetect( ['unitless-zero'], 'a { color: red }', @@ -83,7 +83,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Shouldn’t detect unitless zero option if there is `deg` unit', function() { + it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { this.shouldDetect( ['unitless-zero'], 'a { transform: rotate(0deg) }', @@ -91,7 +91,7 @@ describe('options/unitless-zero', function() { ); }); - it.skip('Should detect unitless zero option with percents', function() { + it('Should detect unitless zero option with percents', function() { this.shouldDetect( ['unitless-zero'], 'a { padding: 0% 0 0 }', diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index 6118bad2..91613542 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -67,7 +67,7 @@ describe('options/vendor-prefix-align', function() { this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); }); - it.skip('Shouldn not detect anything if there are no prefixed groups', function() { + it('Shouldn not detect anything if there are no prefixed groups', function() { this.shouldDetect( ['vendor-prefix-align'], 'a{ color: red }a{ -webkit-transform: translateZ(0) }', @@ -75,7 +75,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as false in properties', function() { + it('Shouldn detect vendor-prefix-align as false in properties', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('property-align.css'), @@ -85,7 +85,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as true in properties', function() { + it('Shouldn detect vendor-prefix-align as true in properties', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('property-align.expected.css'), @@ -95,7 +95,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as false in values', function() { + it('Shouldn detect vendor-prefix-align as false in values', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('value-align.css'), @@ -105,7 +105,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as true in values', function() { + it('Shouldn detect vendor-prefix-align as true in values', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('value-align.expected.css'), @@ -115,7 +115,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as true, test 1', function() { + it('Shouldn detect vendor-prefix-align as true, test 1', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('already-aligned.css'), @@ -125,7 +125,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as true, test 2', function() { + it('Shouldn detect vendor-prefix-align as true, test 2', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('complex.expected.css'), @@ -135,7 +135,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Shouldn detect vendor-prefix-align as false', function() { + it('Shouldn detect vendor-prefix-align as false', function() { this.shouldDetect( ['vendor-prefix-align'], this.readFile('complex.css'), @@ -145,7 +145,7 @@ describe('options/vendor-prefix-align', function() { ); }); - it.skip('Should not detect anything in simple case', function() { + it('Should not detect anything in simple case', function() { this.shouldDetect( ['vendor-prefix-align'], 'a{border:0;}', From 658173b6b531a6e27046a1d3fd7f2561fc62a0fa Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 17 May 2015 23:25:46 +0200 Subject: [PATCH 043/184] Tests: Unskip integral tests --- test/options/integral/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 885e33f6..e316f47d 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('integral test', function() { +describe('integral test', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); From 5750550ab8c9deec1946da6646ed28ea748f1764 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 17 May 2015 23:28:42 +0200 Subject: [PATCH 044/184] Tests: Unskip core tests --- test/core/configure/test.js | 2 +- test/core/get-config/test.js | 2 +- test/core/less/test.js | 2 +- test/core/scss/test.js | 2 +- test/core/use/test.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/core/configure/test.js b/test/core/configure/test.js index 58fde686..9ce774f7 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -1,7 +1,7 @@ var Comb = process.env.TEST_COV ? require('../../../lib-cov/csscomb') : require('../../../lib/csscomb'); var assert = require('assert'); -describe.skip('csscomb methods', function() { +describe('csscomb methods', function() { var comb; var input; var output; diff --git a/test/core/get-config/test.js b/test/core/get-config/test.js index 23ec2377..8d69c294 100644 --- a/test/core/get-config/test.js +++ b/test/core/get-config/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('csscomb methods', function() { +describe('csscomb methods', function() { it('getConfig()', function() { var config = require('../../../config/csscomb.json'); diff --git a/test/core/less/test.js b/test/core/less/test.js index 06688ab3..defa5353 100644 --- a/test/core/less/test.js +++ b/test/core/less/test.js @@ -1,4 +1,4 @@ -describe.skip('LESS', function() { +describe('LESS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/scss/test.js b/test/core/scss/test.js index eda05b50..3f2fb42a 100644 --- a/test/core/scss/test.js +++ b/test/core/scss/test.js @@ -1,4 +1,4 @@ -describe.skip('SCSS', function() { +describe('SCSS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/use/test.js b/test/core/use/test.js index 63f0c2cb..d4ccc690 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('.use()', function() { +describe('.use()', function() { it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); From efa3d8d60b729837a43843cb44956bafb6d4b36a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 17 May 2015 23:31:44 +0200 Subject: [PATCH 045/184] Tests: Unskip green vendor-prefix test --- test/options/vendor-prefix-align/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index 91613542..f9ca9b2b 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -59,7 +59,7 @@ describe('options/vendor-prefix-align', function() { this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); }); - it.skip('Issue 241: should not break tabs', function() { + it('Issue 241: should not break tabs', function() { this.comb.configure({ 'block-indent': '\t', 'vendor-prefix-align': true From ecfc41ee1f30c5ca03d834e3b2a124a39dc56fb3 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 12 May 2015 23:16:47 -0400 Subject: [PATCH 046/184] Follow the configPath to the real path This is in case the configPath is a symlink. Which happens to me with my dotfiles --- lib/csscomb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csscomb.js b/lib/csscomb.js index 607b2c04..706797ca 100644 --- a/lib/csscomb.js +++ b/lib/csscomb.js @@ -247,7 +247,7 @@ CSScomb.getCustomConfigPath = function getCustomConfigPath(configPath) { configPath = configPath || path.join(process.cwd(), '.csscomb.json'); // If we've finally found a config, return its path: - if (fs.existsSync(configPath)) return configPath; + if (fs.existsSync(configPath)) return fs.realpathSync(configPath); // If we are in HOME dir already and yet no config file, return a default // one from our package. From 33388bc29bfe0e8b5722c1508f06a14176323a29 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 12 May 2015 23:28:15 -0400 Subject: [PATCH 047/184] Use readFileSync and JSON parse to read config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I symlink my .csscomb.json file to another file that doesn’t have a json extension. which causes node’s require to bork. --- lib/csscomb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csscomb.js b/lib/csscomb.js index 706797ca..94b4f766 100644 --- a/lib/csscomb.js +++ b/lib/csscomb.js @@ -225,7 +225,7 @@ CSScomb.getCustomConfig = function getCustomConfig(configPath) { configPath = configPath || CSScomb.getCustomConfigPath(); try { - config = require(configPath); + config = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch (e) { config = null; } From ac2c972d63193bb46aa8732cb7dbbf1c5887da8c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 19 May 2015 11:14:02 +0200 Subject: [PATCH 048/184] Add test for #374 --- test/options/integral/issue-374.css | 4 ++++ test/options/integral/test.js | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 test/options/integral/issue-374.css diff --git a/test/options/integral/issue-374.css b/test/options/integral/issue-374.css new file mode 100644 index 00000000..bf667383 --- /dev/null +++ b/test/options/integral/issue-374.css @@ -0,0 +1,4 @@ +html /deep/ span +{ + display: block; +} diff --git a/test/options/integral/test.js b/test/options/integral/test.js index e316f47d..0fe73731 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -13,6 +13,12 @@ describe('integral test', function() { this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); }); + it('Issue 374', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-374.css'); + }); + it('Should detect everything in integral test', function() { var input = this.readFile('integral.expected.css'); // Clone the required config object, otherwise other tests would fail From 854005c8290f403e2e68cc2b5588d206e5016060 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 19 May 2015 11:25:05 +0200 Subject: [PATCH 049/184] Tests: Unskip green parser test --- test/options/sass/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/options/sass/test.js b/test/options/sass/test.js index cb934407..054ab9dd 100644 --- a/test/options/sass/test.js +++ b/test/options/sass/test.js @@ -23,7 +23,7 @@ describe('Sass', function() { this.shouldBeEqual('interpolated-variable-1.sass'); }); - it.skip('Should parse interpolated variables inside values', function() { + it('Should parse interpolated variables inside values', function() { this.shouldBeEqual('interpolated-variable-2.sass'); }); From 32043631e002ab344a95d50f85cdafa8a8c81f4a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 19 May 2015 11:30:02 +0200 Subject: [PATCH 050/184] v3.1.0 --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32fb4e54..ab77f7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 3.1.0 - 2015-05-19 +**Thanks to +[@1000ch](https://github.com/1000ch), +[@alexeykuzmin](https://github.com/alexeykuzmin), +[@jonrohan](https://github.com/jonrohan)** +- Used new Gonzales PE API +- Fixed nested properties (#319) +- Added support for symlinked configs +- Added support for configs with any extension + ## 3.0.4 - 2014-11-15 **Thanks to [@gonzalocasas](https://github.com/gonzalocasas), diff --git a/package.json b/package.json index 78c45805..eff060fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.0.4", + "version": "3.1.0", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 3717cba80e19bf2fe230006fe1e254aaa4e53632 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 11:27:40 +0200 Subject: [PATCH 051/184] #378: Hack for braces in `space-between-declarations` --- lib/options/space-between-declarations.js | 2 ++ test/options/space-between-declarations/issue-378.css | 3 +++ test/options/space-between-declarations/test.js | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 test/options/space-between-declarations/issue-378.css diff --git a/lib/options/space-between-declarations.js b/lib/options/space-between-declarations.js index c85ee6a4..f9b5651c 100644 --- a/lib/options/space-between-declarations.js +++ b/lib/options/space-between-declarations.js @@ -66,6 +66,8 @@ module.exports = (function() { var value = this.getValue('space-between-declarations'); // TODO: Limit nodes to blocks, stylesheet, etc. + // XXX: Hack for braces + if (node.is('braces')) return; for (var i = 0, l = node.length; i < l; i++) { if (!node.get(i) || !node.get(i).is('declarationDelimiter')) continue; diff --git a/test/options/space-between-declarations/issue-378.css b/test/options/space-between-declarations/issue-378.css new file mode 100644 index 00000000..4c8dbfb6 --- /dev/null +++ b/test/options/space-between-declarations/issue-378.css @@ -0,0 +1,3 @@ +@media (min-width: 768px) { + body { background: red; } +} diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/test.js index 0434ed5d..016ec3ec 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/test.js @@ -38,4 +38,9 @@ describe('options/space-between-declarations:', function() { this.comb.configure({ 'space-between-declarations': '\n ' }); this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); }); + + it('Issue 378', function() { + this.comb.configure({ 'space-between-declarations': '\n' }); + this.shouldBeEqual('issue-378.css'); + }); }); From fec4ffa8ec2f32efbf2bb867a7e11cb23d72541a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 11:31:45 +0200 Subject: [PATCH 052/184] Clean up mantainers info --- package.json | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index eff060fa..ba9f7ea3 100644 --- a/package.json +++ b/package.json @@ -6,38 +6,33 @@ "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", "maintainers": [ - { - "name": "Mikhail Troshev", - "email": "mishanga@yandex-team.ru", - "web": "http://mishanga.pro/" - }, { "name": "Tony Ganch", "email": "tonyganch+github@gmail.com", "web": "http://tonyganch.com/" - }, - { - "name": "Slava Oliyanchuk", - "email": "miripiruni@gmail.com", - "web": "http://miripiruni.org/" } ], "contributors": [ { - "name": "Sergey Puzankov", - "email": "puzankov@yandex-team.ru" + "name": "Igor Novak", + "email": "bezengi@gmail.com" + }, + { + "name": "Roman Komarov", + "email": "kizmarh@ya.ru" }, { "name": "Denis Payase", "email": "lostsoul@yandex-team.ru" }, { - "name": "Igor Novak", - "email": "bezengi@gmail.com" + "name": "Mikhail Troshev", + "email": "mishanga@yandex-team.ru", + "web": "http://mishanga.pro/" }, { - "name": "Roman Komarov", - "email": "kizmarh@ya.ru" + "name": "Sergey Puzankov", + "email": "puzankov@yandex-team.ru" } ], "engines": { From 8846e813fbc51a7ffb56f619eead4ba5fcc76948 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 11:29:30 +0200 Subject: [PATCH 053/184] v3.1.1 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab77f7ff..03e83aa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.1 - 2015-05-20 +- Fixed `space-between-declarations` vs. media queries (#378) + ## 3.1.0 - 2015-05-19 **Thanks to [@1000ch](https://github.com/1000ch), diff --git a/package.json b/package.json index ba9f7ea3..d1088cba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.0", + "version": "3.1.1", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 0b8695cfee6915df74f0e940721a25e4e63f4f5e Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 14:33:46 +0200 Subject: [PATCH 054/184] #379: Fix processing of hashes --- lib/options/block-indent.js | 2 +- lib/options/space-before-closing-brace.js | 2 +- lib/options/space-before-opening-brace.js | 12 ++++++------ lib/options/space-between-declarations.js | 2 +- test/options/block-indent/issue-379.css | 3 +++ test/options/block-indent/issue-379.expected.css | 3 +++ test/options/block-indent/test.js | 5 +++++ 7 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 test/options/block-indent/issue-379.css create mode 100644 test/options/block-indent/issue-379.expected.css diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index 1547a454..3bc12aa4 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -6,7 +6,7 @@ module.exports = (function() { level = level || 0; // XXX: Hack for braces - if (node.is('braces')) return; + if (node.is('braces') || node.is('id')) return; for (var i = 0; i < node.length; i++) { var n = node.get(i); diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index 907dc3ed..ff81b260 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -19,7 +19,7 @@ module.exports = (function() { level = level || 0; // XXX: Hack for braces - if (x.is('braces')) return; + if (x.is('braces') || x.is('id')) return; x.forEach(function(node) { if (!node.is('block') && diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index b8209356..4d0622bf 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -35,10 +35,10 @@ module.exports = (function() { process: function(node) { var value = this.getValue('space-before-opening-brace'); - node.forEach(function(block, i) { - // XXX: Hack for braces - if (typeof block === 'string') return; + // XXX: Hack for braces + if (node.is('braces') || node.is('id')) return; + node.forEach(function(block, i) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; @@ -71,10 +71,10 @@ module.exports = (function() { detect: function(node) { var variants = []; - node.forEach(function(block, i) { - // XXX: Hack for braces - if (typeof block === 'string') return; + // XXX: Hack for braces + if (node.is('braces') || node.is('id')) return []; + node.forEach(function(block, i) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; diff --git a/lib/options/space-between-declarations.js b/lib/options/space-between-declarations.js index f9b5651c..cc0819d2 100644 --- a/lib/options/space-between-declarations.js +++ b/lib/options/space-between-declarations.js @@ -67,7 +67,7 @@ module.exports = (function() { // TODO: Limit nodes to blocks, stylesheet, etc. // XXX: Hack for braces - if (node.is('braces')) return; + if (node.is('braces') || node.is('id')) return; for (var i = 0, l = node.length; i < l; i++) { if (!node.get(i) || !node.get(i).is('declarationDelimiter')) continue; diff --git a/test/options/block-indent/issue-379.css b/test/options/block-indent/issue-379.css new file mode 100644 index 00000000..46ef2f74 --- /dev/null +++ b/test/options/block-indent/issue-379.css @@ -0,0 +1,3 @@ +.pageArea #header { +color: red; +} diff --git a/test/options/block-indent/issue-379.expected.css b/test/options/block-indent/issue-379.expected.css new file mode 100644 index 00000000..3708595d --- /dev/null +++ b/test/options/block-indent/issue-379.expected.css @@ -0,0 +1,3 @@ +.pageArea #header { + color: red; + } diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index e0a44618..746d0b32 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -24,6 +24,11 @@ describe('options/block-indent:', function() { this.shouldBeEqual('test.css', 'test-2.expected.css'); }); + it('Issue 379', function() { + this.comb.configure({ 'block-indent': 4 }); + this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); + }); + it('Should detect nothing with an empty block, test 1', function() { this.shouldDetect( ['block-indent'], From 6bcbfdab7d031f95529692a4de0f1e800adedcbd Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 14:34:51 +0200 Subject: [PATCH 055/184] v3.1.2 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03e83aa4..a147c6c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.2 - 2015-05-20 +- Fixed processing of hashes (#379) + ## 3.1.1 - 2015-05-20 - Fixed `space-between-declarations` vs. media queries (#378) diff --git a/package.json b/package.json index d1088cba..175297ec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.1", + "version": "3.1.2", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 155b38617ba93d7873044a0ad84f097d5f3a5ba5 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 22:07:30 +0200 Subject: [PATCH 056/184] #381: Combinators can go first within selectors --- lib/options/space-before-combinator.js | 10 +++++++++- test/options/space-before-combinator/issue-381.css | 5 +++++ test/options/space-before-combinator/test.js | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/options/space-before-combinator/issue-381.css diff --git a/lib/options/space-before-combinator.js b/lib/options/space-before-combinator.js index a3b95d25..1046092f 100644 --- a/lib/options/space-before-combinator.js +++ b/lib/options/space-before-combinator.js @@ -23,7 +23,15 @@ module.exports = { var value = this.getValue('space-before-combinator'); node.forEach(function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { + var notFirst = false; + + simpleSelector.forEach(function(n, i) { + if (!n.is('space') && !n.is('combinator')) notFirst = true; + + // If combinator is the first thing in selector, + // do not add extra spaces: + if (!n.is('combinator') || !notFirst) return; + if (simpleSelector.get(i - 1).is('space')) { simpleSelector.get(i - 1).content = value; } else { diff --git a/test/options/space-before-combinator/issue-381.css b/test/options/space-before-combinator/issue-381.css new file mode 100644 index 00000000..400e8737 --- /dev/null +++ b/test/options/space-before-combinator/issue-381.css @@ -0,0 +1,5 @@ +> .u-margins-off, +> .c-media > > *, +> .c-media-list > * > > * { + margin-top: 0; +} diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index 3883dba8..45c9780e 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -29,6 +29,11 @@ describe('options/space-before-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); + it.only('Issue 381', function() { + this.comb.configure({ 'space-before-combinator': ' ' }); + this.shouldBeEqual('issue-381.css'); + }); + it('Should detect no whitespaces before combinator', function() { this.shouldDetect( ['space-before-combinator'], From d84f7dae351c27dbffdcb341ad74e620345cea09 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 20 May 2015 22:11:07 +0200 Subject: [PATCH 057/184] v3.1.3 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a147c6c5..eb255023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.3 - 2015-05-20 +- Do not add extra space before combinators which go first in selectors (#381) + ## 3.1.2 - 2015-05-20 - Fixed processing of hashes (#379) diff --git a/package.json b/package.json index 175297ec..58f343db 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.2", + "version": "3.1.3", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 7940b30f7adac9872733b91eb716e9461a80587c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 22 May 2015 22:56:23 +0200 Subject: [PATCH 058/184] Uncomment tests --- test/options/space-before-combinator/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index 45c9780e..e30f1d10 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -29,7 +29,7 @@ describe('options/space-before-combinator:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it.only('Issue 381', function() { + it('Issue 381', function() { this.comb.configure({ 'space-before-combinator': ' ' }); this.shouldBeEqual('issue-381.css'); }); From d6d69a979d8530f7405736aa451b7bf682d6373a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 23 May 2015 16:48:01 +0200 Subject: [PATCH 059/184] #387: Fix `space-after-opening-brace` for empty media queries --- lib/options/space-after-opening-brace.js | 3 ++- test/options/space-after-opening-brace/issue-387.css | 1 + .../options/space-after-opening-brace/issue-387.expected.css | 2 ++ test/options/space-after-opening-brace/test.js | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/options/space-after-opening-brace/issue-387.css create mode 100644 test/options/space-after-opening-brace/issue-387.expected.css diff --git a/lib/options/space-after-opening-brace.js b/lib/options/space-after-opening-brace.js index 2fe353a6..f41f562b 100644 --- a/lib/options/space-after-opening-brace.js +++ b/lib/options/space-after-opening-brace.js @@ -23,7 +23,8 @@ module.exports = { var value = this.getValue('space-after-opening-brace'); - if (node.first().is('space')) { + if (node.first() && + node.first().is('space')) { node.first().content = value; } else if (value !== '') { var space = gonzales.createNode({ type: 'space', content: value }); diff --git a/test/options/space-after-opening-brace/issue-387.css b/test/options/space-after-opening-brace/issue-387.css new file mode 100644 index 00000000..3b66e1f1 --- /dev/null +++ b/test/options/space-after-opening-brace/issue-387.css @@ -0,0 +1 @@ +@media only screen (max-width:479px) {} diff --git a/test/options/space-after-opening-brace/issue-387.expected.css b/test/options/space-after-opening-brace/issue-387.expected.css new file mode 100644 index 00000000..aecde5a6 --- /dev/null +++ b/test/options/space-after-opening-brace/issue-387.expected.css @@ -0,0 +1,2 @@ +@media only screen (max-width:479px) { +} diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 7b9eb59a..4971c855 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -29,6 +29,11 @@ describe('options/space-after-opening-brace:', function() { this.shouldBeEqual('test.css', 'test-3.expected.css'); }); + it('Issue 387', function() { + this.comb.configure({ 'space-after-opening-brace': '\n' }); + this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); + }); + it('Should detect no whitespace', function() { this.shouldDetect( ['space-after-opening-brace'], From 467a58e435d75e0273a10b662a421da03bfcb6a4 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 23 May 2015 16:49:26 +0200 Subject: [PATCH 060/184] v3.1.4 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb255023..9f98634c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.4 - 2015-05-24 +- Fixed `space-after-opening-brace` option for empty media queries (#387) + ## 3.1.3 - 2015-05-20 - Do not add extra space before combinators which go first in selectors (#381) diff --git a/package.json b/package.json index 58f343db..0231364c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.3", + "version": "3.1.4", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From bc38b1dda5022f99e88625a1b08cb1890f6ad564 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 27 May 2015 11:45:03 +0200 Subject: [PATCH 061/184] Fix GPE version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0231364c..3db97c64 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "commander": "2.0.0", - "csscomb-core": "~3.0.0-1", - "gonzales-pe": "~3.0.0-10", + "csscomb-core": "3.0.0-3", + "gonzales-pe": "3.0.0-28", "vow": "0.4.4" }, "devDependencies": { From df7cf02730e7398ba428bb2027cbda5480eee517 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 27 May 2015 11:52:09 +0200 Subject: [PATCH 062/184] v3.1.5 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f98634c..ccf2d865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.5 - 2015-05-27 +- Fixed dependencies + ## 3.1.4 - 2015-05-24 - Fixed `space-after-opening-brace` option for empty media queries (#387) diff --git a/package.json b/package.json index 3db97c64..a8a660f5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.4", + "version": "3.1.5", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From d4b4375c0ad19899f55e28adf7351f7c276d652a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:00:44 +0300 Subject: [PATCH 063/184] Hotfix for #389 --- lib/options/unitless-zero.js | 16 +++++++++++++++- test/options/unitless-zero-less/issue-389.less | 4 ++++ test/options/unitless-zero-less/test.js | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/options/unitless-zero-less/issue-389.less create mode 100644 test/options/unitless-zero-less/test.js diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index 1f0a03ed..62bb9a0c 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -25,7 +25,21 @@ module.exports = { value.remove(1); } } else if (value.is('percentage')) { - var number = value.first('number').content; + // XXX(tonyganch): There is a bug in Gonzales when in Less, + // percentage's content is not wrapped as an array but actually + // type of node's content is object. This bug has already been + // fixed in newer versions of Gonzales so the issue should be + // gone after update of dependencies and csscomb@4.0 release. + // This hack is here as a hotfix for csscomb@3.1 and must be + // removed once csscom@4.0 is released. See #389. + var number; + if (!Array.isArray(value.content) && + value.content.is('number')) { + number = value.content; + } else { + number = value.first('number').content; + } + if (number[0] === '0') { value.type = 'number'; value.content = number; diff --git a/test/options/unitless-zero-less/issue-389.less b/test/options/unitless-zero-less/issue-389.less new file mode 100644 index 00000000..f0626d68 --- /dev/null +++ b/test/options/unitless-zero-less/issue-389.less @@ -0,0 +1,4 @@ +.test +{ + width: 100%; +} diff --git a/test/options/unitless-zero-less/test.js b/test/options/unitless-zero-less/test.js new file mode 100644 index 00000000..942206b9 --- /dev/null +++ b/test/options/unitless-zero-less/test.js @@ -0,0 +1,6 @@ +describe('options/unitless-zero (less)', function() { + it('Issue 389', function() { + this.comb.configure({ 'unitless-zero': true }); + this.shouldBeEqual('issue-389.less'); + }); +}); From 4ae9682d961a7349b51b5ea617f5ba26b8ed2bdc Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:03:00 +0300 Subject: [PATCH 064/184] v3.1.6 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccf2d865..e4656e15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.1.6 - 2015-06-09 +- Hotfix for issue when `unitless-zero` crashed on percentages in Less (#389) + ## 3.1.5 - 2015-05-27 - Fixed dependencies diff --git a/package.json b/package.json index a8a660f5..3a4039d9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.5", + "version": "3.1.6", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 1bac5dedfc62b2803ad0f641e5ed58ba016bc13d Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:16:46 +0300 Subject: [PATCH 065/184] Fix #394: unitless-zero vs fractions Don't remove units from values starting from zero, like `0.5em` --- lib/options/unitless-zero.js | 8 ++++---- test/options/unitless-zero/issue-394.css | 6 ++++++ test/options/unitless-zero/issue-394.expected.css | 6 ++++++ test/options/unitless-zero/test.js | 5 +++++ 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/options/unitless-zero/issue-394.css create mode 100644 test/options/unitless-zero/issue-394.expected.css diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index 62bb9a0c..a712efa7 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -20,7 +20,7 @@ module.exports = { if (value.is('dimension')) { var unit = value.first('ident').content; - if (value.first('number').content[0] === '0' && + if (value.first('number').content === '0' && UNITS.indexOf(unit) !== -1) { value.remove(1); } @@ -40,7 +40,7 @@ module.exports = { number = value.first('number').content; } - if (number[0] === '0') { + if (number === '0') { value.type = 'number'; value.content = number; } @@ -61,14 +61,14 @@ module.exports = { if (node.is('percentage') && node.first('number').content[1] === '0') { result = false; } else if (node.is('dimension') && - node.first('number').content[0] === '0' && + node.first('number').content === '0' && node.first('ident').content !== 'deg') { result = false; } // If we see a zero and previous node is not percentage or dimension, then we have an option if (node.is('number') && - node.content[0] === '0' && + node.content === '0' && this._prev !== 'percentage' && this._prev !== 'dimension') { result = true; diff --git a/test/options/unitless-zero/issue-394.css b/test/options/unitless-zero/issue-394.css new file mode 100644 index 00000000..065b1142 --- /dev/null +++ b/test/options/unitless-zero/issue-394.css @@ -0,0 +1,6 @@ +.example { + bottom: 0em; + left: 0.5em; + right: 1em; + top: 1.5em; +} diff --git a/test/options/unitless-zero/issue-394.expected.css b/test/options/unitless-zero/issue-394.expected.css new file mode 100644 index 00000000..dc9de0f0 --- /dev/null +++ b/test/options/unitless-zero/issue-394.expected.css @@ -0,0 +1,6 @@ +.example { + bottom: 0; + left: 0.5em; + right: 1em; + top: 1.5em; +} diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index f47be91d..f7c67c4c 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -35,6 +35,11 @@ describe('options/unitless-zero', function() { ); }); + it('Issue 394', function() { + this.comb.configure({ 'unitless-zero': true }); + this.shouldBeEqual('issue-394.css', 'issue-394.expected.css'); + }); + it('Should detect unitless zero option', function() { this.shouldDetect( ['unitless-zero'], From bd14cfb8b534d04cd5af42fa0ba7df1010f00e08 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:20:33 +0300 Subject: [PATCH 066/184] v3.1.7 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4656e15..794cec0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.1.7 - 2015-06-09 + +- Do not remove units from values starting from zeroes, like `0.5em` (#394) + ## 3.1.6 - 2015-06-09 - Hotfix for issue when `unitless-zero` crashed on percentages in Less (#389) diff --git a/package.json b/package.json index 3a4039d9..94352e3e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.6", + "version": "3.1.7", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 25f698e64c5e5c271fc2d73cb2cb7035ab1a8f70 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 19 May 2015 17:15:47 +0200 Subject: [PATCH 067/184] [cli] Support stdin (#351) --- lib/cli.js | 183 +++++++++++++++++++++++++++++++-------------------- package.json | 2 +- 2 files changed, 114 insertions(+), 71 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 0c99bd2e..9917f05a 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -2,99 +2,142 @@ * Command line implementation for CSSComb * * Usage example: - * ./node_modules/.bin/csscomb [options] file1 [dir1 [fileN [dirN]]] + * ./node_modules/.bin/csscomb [options] [file1 [dir1 [fileN [dirN]]]] */ var fs = require('fs'); +var parseArgs = require('minimist'); var path = require('path'); -var program = require('commander'); var vow = require('vow'); var Comb = require('./csscomb'); - -program - .version(require('../package.json').version) - .usage('[options] ') - .option('-v, --verbose', 'verbose mode') - .option('-c, --config [path]', 'configuration file path') - .option('-d, --detect', 'detect mode (would return detected options)') - .option('-l, --lint', 'in case some fixes needed returns an error') - .parse(process.argv); - -if (!program.args.length) { - console.log('No input paths specified'); - program.help(); -} - var comb = new Comb(); -if (program.detect) { - console.log(JSON.stringify(Comb.detectInFile(program.args[0]), false, 4)); - process.exit(0); -} +var getInputData = new vow.Promise(function(resolve) { + var input = ''; + process.stdin.resume(); + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function(data) { + input += data; + }); + process.stdin.on('end', function() { + resolve(input); + }); +}); -var config; -var configPath = program.config && - path.resolve(process.cwd(), program.config) || - Comb.getCustomConfigPath(); - -if (!fs.existsSync(configPath)) { - config = require('../config/csscomb.json'); -} else if (configPath.match(/\.css$/)) { - config = Comb.detectInFile(configPath); -} else { - config = Comb.getCustomConfig(configPath); +function processInputData(input) { + try { + process.stdout.write(comb.processString(input)); + process.exit(0); + } catch (e) { + process.stderr.write(e.message); + process.exit(1); + } } -if (!config) { - console.log('Configuration file ' + configPath + ' was not found.'); - process.exit(1); +function processSTDIN() { + getInputData.then(processInputData); } -if (config.template) { - if (fs.existsSync(config.template)) { - var templateConfig = Comb.detectInFile(config.template); - for (var attrname in templateConfig) { - if (!config[attrname]) { - config[attrname] = templateConfig[attrname]; - } +function processFiles(files, config) { + vow.all(files.map(comb.processPath.bind(comb))).then(function(c) { + c = c.filter(function(isChanged) { + return isChanged !== undefined; + }); + + var tbchanged = c.reduce(function(a, b) { + return a + b; + }); + + var changed = config.lint ? 0 : tbchanged; + + if (config.verbose) { + process.stdout.write('\n'); + process.stdout.write(c.length + ' file' + (c.length === 1 ? '' : 's') + ' processed\n'); + process.stdout.write(changed + ' file' + (changed === 1 ? '' : 's') + ' fixed\n'); + console.timeEnd('Time spent'); } - } else { - console.log('Template configuration file ' + config.template + ' was not found.'); + + if (config.lint && tbchanged) { + process.exit(1); + } + + process.exit(0); + }).fail(function(e) { + process.stderr.write(e.stack); process.exit(1); - } + }); } -console.time('spent'); - -config.verbose = program.verbose === true || config.verbose; -config.lint = program.lint; +function getOptions() { + var parserOptions = { + boolean: ['verbose', 'lint'], + alias: { + config: 'c', + detect: 'd', + lint: 'l', + verbose: 'v' + } + }; + return parseArgs(process.argv.slice(2), parserOptions); +} -comb.configure(config); +function applyTemplate(config) { + if (!config.template) return; -vow.all(program.args.map(comb.processPath.bind(comb))) -.then(function(changedFiles) { - changedFiles = [].concat.apply([], changedFiles) - .filter(function(isChanged) { - return isChanged !== undefined; - }); + if (!fs.existsSync(config.template)) { + process.stderr.write('Template configuration file ' + config.template + ' was not found.'); + process.exit(1); + } - for (var i = changedFiles.length, tbchanged = 0; i--;) { - tbchanged += changedFiles[i]; + var templateConfig = Comb.detectInFile(config.template); + for (var attrname in templateConfig) { + if (!config[attrname]) { + config[attrname] = templateConfig[attrname]; + } } +} - var changed = config.lint ? 0 : tbchanged; +function getConfig(options) { + var configPath = options.config && + path.resolve(process.cwd(), options.config) || + Comb.getCustomConfigPath(); - if (config.verbose) { - console.log(''); - console.log(changedFiles.length + ' file' + (changedFiles.length === 1 ? '' : 's') + ' processed'); - console.log(changed + ' file' + (changed === 1 ? '' : 's') + ' fixed'); - console.timeEnd('spent'); + var config; + if (!fs.existsSync(configPath)) { + config = require('../config/csscomb.json'); + } else if (configPath.match(/\.css$/)) { + config = Comb.detectInFile(configPath); + } else { + config = Comb.getCustomConfig(configPath); } - if (config.lint && tbchanged) { + if (!config) { + process.stderr.write('Configuration file ' + configPath + ' was not found.'); process.exit(1); } -}) -.fail(function(e) { - console.log('stack: ', e.stack); - process.exit(1); -}); + + applyTemplate(config); + if (options.verbose) config.verbose = options.verbose; + if (options.lint) config.lint = options.lint; + + return config; +} + +function detectConfig(file) { + var config = Comb.detectInFile(file); + config = JSON.stringify(config, false, 4); + process.stdout.write(config); + process.exit(0); +} + +console.time('Time spent'); + +var options = getOptions(); + +if (options.detect) { + detectConfig(options.detect); +} + +var config = getConfig(options); +comb.configure(config); + +process.stdin.isTTY ? processFiles(options._, config) : processSTDIN(); diff --git a/package.json b/package.json index 94352e3e..6f077410 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "node": ">= 0.10.0" }, "dependencies": { - "commander": "2.0.0", + "minimist": "1.1.x", "csscomb-core": "3.0.0-3", "gonzales-pe": "3.0.0-28", "vow": "0.4.4" From 82c78bc1011562efb0089d61c4cbaf7dbf9466c8 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 27 May 2015 11:56:37 +0200 Subject: [PATCH 068/184] [tools] Update dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6f077410..fe87cdf9 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "minimist": "1.1.x", - "csscomb-core": "3.0.0-3", - "gonzales-pe": "3.0.0-28", + "csscomb-core": "3.0.0-4", + "gonzales-pe": "3.0.0-29", "vow": "0.4.4" }, "devDependencies": { From 509bba59654ace2ffd177a7674313a39baa1b51f Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 26 May 2015 22:35:36 +0200 Subject: [PATCH 069/184] [gpe] Handle renaming of `braces` node --- lib/options/block-indent.js | 3 --- lib/options/space-before-closing-brace.js | 3 --- lib/options/space-before-opening-brace.js | 6 ------ lib/options/space-between-declarations.js | 3 --- lib/options/unitless-zero.js | 2 +- 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js index 3bc12aa4..f36f2634 100644 --- a/lib/options/block-indent.js +++ b/lib/options/block-indent.js @@ -5,9 +5,6 @@ module.exports = (function() { function processNode(node, level) { level = level || 0; - // XXX: Hack for braces - if (node.is('braces') || node.is('id')) return; - for (var i = 0; i < node.length; i++) { var n = node.get(i); if (!n) continue; diff --git a/lib/options/space-before-closing-brace.js b/lib/options/space-before-closing-brace.js index ff81b260..22f32970 100644 --- a/lib/options/space-before-closing-brace.js +++ b/lib/options/space-before-closing-brace.js @@ -18,9 +18,6 @@ module.exports = (function() { function processBlock(x, level) { level = level || 0; - // XXX: Hack for braces - if (x.is('braces') || x.is('id')) return; - x.forEach(function(node) { if (!node.is('block') && !node.is('atrulers')) return processBlock(node, level); diff --git a/lib/options/space-before-opening-brace.js b/lib/options/space-before-opening-brace.js index 4d0622bf..b4323585 100644 --- a/lib/options/space-before-opening-brace.js +++ b/lib/options/space-before-opening-brace.js @@ -35,9 +35,6 @@ module.exports = (function() { process: function(node) { var value = this.getValue('space-before-opening-brace'); - // XXX: Hack for braces - if (node.is('braces') || node.is('id')) return; - node.forEach(function(block, i) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; @@ -71,9 +68,6 @@ module.exports = (function() { detect: function(node) { var variants = []; - // XXX: Hack for braces - if (node.is('braces') || node.is('id')) return []; - node.forEach(function(block, i) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; diff --git a/lib/options/space-between-declarations.js b/lib/options/space-between-declarations.js index cc0819d2..6c3d57f3 100644 --- a/lib/options/space-between-declarations.js +++ b/lib/options/space-between-declarations.js @@ -66,9 +66,6 @@ module.exports = (function() { var value = this.getValue('space-between-declarations'); // TODO: Limit nodes to blocks, stylesheet, etc. - // XXX: Hack for braces - if (node.is('braces') || node.is('id')) return; - for (var i = 0, l = node.length; i < l; i++) { if (!node.get(i) || !node.get(i).is('declarationDelimiter')) continue; diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js index a712efa7..b1da0974 100644 --- a/lib/options/unitless-zero.js +++ b/lib/options/unitless-zero.js @@ -13,7 +13,7 @@ module.exports = { process: function(node) { var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - if (!node.is('value') && !node.is('braces')) return; + if (!node.is('value') && !node.is('parentheses')) return; node.forEach(function(value) { if (typeof value === 'string') return; From 0804608a8fd4d86ed09565bd390447aad36a32e2 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 27 May 2015 14:58:03 +0200 Subject: [PATCH 070/184] [tests] Group test cases into `process` and `detect` --- test/options/always-semicolon-less/test.js | 94 +++---- test/options/always-semicolon-sass/test.js | 6 +- test/options/always-semicolon-scss/test.js | 110 ++++---- test/options/always-semicolon/test.js | 217 +++++++-------- test/options/block-indent-sass/test.js | 24 +- test/options/block-indent-scss/test.js | 8 +- test/options/block-indent/test.js | 112 ++++---- test/options/color-case/test.js | 177 +++++++------ test/options/color-shorthand/test.js | 119 +++++---- test/options/element-case-scss/test.js | 8 +- test/options/element-case/test.js | 170 ++++++------ test/options/eof-newline/test.js | 122 +++++---- test/options/integral/test.js | 46 ++-- test/options/leading-zero/test.js | 86 +++--- test/options/quotes/test.js | 201 +++++++------- .../remove-empty-rulesets-less/test.js | 32 +-- .../remove-empty-rulesets-scss/test.js | 24 +- test/options/remove-empty-rulesets/test.js | 42 +-- test/options/sass/test.js | 198 +++++++------- test/options/sort-order-fallback/test.js | 54 ++-- test/options/sort-order-less/test.js | 156 +++++------ test/options/sort-order-sass/test.js | 144 +++++----- test/options/sort-order-scss/test.js | 208 +++++++-------- test/options/sort-order/test.js | 182 ++++++------- test/options/space-after-colon-sass/test.js | 16 +- test/options/space-after-colon-scss/test.js | 8 +- test/options/space-after-colon/test.js | 104 ++++---- test/options/space-after-combinator/test.js | 132 ++++----- .../options/space-after-opening-brace/test.js | 140 +++++----- .../test.js | 8 +- .../space-after-selector-delimiter/test.js | 132 ++++----- .../space-before-closing-brace/test.js | 118 +++++---- test/options/space-before-colon-sass/test.js | 16 +- test/options/space-before-colon/test.js | 104 ++++---- test/options/space-before-combinator/test.js | 140 +++++----- .../space-before-opening-brace-scss/test.js | 16 +- .../space-before-opening-brace/test.js | 140 +++++----- .../space-before-selector-delimiter/test.js | 132 ++++----- .../space-between-declarations/test.js | 88 +++--- test/options/strip-spaces/test.js | 204 +++++++------- test/options/tab-size/test.js | 24 +- test/options/unitless-zero/test.js | 183 +++++++------ test/options/vendor-prefix-align-sass/test.js | 12 +- test/options/vendor-prefix-align/test.js | 250 +++++++++--------- 44 files changed, 2316 insertions(+), 2191 deletions(-) diff --git a/test/options/always-semicolon-less/test.js b/test/options/always-semicolon-less/test.js index ef66fea0..250413a7 100644 --- a/test/options/always-semicolon-less/test.js +++ b/test/options/always-semicolon-less/test.js @@ -3,51 +3,53 @@ describe('options/always-semicolon (less)', function() { this.comb.configure({ 'always-semicolon': true }); }); - it('Should not add semicolon to condition (single-line style)', function() { - this.shouldBeEqual('condition.less'); - }); - - it('Should not add semicolon to condition (multi-line style)', function() { - this.shouldBeEqual('condition-multiline.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.shouldBeEqual('include-1.less', 'include-1.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.shouldBeEqual('include-2.less', 'include-2.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { - this.shouldBeEqual('include-3.less', 'include-3.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { - this.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { - this.shouldBeEqual('include-4.less', 'include-4.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { - this.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { - this.shouldBeEqual('include-5.less', 'include-5.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { - this.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); + describe('process', function() { + it('Should not add semicolon to condition (single-line style)', function() { + this.shouldBeEqual('condition.less'); + }); + + it('Should not add semicolon to condition (multi-line style)', function() { + this.shouldBeEqual('condition-multiline.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { + this.shouldBeEqual('include-1.less', 'include-1.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { + this.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { + this.shouldBeEqual('include-2.less', 'include-2.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { + this.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { + this.shouldBeEqual('include-3.less', 'include-3.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { + this.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { + this.shouldBeEqual('include-4.less', 'include-4.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { + this.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { + this.shouldBeEqual('include-5.less', 'include-5.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { + this.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); + }); }); }); diff --git a/test/options/always-semicolon-sass/test.js b/test/options/always-semicolon-sass/test.js index 76f57f5e..a649269a 100644 --- a/test/options/always-semicolon-sass/test.js +++ b/test/options/always-semicolon-sass/test.js @@ -3,7 +3,9 @@ describe('options/always-semicolon (sass)', function() { this.comb.configure({ 'always-semicolon': true }); }); - it('Should not add semicolon', function() { - this.shouldBeEqual('test.sass'); + describe('process', function() { + it('Should not add semicolon', function() { + this.shouldBeEqual('test.sass'); + }); }); }); diff --git a/test/options/always-semicolon-scss/test.js b/test/options/always-semicolon-scss/test.js index 97750487..52050721 100644 --- a/test/options/always-semicolon-scss/test.js +++ b/test/options/always-semicolon-scss/test.js @@ -3,59 +3,61 @@ describe('options/always-semicolon (scss)', function() { this.comb.configure({ 'always-semicolon': true }); }); - it('Should not add semicolon if last value is block (singl-line style)', function() { - this.shouldBeEqual('block-value.scss'); - }); - - it('Should not add semicolon if last value is block (multi-line style)', function() { - this.shouldBeEqual('block-value-multiline.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); - }); - - it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { - this.shouldBeEqual('block-include.scss'); - }); - - it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { - this.shouldBeEqual('block-include-multiline.scss'); - }); - - it('Should add semicolon to last extend if missing (single-line style)', function() { - this.shouldBeEqual('extend.scss', 'extend.expected.scss'); - }); - - it('Should add semicolon to last extend if missing (multi-line style)', function() { - this.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); - }); - - it('Should not add semicolon to condition (single-line style)', function() { - this.shouldBeEqual('condition.scss'); - }); - - it('Should not add semicolon to condition (multi-line style)', function() { - this.shouldBeEqual('condition-multiline.scss'); - }); - - it('Should not add semicolon to loop (single-line style)', function() { - this.shouldBeEqual('loop.scss'); - }); - - it('Should not add semicolon to loop (multi-line style)', function() { - this.shouldBeEqual('loop-multiline.scss'); + describe('process', function() { + it('Should not add semicolon if last value is block (singl-line style)', function() { + this.shouldBeEqual('block-value.scss'); + }); + + it('Should not add semicolon if last value is block (multi-line style)', function() { + this.shouldBeEqual('block-value-multiline.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { + this.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { + this.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { + this.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { + this.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); + }); + + it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { + this.shouldBeEqual('block-include.scss'); + }); + + it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { + this.shouldBeEqual('block-include-multiline.scss'); + }); + + it('Should add semicolon to last extend if missing (single-line style)', function() { + this.shouldBeEqual('extend.scss', 'extend.expected.scss'); + }); + + it('Should add semicolon to last extend if missing (multi-line style)', function() { + this.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); + }); + + it('Should not add semicolon to condition (single-line style)', function() { + this.shouldBeEqual('condition.scss'); + }); + + it('Should not add semicolon to condition (multi-line style)', function() { + this.shouldBeEqual('condition-multiline.scss'); + }); + + it('Should not add semicolon to loop (single-line style)', function() { + this.shouldBeEqual('loop.scss'); + }); + + it('Should not add semicolon to loop (multi-line style)', function() { + this.shouldBeEqual('loop-multiline.scss'); + }); }); }); diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js index a20f8d3f..bfba4938 100644 --- a/test/options/always-semicolon/test.js +++ b/test/options/always-semicolon/test.js @@ -1,125 +1,128 @@ var assert = require('assert'); describe('options/always-semicolon', function() { - it('Should add semicolon for last property if missing. Test 1', function() { - this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div { height: 0 }' - ), - 'div { height: 0; }' - ); - }); + describe('process', function() { + it('Should add semicolon for last property if missing. Test 1', function() { + this.comb.configure({ 'always-semicolon': true }); + assert.equal( + this.comb.processString( + 'div { height: 0 }' + ), + 'div { height: 0; }' + ); + }); - it('Should add semicolon for last property if missing. Test 2', function() { - this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\nheight: 0\n}' - ), - 'div {\nheight: 0;\n}' - ); - }); + it('Should add semicolon for last property if missing. Test 2', function() { + this.comb.configure({ 'always-semicolon': true }); + assert.equal( + this.comb.processString( + 'div {\nheight: 0\n}' + ), + 'div {\nheight: 0;\n}' + ); + }); - it('Should add semicolon for last property if missing. Test 3', function() { - this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {height: 0}' - ), - 'div {height: 0;}' - ); - }); + it('Should add semicolon for last property if missing. Test 3', function() { + this.comb.configure({ 'always-semicolon': true }); + assert.equal( + this.comb.processString( + 'div {height: 0}' + ), + 'div {height: 0;}' + ); + }); - it('Should add semicolon for last property if missing. Test 4', function() { - this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\nheight: 0 /* Comment */\n}' - ), - 'div {\nheight: 0; /* Comment */\n}' - ); - }); + it('Should add semicolon for last property if missing. Test 4', function() { + this.comb.configure({ 'always-semicolon': true }); + assert.equal( + this.comb.processString( + 'div {\nheight: 0 /* Comment */\n}' + ), + 'div {\nheight: 0; /* Comment */\n}' + ); + }); - it('Should add semicolon for last property if missing. Test 5', function() { - this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}' - ), - 'div {\ntop: 1px;\nheight: 0; /* 1comment */ /* 2comment */\n}' - ); + it('Should add semicolon for last property if missing. Test 5', function() { + this.comb.configure({ 'always-semicolon': true }); + assert.equal( + this.comb.processString( + 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}' + ), + 'div {\ntop: 1px;\nheight: 0; /* 1comment */ /* 2comment */\n}' + ); + }); }); - it('Should detect semicolon for last property. Test 1', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0 }', - { - 'always-semicolon': false - } - ); - }); + describe('detect', function() { + it('Should detect semicolon for last property. Test 1', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0 }', + { + 'always-semicolon': false + } + ); + }); - it('Should detect semicolon for last property. Test 2', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0; }', - { - 'always-semicolon': true - } - ); - }); + it('Should detect semicolon for last property. Test 2', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0; }', + { + 'always-semicolon': true + } + ); + }); - it('Should detect semicolon for last property. Test 3', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0; } div { height: 0 }', - { - 'always-semicolon': true - } - ); - }); + it('Should detect semicolon for last property. Test 3', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0; } div { height: 0 }', + { + 'always-semicolon': true + } + ); + }); - it('Should detect semicolon for last property. Test 4', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0 } div { height: 0; } div { height: 0 }', - { - 'always-semicolon': false - } - ); - }); + it('Should detect semicolon for last property. Test 4', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0 } div { height: 0; } div { height: 0 }', + { + 'always-semicolon': false + } + ); + }); - it('Should detect semicolon for last property. Test 5', function() { - this.shouldDetect( - ['always-semicolon'], - 'div {\nheight: 0 /* Comment */\n} ' + - 'div { height: 0; }' + - 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}', - { - 'always-semicolon': false - } - ); - }); + it('Should detect semicolon for last property. Test 5', function() { + this.shouldDetect( + ['always-semicolon'], + 'div {\nheight: 0 /* Comment */\n} ' + + 'div { height: 0; }' + + 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}', + { + 'always-semicolon': false + } + ); + }); - it('Should detect semicolon for last property. Test 6', function() { - this.shouldDetect( - ['always-semicolon'], - 'a{\n border:0;\n}', - { - 'always-semicolon': true - } - ); - }); + it('Should detect semicolon for last property. Test 6', function() { + this.shouldDetect( + ['always-semicolon'], + 'a{\n border:0;\n}', + { + 'always-semicolon': true + } + ); + }); - it('Should not detect semicolon for last property if there are no properties', function() { - this.shouldDetect( - ['always-semicolon'], - 'div {}', - {} - ); + it('Should not detect semicolon for last property if there are no properties', function() { + this.shouldDetect( + ['always-semicolon'], + 'div {}', + {} + ); + }); }); - }); diff --git a/test/options/block-indent-sass/test.js b/test/options/block-indent-sass/test.js index 182b5a99..4ac1a04f 100644 --- a/test/options/block-indent-sass/test.js +++ b/test/options/block-indent-sass/test.js @@ -1,17 +1,19 @@ describe('options/block-indent (sass):', function() { - it('First level ruleset\'s block', function() { - this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('block.sass', 'block.expected.sass'); - }); + describe('process', function() { + it('First level ruleset\'s block', function() { + this.comb.configure({ 'block-indent': 2 }); + this.shouldBeEqual('block.sass', 'block.expected.sass'); + }); - it('Nested ruleset', function() { - this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); - }); + it('Nested ruleset', function() { + this.comb.configure({ 'block-indent': 2 }); + this.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); + }); - it('Mixin', function() { - this.comb.configure({ 'block-indent': 4 }); - this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + it('Mixin', function() { + this.comb.configure({ 'block-indent': 4 }); + this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + }); }); }); diff --git a/test/options/block-indent-scss/test.js b/test/options/block-indent-scss/test.js index 41c19afd..acb3a17f 100644 --- a/test/options/block-indent-scss/test.js +++ b/test/options/block-indent-scss/test.js @@ -1,6 +1,8 @@ describe('options/block-indent (scss):', function() { - it('Issue 213', function() { - this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); + describe('process', function() { + it('Issue 213', function() { + this.comb.configure({ 'block-indent': 2 }); + this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); + }); }); }); diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index 746d0b32..c8000a0e 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -1,68 +1,72 @@ describe('options/block-indent:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'block-indent': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'block-indent': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'block-indent': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'block-indent': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'block-indent': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'block-indent': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper number of spaces', function() { - this.comb.configure({ 'block-indent': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper number of spaces', function() { + this.comb.configure({ 'block-indent': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value => should set proper number of spaces', function() { - this.comb.configure({ 'block-indent': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value => should set proper number of spaces', function() { + this.comb.configure({ 'block-indent': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Issue 379', function() { - this.comb.configure({ 'block-indent': 4 }); - this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); + it('Issue 379', function() { + this.comb.configure({ 'block-indent': 4 }); + this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); + }); }); - it('Should detect nothing with an empty block, test 1', function() { - this.shouldDetect( - ['block-indent'], - 'a{ }', - {} - ); - }); + describe('detect', function() { + it('Should detect nothing with an empty block, test 1', function() { + this.shouldDetect( + ['block-indent'], + 'a{ }', + {} + ); + }); - it('Should detect nothing with an empty block, test 2', function() { - this.shouldDetect( - ['block-indent'], - 'a{}', - {} - ); - }); + it('Should detect nothing with an empty block, test 2', function() { + this.shouldDetect( + ['block-indent'], + 'a{}', + {} + ); + }); - it('Should detect correct number of spaces', function() { - this.shouldDetect( - ['block-indent'], - 'a{\n top: 0;\n color: tomato;\n}', - { 'block-indent': ' ' } - ); - }); + it('Should detect correct number of spaces', function() { + this.shouldDetect( + ['block-indent'], + 'a{\n top: 0;\n color: tomato;\n}', + { 'block-indent': ' ' } + ); + }); - it('Should detect no indent for one-line code', function() { - this.shouldDetect( - ['block-indent'], - 'a{ top: 0; color: tomato; }', - {} - ); - }); + it('Should detect no indent for one-line code', function() { + this.shouldDetect( + ['block-indent'], + 'a{ top: 0; color: tomato; }', + {} + ); + }); - it('Valid string value => should set proper space after combnator', function() { - this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value => should set proper space after combnator', function() { + this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); }); diff --git a/test/options/color-case/test.js b/test/options/color-case/test.js index e94af2ff..b56713ed 100644 --- a/test/options/color-case/test.js +++ b/test/options/color-case/test.js @@ -1,102 +1,105 @@ var assert = require('assert'); describe('options/color-case', function() { - it('Should switch colors to upper case', function() { - this.comb.configure({ 'color-case': 'upper' }); - assert.equal( - this.comb.processString( - 'div { color: #fff }' - ), - 'div { color: #FFF }' - ); - }); - - it('Should switch colors to lower case', function() { - this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( + describe('process', function() { + it('Should switch colors to upper case', function() { + this.comb.configure({ 'color-case': 'upper' }); + assert.equal( + this.comb.processString( + 'div { color: #fff }' + ), 'div { color: #FFF }' - ), - 'div { color: #fff }' - ); - }); + ); + }); - it('Should switch color-case in complex rules', function() { - this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( - 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + - ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' - ), - 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat;' + - ' box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }' - ); - }); + it('Should switch colors to lower case', function() { + this.comb.configure({ 'color-case': 'lower' }); + assert.equal( + this.comb.processString( + 'div { color: #FFF }' + ), + 'div { color: #fff }' + ); + }); - it('Should not switch selector case', function() { - this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( - '#Header { color: #FFF }' - ), - '#Header { color: #fff }' - ); - }); + it('Should switch color-case in complex rules', function() { + this.comb.configure({ 'color-case': 'lower' }); + assert.equal( + this.comb.processString( + 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + + ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' + ), + 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat;' + + ' box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }' + ); + }); - it('Should detect uppercase color', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #F3F3F3 }', - { - 'color-case': 'upper' - } - ); + it('Should not switch selector case', function() { + this.comb.configure({ 'color-case': 'lower' }); + assert.equal( + this.comb.processString( + '#Header { color: #FFF }' + ), + '#Header { color: #fff }' + ); + }); }); - it('Should detect lowercase color', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #f6f6f6 }', - { - 'color-case': 'lower' - } - ); - }); + describe('detect', function() { + it('Should detect uppercase color', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #F3F3F3 }', + { + 'color-case': 'upper' + } + ); + }); - it('Should detect uppercase color in a shorthand', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #FFF }', - { - 'color-case': 'upper' - } - ); - }); + it('Should detect lowercase color', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #f6f6f6 }', + { + 'color-case': 'lower' + } + ); + }); - it('Should detect lowercase color in a shorthand', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #fff }', - { - 'color-case': 'lower' - } - ); - }); + it('Should detect uppercase color in a shorthand', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #FFF }', + { + 'color-case': 'upper' + } + ); + }); - it('Shouldn’t detect color case if it contains only digits', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #333 }', - {} - ); - }); + it('Should detect lowercase color in a shorthand', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #fff }', + { + 'color-case': 'lower' + } + ); + }); - it('Shouldn’t detect color case if it is in mixed case', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #fFfFfF }', - {} - ); - }); + it('Shouldn’t detect color case if it contains only digits', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #333 }', + {} + ); + }); + it('Shouldn’t detect color case if it is in mixed case', function() { + this.shouldDetect( + ['color-case'], + 'a { color: #fFfFfF }', + {} + ); + }); + }); }); diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/test.js index d1708c0c..0e791a29 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/test.js @@ -1,70 +1,73 @@ var assert = require('assert'); describe('options/color-shorthand', function() { - it('Should shrink hexadecimal colors to 3 symbols', function() { - this.comb.configure({ 'color-shorthand': true }); - assert.equal( - this.comb.processString( - 'div { color: #aabbcc }' - ), - 'div { color: #abc }' - ); - }); + describe('process', function() { + it('Should shrink hexadecimal colors to 3 symbols', function() { + this.comb.configure({ 'color-shorthand': true }); + assert.equal( + this.comb.processString( + 'div { color: #aabbcc }' + ), + 'div { color: #abc }' + ); + }); - it('Should expand hexadecimal colors to 6 symbols', function() { - this.comb.configure({ 'color-shorthand': false }); - assert.equal( - this.comb.processString( - 'div { color: #7ad }' - ), - 'div { color: #77aadd }' - ); - }); + it('Should expand hexadecimal colors to 6 symbols', function() { + this.comb.configure({ 'color-shorthand': false }); + assert.equal( + this.comb.processString( + 'div { color: #7ad }' + ), + 'div { color: #77aadd }' + ); + }); - it('Should save case while processing', function() { - this.comb.configure({ 'color-shorthand': true }); - assert.equal( - this.comb.processString( - 'div { color: #fFAafF }' - ), - 'div { color: #fAf }' - ); + it('Should save case while processing', function() { + this.comb.configure({ 'color-shorthand': true }); + assert.equal( + this.comb.processString( + 'div { color: #fFAafF }' + ), + 'div { color: #fAf }' + ); + }); }); + describe('detect', function() { + it('Should detect non-shorthanded color', function() { + this.shouldDetect( + ['color-shorthand'], + 'a { color: #FF33EE }', + { + 'color-shorthand': false + } + ); + }); - it('Should detect non-shorthanded color', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #FF33EE }', - { - 'color-shorthand': false - } - ); - }); - - it('Should detect shorthanded color', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #fff }', - { - 'color-shorthand': true - } - ); - }); + it('Should detect shorthanded color', function() { + this.shouldDetect( + ['color-shorthand'], + 'a { color: #fff }', + { + 'color-shorthand': true + } + ); + }); - it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #F3F3F3 }', - {} - ); - }); + it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { + this.shouldDetect( + ['color-shorthand'], + 'a { color: #F3F3F3 }', + {} + ); + }); - it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: rgba(0,0,0,0.5) }', - {} - ); + it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { + this.shouldDetect( + ['color-shorthand'], + 'a { color: rgba(0,0,0,0.5) }', + {} + ); + }); }); }); diff --git a/test/options/element-case-scss/test.js b/test/options/element-case-scss/test.js index c2402506..89a14e01 100644 --- a/test/options/element-case-scss/test.js +++ b/test/options/element-case-scss/test.js @@ -1,6 +1,8 @@ describe('options/element-case (scss):', function() { - it('Should not touch mixin names', function() { - this.comb.configure({ 'element-case': 'lower' }); - this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + describe('process', function() { + it('Should not touch mixin names', function() { + this.comb.configure({ 'element-case': 'lower' }); + this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + }); }); }); diff --git a/test/options/element-case/test.js b/test/options/element-case/test.js index fb95287c..4d6354c9 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/test.js @@ -1,99 +1,103 @@ var assert = require('assert'); describe('options/element-case', function() { - it('Invalid String should not change case of elements', function() { - this.comb.configure({ 'element-case': 'foobar' }); - assert.equal( - this.comb.processString( + describe('process', function() { + it('Invalid String should not change case of elements', function() { + this.comb.configure({ 'element-case': 'foobar' }); + assert.equal( + this.comb.processString( + 'LI a { color : red }' + ), 'LI a { color : red }' - ), - 'LI a { color : red }' - ); - }); + ); + }); - it('Should switch tag name to upper case', function() { - this.comb.configure({ 'element-case': 'upper' }); - assert.equal( - this.comb.processString( - 'div { color: #fff }' - ), - 'DIV { color: #fff }' - ); - }); + it('Should switch tag name to upper case', function() { + this.comb.configure({ 'element-case': 'upper' }); + assert.equal( + this.comb.processString( + 'div { color: #fff }' + ), + 'DIV { color: #fff }' + ); + }); - it('Should switch tag name to lower case', function() { - this.comb.configure({ 'element-case': 'lower' }); - assert.equal( - this.comb.processString( - 'DIV { color: #FFF }' - ), - 'div { color: #FFF }' - ); - }); + it('Should switch tag name to lower case', function() { + this.comb.configure({ 'element-case': 'lower' }); + assert.equal( + this.comb.processString( + 'DIV { color: #FFF }' + ), + 'div { color: #FFF }' + ); + }); - it('Should switch element-case in complex rules', function() { - this.comb.configure({ 'element-case': 'lower' }); - assert.equal( - this.comb.processString( - 'UL > LI > .foo:not(A) { color: red }' - ), - 'ul > li > .foo:not(a) { color: red }' - ); + it('Should switch element-case in complex rules', function() { + this.comb.configure({ 'element-case': 'lower' }); + assert.equal( + this.comb.processString( + 'UL > LI > .foo:not(A) { color: red }' + ), + 'ul > li > .foo:not(a) { color: red }' + ); + }); }); - it('Should detect lowercase elements', function() { - this.shouldDetect( - ['element-case'], - 'a { color: red }', - { - 'element-case': 'lower' - } - ); - }); + describe('detect', function() { + it('Should detect lowercase elements', function() { + this.shouldDetect( + ['element-case'], + 'a { color: red }', + { + 'element-case': 'lower' + } + ); + }); - it('Should detect uppercase elements', function() { - this.shouldDetect( - ['element-case'], - 'A { color: red }', - { - 'element-case': 'upper' - } - ); - }); + it('Should detect uppercase elements', function() { + this.shouldDetect( + ['element-case'], + 'A { color: red }', + { + 'element-case': 'upper' + } + ); + }); - it('Should detect lowercase elements in a long selector', function() { - this.shouldDetect( - ['element-case'], - 'ul li:not(:hover) A { color: red }', - { - 'element-case': 'lower' - } - ); - }); + it('Should detect lowercase elements in a long selector', function() { + this.shouldDetect( + ['element-case'], + 'ul li:not(:hover) A { color: red }', + { + 'element-case': 'lower' + } + ); + }); - it('Should detect uppercase elements in a long selector', function() { - this.shouldDetect( - ['element-case'], - 'ul .lol:not(LI) A { color: red }', - { - 'element-case': 'upper' - } - ); - }); + it('Should detect uppercase elements in a long selector', function() { + this.shouldDetect( + ['element-case'], + 'ul .lol:not(LI) A { color: red }', + { + 'element-case': 'upper' + } + ); + }); - it('Shouldn’t detect case of elements in a mixed case', function() { - this.shouldDetect( - ['element-case'], - 'aRtIcLe { color: red }', - {} - ); - }); + it('Shouldn’t detect case of elements in a mixed case', function() { + this.shouldDetect( + ['element-case'], + 'aRtIcLe { color: red }', + {} + ); + }); - it('Shouldn’t detect case of elements when there are no such', function() { - this.shouldDetect( - ['element-case'], - '*.lol { color: red }', - {} - ); + it('Shouldn’t detect case of elements when there are no such', function() { + this.shouldDetect( + ['element-case'], + '*.lol { color: red }', + {} + ); + }); }); }); diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/test.js index ead5fcf1..d8436cea 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/test.js @@ -1,69 +1,75 @@ var assert = require('assert'); describe('options/eof-newline', function() { - it('Invalid value should not change trim trailing brac', function() { - this.comb.configure({ 'eof-newline': 'foobar' }); - assert.equal( - this.comb.processString('a { color: red } \n'), - 'a { color: red } \n' - ); - }); - it('Boolean true value should insert line-break at eof', function() { - this.comb.configure({ 'eof-newline': true }); - assert.equal( - this.comb.processString( - 'a {color:red} ' - ), - 'a {color:red} \n' - ); - }); - it('Boolean false value should remove line-break from eof', function() { - this.comb.configure({ 'eof-newline': false }); - assert.equal( - this.comb.processString( + describe('process', function() { + it('Invalid value should not change trim trailing brac', function() { + this.comb.configure({ 'eof-newline': 'foobar' }); + assert.equal( + this.comb.processString('a { color: red } \n'), + 'a { color: red } \n' + ); + }); + + it('Boolean true value should insert line-break at eof', function() { + this.comb.configure({ 'eof-newline': true }); + assert.equal( + this.comb.processString( + 'a {color:red} ' + ), 'a {color:red} \n' - ), - 'a {color:red} ' - ); - }); + ); + }); - it('Shouldn’t detect eof newline', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red }', - { - 'eof-newline': false - } - ); + it('Boolean false value should remove line-break from eof', function() { + this.comb.configure({ 'eof-newline': false }); + assert.equal( + this.comb.processString( + 'a {color:red} \n' + ), + 'a {color:red} ' + ); + }); }); - it('Should detect eof newline', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red }\n', - { - 'eof-newline': true - } - ); - }); + describe('detect', function() { + it('Shouldn’t detect eof newline', function() { + this.shouldDetect( + ['eof-newline'], + 'a { color: red }', + { + 'eof-newline': false + } + ); + }); - it('Shouldn’t detect eof newline with spaces at the end', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red } ', - { - 'eof-newline': false - } - ); - }); + it('Should detect eof newline', function() { + this.shouldDetect( + ['eof-newline'], + 'a { color: red }\n', + { + 'eof-newline': true + } + ); + }); + + it('Shouldn’t detect eof newline with spaces at the end', function() { + this.shouldDetect( + ['eof-newline'], + 'a { color: red } ', + { + 'eof-newline': false + } + ); + }); - it('Should detect eof newline with mixed spaces at the end', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red } \n ', - { - 'eof-newline': true - } - ); + it('Should detect eof newline with mixed spaces at the end', function() { + this.shouldDetect( + ['eof-newline'], + 'a { color: red } \n ', + { + 'eof-newline': true + } + ); + }); }); }); diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 0fe73731..2138309b 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,30 +1,34 @@ var assert = require('assert'); describe('integral test', function() { - it('Process result must be equal to expected.css', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('integral.css', 'integral.expected.css'); - }); + describe('process', function() { + it('Process result must be equal to expected.css', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('integral.css', 'integral.expected.css'); + }); - it('Issue 252', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); - }); + it('Issue 252', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); + }); - it('Issue 374', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('issue-374.css'); + it('Issue 374', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-374.css'); + }); }); - it('Should detect everything in integral test', function() { - var input = this.readFile('integral.expected.css'); - // Clone the required config object, otherwise other tests would fail - var expected = JSON.parse(JSON.stringify(this.Comb.getConfig('csscomb'))); - delete expected['sort-order']; - delete expected['exclude']; - this.shouldDetect(undefined, input, expected); + describe('detect', function() { + it('Should detect everything in integral test', function() { + var input = this.readFile('integral.expected.css'); + // Clone the required config object, otherwise other tests would fail + var expected = JSON.parse(JSON.stringify(this.Comb.getConfig('csscomb'))); + delete expected['sort-order']; + delete expected['exclude']; + this.shouldDetect(undefined, input, expected); + }); }); }); diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/test.js index dbd5c2b8..d6ecff7d 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/test.js @@ -1,51 +1,55 @@ var assert = require('assert'); describe('options/leading-zero', function() { - it('Should add leading zero in dimensions', function() { - this.comb.configure({ 'leading-zero': true }); - assert.equal( - this.comb.processString( - 'div { margin: .5em }' - ), - 'div { margin: 0.5em }' - ); - }); - - it('Should remove leading zero in dimensions', function() { - this.comb.configure({ 'leading-zero': false }); - assert.equal( - this.comb.processString( + describe('process', function() { + it('Should add leading zero in dimensions', function() { + this.comb.configure({ 'leading-zero': true }); + assert.equal( + this.comb.processString( + 'div { margin: .5em }' + ), 'div { margin: 0.5em }' - ), - 'div { margin: .5em }' - ); - }); + ); + }); - it('Should detect leading zero option', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: 0.5em }', - { - 'leading-zero': true - } - ); + it('Should remove leading zero in dimensions', function() { + this.comb.configure({ 'leading-zero': false }); + assert.equal( + this.comb.processString( + 'div { margin: 0.5em }' + ), + 'div { margin: .5em }' + ); + }); }); - it('Should detect leading zero option set to false', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: .5em }', - { - 'leading-zero': false - } - ); - }); + describe('detect', function() { + it('Should detect leading zero option', function() { + this.shouldDetect( + ['leading-zero'], + 'a { width: 0.5em }', + { + 'leading-zero': true + } + ); + }); + + it('Should detect leading zero option set to false', function() { + this.shouldDetect( + ['leading-zero'], + 'a { width: .5em }', + { + 'leading-zero': false + } + ); + }); - it('Shouldn’t detect leading zero option', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: 10.5em }', - {} - ); + it('Shouldn’t detect leading zero option', function() { + this.shouldDetect( + ['leading-zero'], + 'a { width: 10.5em }', + {} + ); + }); }); }); diff --git a/test/options/quotes/test.js b/test/options/quotes/test.js index 5ed3a898..e9088289 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/test.js @@ -1,120 +1,123 @@ var assert = require('assert'); describe('options/quotes', function() { - it('Invalid String should not change quotes', function() { - this.comb.configure({ quotes: 3 }); - assert.equal( - this.comb.processString( + describe('process', function() { + it('Invalid String should not change quotes', function() { + this.comb.configure({ quotes: 3 }); + assert.equal( + this.comb.processString( + 'a { content: "" }' + + 'b { content: \'\' }' + ), 'a { content: "" }' + 'b { content: \'\' }' - ), - 'a { content: "" }' + - 'b { content: \'\' }' - ); - }); + ); + }); - it('`single` value should set the quotes to single', function() { - this.comb.configure({ quotes: 'single' }); - assert.equal( - this.comb.processString( - 'a { content: "" }' + + it('`single` value should set the quotes to single', function() { + this.comb.configure({ quotes: 'single' }); + assert.equal( + this.comb.processString( + 'a { content: "" }' + + 'b { content: \'\' }' + ), + 'a { content: \'\' }' + 'b { content: \'\' }' - ), - 'a { content: \'\' }' + - 'b { content: \'\' }' - ); - }); + ); + }); - it('`double` value should set the quotes to double', function() { - this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( + it('`double` value should set the quotes to double', function() { + this.comb.configure({ quotes: 'double' }); + assert.equal( + this.comb.processString( + 'a { content: "" }' + + 'b { content: \'\' }' + ), 'a { content: "" }' + - 'b { content: \'\' }' - ), - 'a { content: "" }' + - 'b { content: "" }' - ); - }); + 'b { content: "" }' + ); + }); - it('`double` value should set the quotes to double in attrs and urls', function() { - this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( - 'a[class^=\'foo\'] { background: url(\'foo.png\') }' - ), - 'a[class^="foo"] { background: url("foo.png") }' - ); - }); + it('`double` value should set the quotes to double in attrs and urls', function() { + this.comb.configure({ quotes: 'double' }); + assert.equal( + this.comb.processString( + 'a[class^=\'foo\'] { background: url(\'foo.png\') }' + ), + 'a[class^="foo"] { background: url("foo.png") }' + ); + }); - it('`double` value should escape the unescaped double quotes on change', function() { - this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( + it('`double` value should escape the unescaped double quotes on change', function() { + this.comb.configure({ quotes: 'double' }); + assert.equal( + this.comb.processString( + 'a { content: "\\"" }' + + 'b { content: \'"\' }' + ), 'a { content: "\\"" }' + - 'b { content: \'"\' }' - ), - 'a { content: "\\"" }' + - 'b { content: "\\"" }' - ); - }); - + 'b { content: "\\"" }' + ); + }); - it('`single` value should unescape the escaped double quotes on change', function() { - this.comb.configure({ quotes: 'single' }); - assert.equal( - this.comb.processString( - 'a { content: "\\"" }' - ), - 'a { content: \'"\' }' - ); + it('`single` value should unescape the escaped double quotes on change', function() { + this.comb.configure({ quotes: 'single' }); + assert.equal( + this.comb.processString( + 'a { content: "\\"" }' + ), + 'a { content: \'"\' }' + ); + }); }); - it('Should not detect quotes when there are none', function() { - this.shouldDetect( - ['quotes'], - 'a { color:red }', - {} - ); - }); + describe('detect', function() { + it('Should not detect quotes when there are none', function() { + this.shouldDetect( + ['quotes'], + 'a { color:red }', + {} + ); + }); - it('Should detect double quotes', function() { - this.shouldDetect( - ['quotes'], - 'a { content: "foo" }', - { - quotes: 'double' - } - ); - }); + it('Should detect double quotes', function() { + this.shouldDetect( + ['quotes'], + 'a { content: "foo" }', + { + quotes: 'double' + } + ); + }); - it('Should detect single quotes', function() { - this.shouldDetect( - ['quotes'], - 'a { content: \'foo\' }', - { - quotes: 'single' - } - ); - }); + it('Should detect single quotes', function() { + this.shouldDetect( + ['quotes'], + 'a { content: \'foo\' }', + { + quotes: 'single' + } + ); + }); - it('Should detect single quotes in attribute', function() { - this.shouldDetect( - ['quotes'], - 'a[class^=\'foo\'] { color: red }', - { - quotes: 'single' - } - ); - }); + it('Should detect single quotes in attribute', function() { + this.shouldDetect( + ['quotes'], + 'a[class^=\'foo\'] { color: red }', + { + quotes: 'single' + } + ); + }); - it('Should detect double quotes in url', function() { - this.shouldDetect( - ['quotes'], - 'a { background: url("foo.png") }', - { - quotes: 'double' - } - ); + it('Should detect double quotes in url', function() { + this.shouldDetect( + ['quotes'], + 'a { background: url("foo.png") }', + { + quotes: 'double' + } + ); + }); }); }); diff --git a/test/options/remove-empty-rulesets-less/test.js b/test/options/remove-empty-rulesets-less/test.js index a031071d..a867d677 100644 --- a/test/options/remove-empty-rulesets-less/test.js +++ b/test/options/remove-empty-rulesets-less/test.js @@ -1,23 +1,25 @@ var assert = require('assert'); describe('options/remove-empty-rulesets (less):', function() { - it('Issue 201. Test 1', function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - this.shouldBeEqual('1.less', '1.expected.less'); - }); + describe('process', function() { + it('Issue 201. Test 1', function() { + this.comb.configure({ 'remove-empty-rulesets': true }); + this.shouldBeEqual('1.less', '1.expected.less'); + }); - it('Issue 201. Test 2', function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - var string = '#a {#b {} #d {}}'; - assert.equal(this.comb.processString(string, { syntax: 'less' }), ''); - }); + it('Issue 201. Test 2', function() { + this.comb.configure({ 'remove-empty-rulesets': true }); + var string = '#a {#b {} #d {}}'; + assert.equal(this.comb.processString(string, { syntax: 'less' }), ''); + }); - it('Issue 201. Test 3', function() { - this.comb.configure({ - 'remove-empty-rulesets': false, - 'always-semicolon': true + it('Issue 201. Test 3', function() { + this.comb.configure({ + 'remove-empty-rulesets': false, + 'always-semicolon': true + }); + var string = '#a {#b {} #d {}}'; + assert.equal(this.comb.processString(string, { syntax: 'less' }), string); }); - var string = '#a {#b {} #d {}}'; - assert.equal(this.comb.processString(string, { syntax: 'less' }), string); }); }); diff --git a/test/options/remove-empty-rulesets-scss/test.js b/test/options/remove-empty-rulesets-scss/test.js index de898210..9ee6ec9f 100644 --- a/test/options/remove-empty-rulesets-scss/test.js +++ b/test/options/remove-empty-rulesets-scss/test.js @@ -3,19 +3,21 @@ describe('options/remove-empty-rulesets (scss)', function() { this.comb.configure({ 'remove-empty-rulesets': true }); }); - it('Should not remove rulesets which contain only includes', function() { - this.shouldBeEqual('include.scss'); - }); + describe('process', function() { + it('Should not remove rulesets which contain only includes', function() { + this.shouldBeEqual('include.scss'); + }); - it('Should remove rulesets with contain only empty nested rules', function() { - this.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); - }); + it('Should remove rulesets with contain only empty nested rules', function() { + this.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); + }); - it('Should not remove rulesets with non-empty nested rules. Test 1', function() { - this.shouldBeEqual('nested-rule-1.scss'); - }); + it('Should not remove rulesets with non-empty nested rules. Test 1', function() { + this.shouldBeEqual('nested-rule-1.scss'); + }); - it('Should not remove rulesets with non-empty nested rules. Test 2', function() { - this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + it('Should not remove rulesets with non-empty nested rules. Test 2', function() { + this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + }); }); }); diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/test.js index a516227c..fcaa253c 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/test.js @@ -1,34 +1,36 @@ var assert = require('assert'); describe('options/remove-empty-rulesets', function() { - it('Configured with invalid value, should not remove empty ruleset', function() { - this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); - assert.equal(this.comb.processString('a { width: 10px; } b {}'), 'a { width: 10px; } b {}'); - }); - - describe('configured with Boolean "true" value', function() { - beforeEach(function() { - this.comb.configure({ 'remove-empty-rulesets': true }); + describe('process', function() { + it('Configured with invalid value, should not remove empty ruleset', function() { + this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); + assert.equal(this.comb.processString('a { width: 10px; } b {}'), 'a { width: 10px; } b {}'); }); - it('should remove empty ruleset', function() { - assert.equal(this.comb.processString(' b {} '), ' '); - }); + describe('configured with Boolean "true" value', function() { + beforeEach(function() { + this.comb.configure({ 'remove-empty-rulesets': true }); + }); - it('should remove ruleset with spaces', function() { - assert.equal(this.comb.processString(' b { } '), ' '); - }); + it('should remove empty ruleset', function() { + assert.equal(this.comb.processString(' b {} '), ' '); + }); - it('should leave ruleset with declarations', function() { - assert.equal(this.comb.processString('a { width: 10px; }\nb {} '), 'a { width: 10px; }\n '); - }); + it('should remove ruleset with spaces', function() { + assert.equal(this.comb.processString(' b { } '), ' '); + }); + + it('should leave ruleset with declarations', function() { + assert.equal(this.comb.processString('a { width: 10px; }\nb {} '), 'a { width: 10px; }\n '); + }); - it('should leave ruleset with comments', function() { - assert.equal(this.comb.processString('a { /* comment */ }\nb {} '), 'a { /* comment */ }\n '); + it('should leave ruleset with comments', function() { + assert.equal(this.comb.processString('a { /* comment */ }\nb {} '), 'a { /* comment */ }\n '); + }); }); }); - describe('detecting the value', function() { + describe('detect', function() { it('Should detect this option set to `true`', function() { this.shouldDetect( ['remove-empty-rulesets'], diff --git a/test/options/sass/test.js b/test/options/sass/test.js index 054ab9dd..f587c366 100644 --- a/test/options/sass/test.js +++ b/test/options/sass/test.js @@ -3,104 +3,106 @@ describe('Sass', function() { this.comb.configure({}); }); - it('Should parse nested rules', function() { - this.shouldBeEqual('nested-rule.sass'); - }); - - it('Should parse parent selector &', function() { - this.shouldBeEqual('parent-selector.sass'); - }); - - it('Should parse nested properties', function() { - this.shouldBeEqual('nested-property.sass'); - }); - - it('Should parse variables', function() { - this.shouldBeEqual('variable.sass'); - }); - - it('Should parse interpolated variables inside selectors', function() { - this.shouldBeEqual('interpolated-variable-1.sass'); - }); - - it('Should parse interpolated variables inside values', function() { - this.shouldBeEqual('interpolated-variable-2.sass'); - }); - - it('Should parse defaults', function() { - this.shouldBeEqual('default.sass'); - }); - - it('Should parse @import', function() { - this.shouldBeEqual('import.sass'); - }); - - it('Should parse @include', function() { - this.shouldBeEqual('include.sass'); - }); - - it('Should parse nested @media', function() { - this.shouldBeEqual('nested-media.sass'); - }); - - it('Should parse @extend with classes', function() { - this.shouldBeEqual('extend-1.sass'); - }); - - it('Should parse @extend with placeholders', function() { - this.shouldBeEqual('extend-2.sass'); - }); - - it('Should parse @warn', function() { - this.shouldBeEqual('warn.sass'); - }); - - it('Should parse @if', function() { - this.shouldBeEqual('if.sass'); - }); - - it('Should parse @if and @else', function() { - this.shouldBeEqual('if-else.sass'); - }); - - it('Should parse @if and @else if', function() { - this.shouldBeEqual('if-else-if.sass'); - }); - - it('Should parse @for', function() { - this.shouldBeEqual('for.sass'); - }); - - it('Should parse @each', function() { - this.shouldBeEqual('each.sass'); - }); - - it('Should parse @while', function() { - this.shouldBeEqual('while.sass'); - }); - - it('Should parse mixins', function() { - this.shouldBeEqual('mixin-1.sass'); - }); - - it('Should parse passing several variables to a mixin', function() { - this.shouldBeEqual('mixin-2.sass'); - }); - - it('Should parse passing a list of variables to a mixin', function() { - this.shouldBeEqual('mixin-3.sass'); - }); - - it('Should parse passing a content block to a mixin', function() { - this.shouldBeEqual('mixin-4.sass'); - }); - - it('Should parse @content', function() { - this.shouldBeEqual('content.sass'); - }); - - it('Should parse functions', function() { - this.shouldBeEqual('function.sass'); + describe('process', function() { + it('Should parse nested rules', function() { + this.shouldBeEqual('nested-rule.sass'); + }); + + it('Should parse parent selector &', function() { + this.shouldBeEqual('parent-selector.sass'); + }); + + it('Should parse nested properties', function() { + this.shouldBeEqual('nested-property.sass'); + }); + + it('Should parse variables', function() { + this.shouldBeEqual('variable.sass'); + }); + + it('Should parse interpolated variables inside selectors', function() { + this.shouldBeEqual('interpolated-variable-1.sass'); + }); + + it('Should parse interpolated variables inside values', function() { + this.shouldBeEqual('interpolated-variable-2.sass'); + }); + + it('Should parse defaults', function() { + this.shouldBeEqual('default.sass'); + }); + + it('Should parse @import', function() { + this.shouldBeEqual('import.sass'); + }); + + it('Should parse @include', function() { + this.shouldBeEqual('include.sass'); + }); + + it('Should parse nested @media', function() { + this.shouldBeEqual('nested-media.sass'); + }); + + it('Should parse @extend with classes', function() { + this.shouldBeEqual('extend-1.sass'); + }); + + it('Should parse @extend with placeholders', function() { + this.shouldBeEqual('extend-2.sass'); + }); + + it('Should parse @warn', function() { + this.shouldBeEqual('warn.sass'); + }); + + it('Should parse @if', function() { + this.shouldBeEqual('if.sass'); + }); + + it('Should parse @if and @else', function() { + this.shouldBeEqual('if-else.sass'); + }); + + it('Should parse @if and @else if', function() { + this.shouldBeEqual('if-else-if.sass'); + }); + + it('Should parse @for', function() { + this.shouldBeEqual('for.sass'); + }); + + it('Should parse @each', function() { + this.shouldBeEqual('each.sass'); + }); + + it('Should parse @while', function() { + this.shouldBeEqual('while.sass'); + }); + + it('Should parse mixins', function() { + this.shouldBeEqual('mixin-1.sass'); + }); + + it('Should parse passing several variables to a mixin', function() { + this.shouldBeEqual('mixin-2.sass'); + }); + + it('Should parse passing a list of variables to a mixin', function() { + this.shouldBeEqual('mixin-3.sass'); + }); + + it('Should parse passing a content block to a mixin', function() { + this.shouldBeEqual('mixin-4.sass'); + }); + + it('Should parse @content', function() { + this.shouldBeEqual('content.sass'); + }); + + it('Should parse functions', function() { + this.shouldBeEqual('function.sass'); + }); }); }); diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index 1262c177..d4efede9 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -1,32 +1,34 @@ describe('options/sort-order-fallback', function() { - it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { - var config = { - 'sort-order-fallback': 'abc', - 'sort-order': [ - ['top', 'left'], - ['...'], - ['color'] - ] - }; - this.comb.configure(config); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + describe('process', function() { + it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { + var config = { + 'sort-order-fallback': 'abc', + 'sort-order': [ + ['top', 'left'], + ['...'], + ['color'] + ] + }; + this.comb.configure(config); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should sort unknown properties alphabetically if `sort-order-fallback` is set', function() { - var config = { - 'sort-order-fallback': 'abc', - 'sort-order': ['top', 'left'] - }; - this.comb.configure(config); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Should sort unknown properties alphabetically if `sort-order-fallback` is set', function() { + var config = { + 'sort-order-fallback': 'abc', + 'sort-order': ['top', 'left'] + }; + this.comb.configure(config); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { - var config = { - 'sort-order': ['top', 'left'] - }; - this.comb.configure(config); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { + var config = { + 'sort-order': ['top', 'left'] + }; + this.comb.configure(config); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); }); diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index 69208169..c00dfbc7 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -1,92 +1,94 @@ describe('options/sort-order (less)', function() { - it('Should sort properties inside rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('rule.less', 'rule.expected.less'); - }); + describe('process', function() { + it('Should sort properties inside rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('rule.less', 'rule.expected.less'); + }); - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); - }); + it('Should sort properties inside nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); + }); - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - this.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); - }); + it('Should sort properties divided by nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'left', 'color'] + ] }); + this.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); + }); - it('Should group declarations with proper comments and spaces (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); - }); + it('Should group declarations with proper comments and spaces (single line)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); + }); - it('Should group declarations with proper comments and spaces (multiple lines). Test 1', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); - }); + it('Should group declarations with proper comments and spaces (multiple lines). Test 1', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); + }); - it('Should group declarations with proper comments and spaces (multiple lines). Test 2', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); - }); + it('Should group declarations with proper comments and spaces (multiple lines). Test 2', function() { + this.comb.configure({ 'sort-order': [ + ['$variable', 'color'] + ] }); + this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + }); - it('Should group declarations with proper comments and spaces (multiple lines). Test 3', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); - }); + it('Should group declarations with proper comments and spaces (multiple lines). Test 3', function() { + this.comb.configure({ 'sort-order': [ + ['$variable', 'color'] + ] }); + this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + }); - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - this.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); - }); + it('Should divide properties from different groups with an empty line', function() { + this.comb.configure({ 'sort-order': [ + ['top'], ['color'] + ] }); + this.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); + }); - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - this.shouldBeEqual('variable.less', 'variable.expected.less'); - }); + it('Should sort variables', function() { + this.comb.configure({ 'sort-order': [ + ['$variable', 'color'] + ] }); + this.shouldBeEqual('variable.less', 'variable.expected.less'); + }); - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - this.shouldBeEqual('import.less', 'import.expected.less'); - }); + it('Should sort imports', function() { + this.comb.configure({ 'sort-order': [ + ['$import', 'color'] + ] }); + this.shouldBeEqual('import.less', 'import.expected.less'); + }); - it('Should sort included mixins. Test 1', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color', 'border-top', 'border-bottom'] - ] }); - this.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); - }); + it('Should sort included mixins. Test 1', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'color', 'border-top', 'border-bottom'] + ] }); + this.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); + }); - it('Should sort included mixins. Test 2', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'top', 'color'] - ] }); - this.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); - }); + it('Should sort included mixins. Test 2', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'top', 'color'] + ] }); + this.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); + }); - it('Should sort included mixins. Test 3', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'border', 'color'] - ] }); - this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); + it('Should sort included mixins. Test 3', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'border', 'color'] + ] }); + this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); + }); }); }); diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 6348c10d..bb914968 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -1,85 +1,87 @@ describe('options/sort-order (sass)', function() { - it('Should sort properties inside rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('rule.sass', 'rule.expected.sass'); - }); + describe('process', function() { + it('Should sort properties inside rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('rule.sass', 'rule.expected.sass'); + }); - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); - }); + it('Should sort properties inside nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); + }); - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - this.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); - }); + it('Should sort properties divided by nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'left', 'color'] + ] }); + this.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); + }); - it('Should group declarations with proper comments and spaces (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('comments.sass', 'comments.expected.sass'); - }); + it('Should group declarations with proper comments and spaces (multiple lines)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('comments.sass', 'comments.expected.sass'); + }); - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - this.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); - }); + it('Should divide properties from different groups with an empty line', function() { + this.comb.configure({ 'sort-order': [ + ['top'], ['color'] + ] }); + this.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); + }); - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - this.shouldBeEqual('variable.sass', 'variable.expected.sass'); - }); + it('Should sort variables', function() { + this.comb.configure({ 'sort-order': [ + ['$variable', 'color'] + ] }); + this.shouldBeEqual('variable.sass', 'variable.expected.sass'); + }); - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - this.shouldBeEqual('import.sass', 'import.expected.sass'); - }); + it('Should sort imports', function() { + this.comb.configure({ 'sort-order': [ + ['$import', 'color'] + ] }); + this.shouldBeEqual('import.sass', 'import.expected.sass'); + }); - it('Should sort @include-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - this.shouldBeEqual('include.sass', 'include.expected.sass'); - }); + it('Should sort @include-s', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'color'] + ] }); + this.shouldBeEqual('include.sass', 'include.expected.sass'); + }); - it('Should sort @extend-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - this.shouldBeEqual('extend.sass', 'extend.expected.sass'); - }); + it('Should sort @extend-s', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'color'] + ] }); + this.shouldBeEqual('extend.sass', 'extend.expected.sass'); + }); - it('Should sort properties inside blocks passed to mixins', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); - }); + it('Should sort properties inside blocks passed to mixins', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + }); - it('Should handle properties preceeding rulesets', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - this.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); - }); + it('Should handle properties preceeding rulesets', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'left', 'color'] + ] }); + this.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); + }); - it('Should handle properties preceeding conditions', function() { - this.comb.configure({ 'sort-order': [ - ['font-size', 'display', 'top', 'color'] - ] }); - this.shouldBeEqual('condition.sass', 'condition.expected.sass'); + it('Should handle properties preceeding conditions', function() { + this.comb.configure({ 'sort-order': [ + ['font-size', 'display', 'top', 'color'] + ] }); + this.shouldBeEqual('condition.sass', 'condition.expected.sass'); + }); }); }); diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 66a7d7df..8b71de48 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -1,122 +1,124 @@ describe('options/sort-order (scss)', function() { - it('Should sort properties inside rules (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('rule.scss', 'rule.expected.scss'); - }); + describe('process', function() { + it('Should sort properties inside rules (single line)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('rule.scss', 'rule.expected.scss'); + }); - it('Should sort properties inside rules (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('rule.scss', 'rule.expected.scss'); - }); + it('Should sort properties inside rules (multiple lines)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('rule.scss', 'rule.expected.scss'); + }); - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); - }); + it('Should sort properties inside nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); + }); - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); - }); + it('Should sort properties divided by nested rules', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'left', 'color'] + ] }); + this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + }); - it('Should group declarations with proper comments and spaces (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); - }); + it('Should group declarations with proper comments and spaces (multiple lines)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); + }); - it('Should group declarations with proper comments and spaces (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); - }); + it('Should group declarations with proper comments and spaces (single line)', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); + }); - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - this.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); - }); + it('Should divide properties from different groups with an empty line', function() { + this.comb.configure({ 'sort-order': [ + ['top'], ['color'] + ] }); + this.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); + }); - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - this.shouldBeEqual('variable.scss', 'variable.expected.scss'); - }); + it('Should sort variables', function() { + this.comb.configure({ 'sort-order': [ + ['$variable', 'color'] + ] }); + this.shouldBeEqual('variable.scss', 'variable.expected.scss'); + }); - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - this.shouldBeEqual('import.scss', 'import.expected.scss'); - }); + it('Should sort imports', function() { + this.comb.configure({ 'sort-order': [ + ['$import', 'color'] + ] }); + this.shouldBeEqual('import.scss', 'import.expected.scss'); + }); - it('Should sort @include-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - this.shouldBeEqual('include.scss', 'include.expected.scss'); - }); + it('Should sort @include-s', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'color'] + ] }); + this.shouldBeEqual('include.scss', 'include.expected.scss'); + }); - it('Should sort @extend-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - this.shouldBeEqual('extend.scss', 'extend.expected.scss'); - }); + it('Should sort @extend-s', function() { + this.comb.configure({ 'sort-order': [ + ['$include', 'color'] + ] }); + this.shouldBeEqual('extend.scss', 'extend.expected.scss'); + }); - it('Should sort properties inside blocks passed to mixins', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); - }); + it('Should sort properties inside blocks passed to mixins', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'color'] + ] }); + this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + }); - it('Should handle properties preceeding rulesets', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - this.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); - }); + it('Should handle properties preceeding rulesets', function() { + this.comb.configure({ 'sort-order': [ + ['top', 'left', 'color'] + ] }); + this.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); + }); - it('Should handle properties preceeding conditions', function() { - this.comb.configure({ 'sort-order': [ - ['font-size', 'display', 'top', 'color'] - ] }); - this.shouldBeEqual('condition.scss', 'condition.expected.scss'); - }); + it('Should handle properties preceeding conditions', function() { + this.comb.configure({ 'sort-order': [ + ['font-size', 'display', 'top', 'color'] + ] }); + this.shouldBeEqual('condition.scss', 'condition.expected.scss'); + }); - it('Should sort complex case with leftovers', function() { - this.comb.configure({ - "sort-order": [ - ["$variable"], - ["position"], - ["...", "border"], - ["$include"], - ["font"] - ] - }); - this.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); - }); + it('Should sort complex case with leftovers', function() { + this.comb.configure({ + "sort-order": [ + ["$variable"], + ["position"], + ["...", "border"], + ["$include"], + ["font"] + ] + }); + this.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); + }); - it('Issue 317', function() { - this.comb.configure({ 'sort-order': ['...'] }); - this.shouldBeEqual('issue-317.scss'); - }); + it('Issue 317', function() { + this.comb.configure({ 'sort-order': ['...'] }); + this.shouldBeEqual('issue-317.scss'); + }); - it('Issue 333', function() { - this.comb.configure({ 'sort-order': ['...'] }); - this.shouldBeEqual('issue-333.scss'); + it('Issue 333', function() { + this.comb.configure({ 'sort-order': ['...'] }); + this.shouldBeEqual('issue-333.scss'); + }); }); }); diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index f313817a..a0719ee3 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -1,111 +1,113 @@ var assert = require('assert'); describe('options/sort-order', function() { - it('Should be in expected order in case properties are not grouped', function() { - this.comb.configure({ 'sort-order': ['position', 'z-index'] }); - this.shouldBeEqual('single-group.css', 'single-group.expected.css'); - }); - - it('Should be in expected order in case of 1 group', function() { - this.comb.configure({ 'sort-order': [ - ['position', 'z-index'] - ] }); - this.shouldBeEqual('single-group.css', 'single-group.expected.css'); - }); + describe('process', function() { + it('Should be in expected order in case properties are not grouped', function() { + this.comb.configure({ 'sort-order': ['position', 'z-index'] }); + this.shouldBeEqual('single-group.css', 'single-group.expected.css'); + }); - it('Shuld be in expected order in case of multiple groups', function() { - this.comb.configure({ 'sort-order': [ - ['position', 'z-index'], - ['width', 'height'] - ] }); - this.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); + it('Should be in expected order in case of 1 group', function() { + this.comb.configure({ 'sort-order': [ + ['position', 'z-index'] + ] }); + this.shouldBeEqual('single-group.css', 'single-group.expected.css'); + }); - }); + it('Shuld be in expected order in case of multiple groups', function() { + this.comb.configure({ 'sort-order': [ + ['position', 'z-index'], + ['width', 'height'] + ] }); + this.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); - it('Should work correctly with comments in case of 1 group', function() { - this.comb.configure({ 'sort-order': [ - ['border-bottom', 'font-style'], - ] }); - this.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); - }); + }); - it('Should work correctly with comments in case of multiple groups', function() { - this.comb.configure({ 'sort-order': [ - ['margin'], - ['padding'] - ] }); - this.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); - }); + it('Should work correctly with comments in case of 1 group', function() { + this.comb.configure({ 'sort-order': [ + ['border-bottom', 'font-style'], + ] }); + this.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); + }); - it('Should parse semicolons inside data uri correctly', function() { - this.comb.configure({ - 'sort-order': [ - ['position', 'background', 'color'] - ] + it('Should work correctly with comments in case of multiple groups', function() { + this.comb.configure({ 'sort-order': [ + ['margin'], + ['padding'] + ] }); + this.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); }); - this.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); - }); - it('Should not add more than 1 line between groups', function() { - var input = this.readFile('multiple-groups-2.css'); - var expected = this.readFile('multiple-groups-2.expected.css'); - this.comb.configure({ - 'sort-order': [ - ['top'], ['color'] - ] + it('Should parse semicolons inside data uri correctly', function() { + this.comb.configure({ + 'sort-order': [ + ['position', 'background', 'color'] + ] + }); + this.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); }); - for (var i = 6; i--;) { - input = this.comb.processString(input); - } - assert.equal(input, expected); - }); + it('Should not add more than 1 line between groups', function() { + var input = this.readFile('multiple-groups-2.css'); + var expected = this.readFile('multiple-groups-2.expected.css'); + this.comb.configure({ + 'sort-order': [ + ['top'], ['color'] + ] + }); + + for (var i = 6; i--;) { + input = this.comb.processString(input); + } + assert.equal(input, expected); + }); - it('Issue 94. Test 1', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); - }); + it('Issue 94. Test 1', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); + }); - it('Issue 94. Test 2', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); - }); + it('Issue 94. Test 2', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); + }); - it('Issue 94. Test 3', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); - }); + it('Issue 94. Test 3', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); + }); - it('Should place the leftovers in the end', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); - }); + it('Should place the leftovers in the end', function() { + var config = this.Comb.getConfig('csscomb'); + this.comb.configure(config); + this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); + }); - it('Should place the leftovers in the beginning', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][0].unshift(['...']); - this.comb.configure(config); - this.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css'); - config['sort-order'][0].shift(); - }); + it('Should place the leftovers in the beginning', function() { + var config = this.Comb.getConfig('csscomb'); + config['sort-order'][0].unshift(['...']); + this.comb.configure(config); + this.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css'); + config['sort-order'][0].shift(); + }); - it('Should place the leftovers in the beginning of its group', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][1].unshift('...'); - this.comb.configure(config); - this.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css'); - config['sort-order'][1].shift(); - }); + it('Should place the leftovers in the beginning of its group', function() { + var config = this.Comb.getConfig('csscomb'); + config['sort-order'][1].unshift('...'); + this.comb.configure(config); + this.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css'); + config['sort-order'][1].shift(); + }); - it('Should place the leftovers in the middle of its group', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][1].splice(1, 0, '...'); - this.comb.configure(config); - this.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css'); - config['sort-order'][1].splice(1, 1); + it('Should place the leftovers in the middle of its group', function() { + var config = this.Comb.getConfig('csscomb'); + config['sort-order'][1].splice(1, 0, '...'); + this.comb.configure(config); + this.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css'); + config['sort-order'][1].splice(1, 1); + }); }); }); diff --git a/test/options/space-after-colon-sass/test.js b/test/options/space-after-colon-sass/test.js index d85412d9..bf7c9383 100644 --- a/test/options/space-after-colon-sass/test.js +++ b/test/options/space-after-colon-sass/test.js @@ -1,11 +1,13 @@ describe('options/space-after-colon (sass):', function() { - it('Should set proper space if colon is after property name', function() { - this.comb.configure({ 'space-after-colon': 2 }); - this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); - }); + describe('process', function() { + it('Should set proper space if colon is after property name', function() { + this.comb.configure({ 'space-after-colon': 2 }); + this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); + }); - it('Should not change space after colon which is before property name', function() { - this.comb.configure({ 'space-after-colon': 1 }); - this.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); + it('Should not change space after colon which is before property name', function() { + this.comb.configure({ 'space-after-colon': 1 }); + this.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); + }); }); }); diff --git a/test/options/space-after-colon-scss/test.js b/test/options/space-after-colon-scss/test.js index b95d7f5d..b1d55398 100644 --- a/test/options/space-after-colon-scss/test.js +++ b/test/options/space-after-colon-scss/test.js @@ -1,6 +1,8 @@ describe('options/space-after-colon (scss):', function() { - it('Space after colon should not affect pseudo elements', function() { - this.comb.configure({ 'space-after-colon': 1 }); - this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); + describe('process', function() { + it('Space after colon should not affect pseudo elements', function() { + this.comb.configure({ 'space-after-colon': 1 }); + this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); + }); }); }); diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/test.js index 8a6873d9..81af81b8 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/test.js @@ -1,64 +1,68 @@ describe('options/space-after-colon:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-after-colon': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-after-colon': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-after-colon': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space after colon', function() { + this.comb.configure({ 'space-after-colon': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only)=> should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only)=> should set proper space after colon', function() { + this.comb.configure({ 'space-after-colon': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spacesand newlines)=> should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spacesand newlines)=> should set proper space after colon', function() { + this.comb.configure({ 'space-after-colon': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespaces', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color:red }', - { 'space-after-colon': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespaces', function() { + this.shouldDetect( + ['space-after-colon'], + 'a { color:red }', + { 'space-after-colon': '' } + ); + }); - it('Should detect space from two variants', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color: red; color :red }', - { 'space-after-colon': ' ' } - ); - }); + it('Should detect space from two variants', function() { + this.shouldDetect( + ['space-after-colon'], + 'a { color: red; color :red }', + { 'space-after-colon': ' ' } + ); + }); - it('Should detect no whitespaces along three variants', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color: red; background :red } b { width:10px }', - { 'space-after-colon': '' } - ); - }); + it('Should detect no whitespaces along three variants', function() { + this.shouldDetect( + ['space-after-colon'], + 'a { color: red; background :red } b { width:10px }', + { 'space-after-colon': '' } + ); + }); - it('Should detect space', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color : red; background :red } b { width: 10px }', - { 'space-after-colon': ' ' } - ); + it('Should detect space', function() { + this.shouldDetect( + ['space-after-colon'], + 'a { color : red; background :red } b { width: 10px }', + { 'space-after-colon': ' ' } + ); + }); }); }); diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/test.js index 7d085b48..364546fe 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/test.js @@ -1,80 +1,84 @@ describe('options/space-after-combinator:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-after-combinator': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-after-combinator': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-after-combinator': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space after combinator', function() { + this.comb.configure({ 'space-after-combinator': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space after combinator', function() { + this.comb.configure({ 'space-after-combinator': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spaces and newlines) => should set proper space after combinator', function() { + this.comb.configure({ 'space-after-combinator': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespaces after combinator', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a+b { color:red }', - { 'space-after-combinator': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespaces after combinator', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a+b { color:red }', + { 'space-after-combinator': '' } + ); + }); - it('Should detect a space after combinator', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a + \n b { color:red }', - { 'space-after-combinator': ' \n ' } - ); - }); + it('Should detect a space after combinator', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a + \n b { color:red }', + { 'space-after-combinator': ' \n ' } + ); + }); - it('Should detect a space after combinator in long selector', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a + b ~ c>d { color:red }', - { 'space-after-combinator': ' ' } - ); - }); + it('Should detect a space after combinator in long selector', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a + b ~ c>d { color:red }', + { 'space-after-combinator': ' ' } + ); + }); - it('Should detect a space after combinator in long selector, test 2', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a>b + c + d { color:red }', - { 'space-after-combinator': ' ' } - ); - }); + it('Should detect a space after combinator in long selector, test 2', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a>b + c + d { color:red }', + { 'space-after-combinator': ' ' } + ); + }); - it('Should detect no whitespaces after combinator in long selector', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a+b ~ c+d { color:red }', - { 'space-after-combinator': '' } - ); - }); + it('Should detect no whitespaces after combinator in long selector', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a+b ~ c+d { color:red }', + { 'space-after-combinator': '' } + ); + }); - it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a { color:red }', - {} - ); + it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { + this.shouldDetect( + ['space-after-combinator'], + 'a { color:red }', + {} + ); + }); }); }); diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 4971c855..5c6ea5c0 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -1,85 +1,89 @@ describe('options/space-after-opening-brace:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-after-opening-brace': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-after-opening-brace': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space after {', function() { + this.comb.configure({ 'space-after-opening-brace': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space after {', function() { + this.comb.configure({ 'space-after-opening-brace': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Valid string value (spaces and newlines) => should set proper space after {', function() { + this.comb.configure({ 'space-after-opening-brace': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Issue 387', function() { - this.comb.configure({ 'space-after-opening-brace': '\n' }); - this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); + it('Issue 387', function() { + this.comb.configure({ 'space-after-opening-brace': '\n' }); + this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); + }); }); - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0}', - { 'space-after-opening-brace': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespace', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0}', + { 'space-after-opening-brace': '' } + ); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{\n\ttop:0}', - { 'space-after-opening-brace': '\n\t' } - ); - }); + it('Should detect whitespace', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{\n\ttop:0}', + { 'space-after-opening-brace': '\n\t' } + ); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0} b{\n left:0}', - { 'space-after-opening-brace': '' } - ); - }); + it('Should detect no whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0} b{\n left:0}', + { 'space-after-opening-brace': '' } + ); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{ top:0 } b{left:0}', - { 'space-after-opening-brace': ' ' } - ); - }); + it('Should detect whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{ top:0 } b{left:0}', + { 'space-after-opening-brace': ' ' } + ); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0} b { left: 0 } c{\n\tright:0}', - { 'space-after-opening-brace': '' } - ); - }); + it('Should detect no whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0} b { left: 0 } c{\n\tright:0}', + { 'space-after-opening-brace': '' } + ); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{\ntop:0} b{\nleft:0} c{\n right:0}', - { 'space-after-opening-brace': '\n' } - ); + it('Should detect whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-after-opening-brace'], + 'a{\ntop:0} b{\nleft:0} c{\n right:0}', + { 'space-after-opening-brace': '\n' } + ); + }); }); }); diff --git a/test/options/space-after-selector-delimiter-sass/test.js b/test/options/space-after-selector-delimiter-sass/test.js index c0c10e9f..e748c540 100644 --- a/test/options/space-after-selector-delimiter-sass/test.js +++ b/test/options/space-after-selector-delimiter-sass/test.js @@ -1,6 +1,8 @@ describe('options/space-after-selector-delimiter (sass):', function() { - it('Issue 238', function() { - this.comb.configure({ 'space-after-selector-delimiter': '\n' }); - this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); + describe('process', function() { + it('Issue 238', function() { + this.comb.configure({ 'space-after-selector-delimiter': '\n' }); + this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); + }); }); }); diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/test.js index 3eb3b1b0..15128e18 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -1,79 +1,83 @@ describe('options/space-after-selector-delimiter:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-after-selector-delimiter': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-after-selector-delimiter': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space after selector delimiter', function() { + this.comb.configure({ 'space-after-selector-delimiter': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space after selector delimiter', function() { + this.comb.configure({ 'space-after-selector-delimiter': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spaces and newlines) => should set proper space after selector delimiter', function() { + this.comb.configure({ 'space-after-selector-delimiter': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespace', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0}', + { 'space-after-selector-delimiter': '' } + ); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, \n b {top:0}', - { 'space-after-selector-delimiter': ' \n ' } - ); - }); + it('Should detect whitespace', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a, \n b {top:0}', + { 'space-after-selector-delimiter': ' \n ' } + ); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0} a, b{left:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + it('Should detect no whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0} a, b{left:0}', + { 'space-after-selector-delimiter': '' } + ); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, b {top:0} b,a{left:0}', - { 'space-after-selector-delimiter': ' ' } - ); - }); + it('Should detect whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a, b {top:0} b,a{left:0}', + { 'space-after-selector-delimiter': ' ' } + ); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, b{top:0} b,c{left:0} c,d{right:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + it('Should detect no whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a, b{top:0} b,c{left:0} c,d{right:0}', + { 'space-after-selector-delimiter': '' } + ); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0} b, c{left:0} c, sd{right:0}', - { 'space-after-selector-delimiter': ' ' } - ); + it('Should detect whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0} b, c{left:0} c, sd{right:0}', + { 'space-after-selector-delimiter': ' ' } + ); + }); }); }); diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/test.js index d8d0a62a..6ece137a 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/test.js @@ -1,72 +1,76 @@ describe('options/space-before-closing-brace:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-before-closing-brace': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-before-closing-brace': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space before }', function() { + this.comb.configure({ 'space-before-closing-brace': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space before }', function() { + this.comb.configure({ 'space-before-closing-brace': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spaces and newlines) => should set proper space before }', function() { + this.comb.configure({ 'space-before-closing-brace': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a{top:0}', - { 'space-before-closing-brace': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespace', function() { + this.shouldDetect( + ['space-before-closing-brace'], + 'a{top:0}', + { 'space-before-closing-brace': '' } + ); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a{top:0} b { color: tomato; }', - { 'space-before-closing-brace': '' } - ); - }); + it('Should detect no whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-closing-brace'], + 'a{top:0} b { color: tomato; }', + { 'space-before-closing-brace': '' } + ); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a { top:0 }', - { 'space-before-closing-brace': ' ' } - ); - }); + it('Should detect whitespace', function() { + this.shouldDetect( + ['space-before-closing-brace'], + 'a { top:0 }', + { 'space-before-closing-brace': ' ' } + ); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a { top:0 } b{color:tomato;}', - { 'space-before-closing-brace': ' ' } - ); - }); + it('Should detect whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-closing-brace'], + 'a { top:0 } b{color:tomato;}', + { 'space-before-closing-brace': ' ' } + ); + }); - it('Should detect whitespace (mix with block indent)', function() { - this.shouldDetect( - ['space-before-closing-brace', 'block-indent'], - 'a {\n top:0\n }\nb{\n color:tomato;\n }', - { 'block-indent': ' ', 'space-before-closing-brace': '\n ' } - ); + it('Should detect whitespace (mix with block indent)', function() { + this.shouldDetect( + ['space-before-closing-brace', 'block-indent'], + 'a {\n top:0\n }\nb{\n color:tomato;\n }', + { 'block-indent': ' ', 'space-before-closing-brace': '\n ' } + ); + }); }); }); diff --git a/test/options/space-before-colon-sass/test.js b/test/options/space-before-colon-sass/test.js index d9380d5e..70f21859 100644 --- a/test/options/space-before-colon-sass/test.js +++ b/test/options/space-before-colon-sass/test.js @@ -1,12 +1,14 @@ describe('options/space-before-colon-sass:', function() { - it('Should correct space', function() { - this.comb.configure({ 'space-before-colon': 1 }); - this.shouldBeEqual('test.sass', 'test.expected.sass'); - }); + describe('process', function() { + it('Should correct space', function() { + this.comb.configure({ 'space-before-colon': 1 }); + this.shouldBeEqual('test.sass', 'test.expected.sass'); + }); - it('Should not correct space', function() { - this.comb.configure({ 'space-before-colon': 1 }); - this.shouldBeEqual('test2.sass'); + it('Should not correct space', function() { + this.comb.configure({ 'space-before-colon': 1 }); + this.shouldBeEqual('test2.sass'); + }); }); }); diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/test.js index c545d0c8..e4acb58c 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/test.js @@ -1,64 +1,68 @@ describe('options/space-before-colon:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-before-colon': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-before-colon': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-before-colon': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space before colon', function() { + this.comb.configure({ 'space-before-colon': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space before colon', function() { + this.comb.configure({ 'space-before-colon': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spaces and newlines) => should set proper space before colon', function() { + this.comb.configure({ 'space-before-colon': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespaces', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color:red }', - { 'space-before-colon': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespaces', function() { + this.shouldDetect( + ['space-before-colon'], + 'a { color:red }', + { 'space-before-colon': '' } + ); + }); - it('Should detect no space from two variants', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color: red; color :red }', - { 'space-before-colon': '' } - ); - }); + it('Should detect no space from two variants', function() { + this.shouldDetect( + ['space-before-colon'], + 'a { color: red; color :red }', + { 'space-before-colon': '' } + ); + }); - it('Should detect no whitespaces along three variants', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color: red; background :red } b { width:10px }', - { 'space-before-colon': '' } - ); - }); + it('Should detect no whitespaces along three variants', function() { + this.shouldDetect( + ['space-before-colon'], + 'a { color: red; background :red } b { width:10px }', + { 'space-before-colon': '' } + ); + }); - it('Should detect space', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color : red; background :red } b { width:10px }', - { 'space-before-colon': ' ' } - ); + it('Should detect space', function() { + this.shouldDetect( + ['space-before-colon'], + 'a { color : red; background :red } b { width:10px }', + { 'space-before-colon': ' ' } + ); + }); }); }); diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index e30f1d10..4292210d 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -1,85 +1,89 @@ describe('options/space-before-combinator:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-before-combinator': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-before-combinator': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-before-combinator': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space before combinator', function() { + this.comb.configure({ 'space-before-combinator': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space before combinator', function() { + this.comb.configure({ 'space-before-combinator': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Valid string value (spaces and newlines) => should set proper space before combinator', function() { + this.comb.configure({ 'space-before-combinator': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Issue 381', function() { - this.comb.configure({ 'space-before-combinator': ' ' }); - this.shouldBeEqual('issue-381.css'); + it('Issue 381', function() { + this.comb.configure({ 'space-before-combinator': ' ' }); + this.shouldBeEqual('issue-381.css'); + }); }); - it('Should detect no whitespaces before combinator', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a+b { color:red }', - { 'space-before-combinator': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespaces before combinator', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a+b { color:red }', + { 'space-before-combinator': '' } + ); + }); - it('Should detect a space before combinator', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a + b { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Should detect a space before combinator', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a + b { color:red }', + { 'space-before-combinator': ' ' } + ); + }); - it('Should detect a space before combinator in long selector', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a + b ~ c>d { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Should detect a space before combinator in long selector', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a + b ~ c>d { color:red }', + { 'space-before-combinator': ' ' } + ); + }); - it('Should detect a space before combinator in long selector, test 2', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a>b + c + d { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Should detect a space before combinator in long selector, test 2', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a>b + c + d { color:red }', + { 'space-before-combinator': ' ' } + ); + }); - it('Should detect no whitespaces before combinator in long selector', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a+b ~ c+d { color:red }', - { 'space-before-combinator': '' } - ); - }); + it('Should detect no whitespaces before combinator in long selector', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a+b ~ c+d { color:red }', + { 'space-before-combinator': '' } + ); + }); - it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a { color:red }', - {} - ); + it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { + this.shouldDetect( + ['space-before-combinator'], + 'a { color:red }', + {} + ); + }); }); }); diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace-scss/test.js index 19a7a059..971d485d 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -1,11 +1,13 @@ describe('options/space-before-opening-brace (scss):', function() { - it('Issue 231', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); - }); + describe('process', function() { + it('Issue 231', function() { + this.comb.configure({ 'space-before-opening-brace': 1 }); + this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); + }); - it('Issue 319', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); + it('Issue 319', function() { + this.comb.configure({ 'space-before-opening-brace': 1 }); + this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); + }); }); }); diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/test.js index 338e6c1c..ab077bba 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/test.js @@ -1,85 +1,89 @@ describe('options/space-before-opening-brace:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-before-opening-brace': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-before-opening-brace': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space before {', function() { + this.comb.configure({ 'space-before-opening-brace': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space before {', function() { + this.comb.configure({ 'space-before-opening-brace': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Valid string value (spaces and newlines) => should set proper space before {', function() { + this.comb.configure({ 'space-before-opening-brace': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Issue 232', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); + it('Issue 232', function() { + this.comb.configure({ 'space-before-opening-brace': 1 }); + this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); + }); }); - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0}', - { 'space-before-opening-brace': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespace', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0}', + { 'space-before-opening-brace': '' } + ); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a \n {top:0}', - { 'space-before-opening-brace': ' \n ' } - ); - }); + it('Should detect whitespace', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a \n {top:0}', + { 'space-before-opening-brace': ' \n ' } + ); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0} b {left:0}', - { 'space-before-opening-brace': '' } - ); - }); + it('Should detect no whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0} b {left:0}', + { 'space-before-opening-brace': '' } + ); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a {top:0} b{left:0}', - { 'space-before-opening-brace': ' ' } - ); - }); + it('Should detect whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a {top:0} b{left:0}', + { 'space-before-opening-brace': ' ' } + ); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a {top:0} b{left:0} c{right:0}', - { 'space-before-opening-brace': '' } - ); - }); + it('Should detect no whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a {top:0} b{left:0} c{right:0}', + { 'space-before-opening-brace': '' } + ); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0} b {left:0} c {right:0}', - { 'space-before-opening-brace': ' ' } - ); + it('Should detect whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0} b {left:0} c {right:0}', + { 'space-before-opening-brace': ' ' } + ); + }); }); }); diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/test.js index 92e2a959..d4bec32d 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -1,79 +1,83 @@ describe('options/space-before-selector-delimiter:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': ' nani ' }); - this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-before-selector-delimiter': ' nani ' }); + this.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': 3.5 }); - this.shouldBeEqual('test.css'); - }); + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-before-selector-delimiter': 3.5 }); + this.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Integer value => should set proper space before selector delimiter', function() { + this.comb.configure({ 'space-before-selector-delimiter': 0 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spaces only) => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Valid string value (spaces only) => should set proper space before selector delimiter', function() { + this.comb.configure({ 'space-before-selector-delimiter': ' ' }); + this.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + it('Valid string value (spaces and newlines) => should set proper space before selector delimiter', function() { + this.comb.configure({ 'space-before-selector-delimiter': '\n ' }); + this.shouldBeEqual('test.css', 'test-3.expected.css'); + }); }); - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0}', - { 'space-before-selector-delimiter': '' } - ); - }); + describe('detect', function() { + it('Should detect no whitespace', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0}', + { 'space-before-selector-delimiter': '' } + ); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a \n ,b {top:0}', - { 'space-before-selector-delimiter': ' \n ' } - ); - }); + it('Should detect whitespace', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a \n ,b {top:0}', + { 'space-before-selector-delimiter': ' \n ' } + ); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0} a ,b{left:0}', - { 'space-before-selector-delimiter': '' } - ); - }); + it('Should detect no whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0} a ,b{left:0}', + { 'space-before-selector-delimiter': '' } + ); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a ,b {top:0} b,a{left:0}', - { 'space-before-selector-delimiter': ' ' } - ); - }); + it('Should detect whitespace (2 blocks)', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a ,b {top:0} b,a{left:0}', + { 'space-before-selector-delimiter': ' ' } + ); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a ,b{top:0} b,c{left:0} c,d{right:0}', - { 'space-before-selector-delimiter': '' } - ); - }); + it('Should detect no whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a ,b{top:0} b,c{left:0} c,d{right:0}', + { 'space-before-selector-delimiter': '' } + ); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0} b ,c{left:0} c ,d{right:0}', - { 'space-before-selector-delimiter': ' ' } - ); + it('Should detect whitespace (3 blocks)', function() { + this.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0} b ,c{left:0} c ,d{right:0}', + { 'space-before-selector-delimiter': ' ' } + ); + }); }); }); diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/test.js index 016ec3ec..451e318b 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/test.js @@ -1,46 +1,48 @@ describe('options/space-between-declarations:', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': ['', ' '] }); - this.shouldBeEqual('test.css'); - }); - - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': ' nani ' }); - this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': 3.5 }); - this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': 0 }); - this.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': ' ' }); - this.shouldBeEqual('space-value.css', 'space-value.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': '\n ' }); - this.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); - }); - - it('Should leave comments as is', function() { - this.comb.configure({ 'space-between-declarations': 1 }); - this.shouldBeEqual('comments.css', 'comments.expected.css'); - }); - - it('Issue 239', function() { - this.comb.configure({ 'space-between-declarations': '\n ' }); - this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); - }); - - it('Issue 378', function() { - this.comb.configure({ 'space-between-declarations': '\n' }); - this.shouldBeEqual('issue-378.css'); + describe('process', function() { + it('Array value => should not change anything', function() { + this.comb.configure({ 'space-between-declarations': ['', ' '] }); + this.shouldBeEqual('test.css'); + }); + + it('Invalid string value => should not change anything', function() { + this.comb.configure({ 'space-between-declarations': ' nani ' }); + this.shouldBeEqual('test.css'); + }); + + it('Float number value => should not change anything', function() { + this.comb.configure({ 'space-between-declarations': 3.5 }); + this.shouldBeEqual('test.css'); + }); + + it('Integer value => should set proper space after declaration', function() { + this.comb.configure({ 'space-between-declarations': 0 }); + this.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); + }); + + it('Valid string value (spaces only) => should set proper space after declaration', function() { + this.comb.configure({ 'space-between-declarations': ' ' }); + this.shouldBeEqual('space-value.css', 'space-value.expected.css'); + }); + + it('Valid string value (spaces and newlines) => should set proper space after declaration', function() { + this.comb.configure({ 'space-between-declarations': '\n ' }); + this.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); + }); + + it('Should leave comments as is', function() { + this.comb.configure({ 'space-between-declarations': 1 }); + this.shouldBeEqual('comments.css', 'comments.expected.css'); + }); + + it('Issue 239', function() { + this.comb.configure({ 'space-between-declarations': '\n ' }); + this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); + }); + + it('Issue 378', function() { + this.comb.configure({ 'space-between-declarations': '\n' }); + this.shouldBeEqual('issue-378.css'); + }); }); }); diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/test.js index b8f19b36..130c01c2 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/test.js @@ -1,113 +1,119 @@ var assert = require('assert'); describe('options/strip-spaces', function() { - it('Invalid value should not trim trailing spaces', function() { - this.comb.configure({ 'strip-spaces': 'foobar' }); - assert.equal( - this.comb.processString('a { color: red } \n'), - 'a { color: red } \n' - ); - }); - it('Boolean true value should trim all trailing spaces', function() { - this.comb.configure({ 'strip-spaces': true }); - assert.equal( - this.comb.processString( - 'a { color: red } \n' + - 'a{color:red}\t /* foobar */\t \n' + - 'a {color:red} \n \n' - ), - 'a { color: red }\n' + - 'a{color:red}\t /* foobar */\n' + - 'a {color:red}\n' - ); - }); - it('Boolean true value should trim trailing spaces at eof', function() { - this.comb.configure({ 'strip-spaces': true }); - assert.equal( - this.comb.processString( - 'a {color:red} ' - ), - 'a {color:red}' - ); - }); + describe('process', function() { + it('Invalid value should not trim trailing spaces', function() { + this.comb.configure({ 'strip-spaces': 'foobar' }); + assert.equal( + this.comb.processString('a { color: red } \n'), + 'a { color: red } \n' + ); + }); - it('Should detect strip-spaces option set to `true`', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }', - { - 'strip-spaces': true - } - ); - }); + it('Boolean true value should trim all trailing spaces', function() { + this.comb.configure({ 'strip-spaces': true }); + assert.equal( + this.comb.processString( + 'a { color: red } \n' + + 'a{color:red}\t /* foobar */\t \n' + + 'a {color:red} \n \n' + ), + 'a { color: red }\n' + + 'a{color:red}\t /* foobar */\n' + + 'a {color:red}\n' + ); + }); - it('Should detect strip-spaces option set to `false`', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red } ', - { - 'strip-spaces': false - } - ); + it('Boolean true value should trim trailing spaces at eof', function() { + this.comb.configure({ 'strip-spaces': true }); + assert.equal( + this.comb.processString( + 'a {color:red} ' + ), + 'a {color:red}' + ); + }); }); - it('Should detect strip-spaces option set to `true` with newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\nb { color: blue }', - { - 'strip-spaces': true - } - ); - }); + describe('detect', function() { + it('Should detect strip-spaces option set to `true`', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red }', + { + 'strip-spaces': true + } + ); + }); - it('Should detect strip-spaces option set to `false` with newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red } \nb { color: blue }', - { - 'strip-spaces': false - } - ); - }); + it('Should detect strip-spaces option set to `false`', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red } ', + { + 'strip-spaces': false + } + ); + }); - it('Should detect strip-spaces option set to `true` inside a value', function() { - this.shouldDetect( - ['strip-spaces'], - 'a {\n color:\n red }', - { - 'strip-spaces': true - } - ); - }); + it('Should detect strip-spaces option set to `true` with newline', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red }\nb { color: blue }', + { + 'strip-spaces': true + } + ); + }); - it('Should detect strip-spaces option set to `false` inside a value', function() { - this.shouldDetect( - ['strip-spaces'], - 'a {\n color: \n red }', - { - 'strip-spaces': false - } - ); - }); + it('Should detect strip-spaces option set to `false` with newline', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red } \nb { color: blue }', + { + 'strip-spaces': false + } + ); + }); - it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\n', - { - 'strip-spaces': true - } - ); - }); + it('Should detect strip-spaces option set to `true` inside a value', function() { + this.shouldDetect( + ['strip-spaces'], + 'a {\n color:\n red }', + { + 'strip-spaces': true + } + ); + }); + + it('Should detect strip-spaces option set to `false` inside a value', function() { + this.shouldDetect( + ['strip-spaces'], + 'a {\n color: \n red }', + { + 'strip-spaces': false + } + ); + }); + + it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red }\n', + { + 'strip-spaces': true + } + ); + }); - it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\n\n', - { - 'strip-spaces': false - } - ); + it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { + this.shouldDetect( + ['strip-spaces'], + 'a { color: red }\n\n', + { + 'strip-spaces': false + } + ); + }); }); }); diff --git a/test/options/tab-size/test.js b/test/options/tab-size/test.js index 05560b1f..d59fff13 100644 --- a/test/options/tab-size/test.js +++ b/test/options/tab-size/test.js @@ -1,16 +1,18 @@ describe('options/tab-size:', function() { - it('Test 1: String value => should not change anything', function() { - this.comb.configure({ 'tab-size': ' ' }); - this.shouldBeEqual('test.css'); - }); + describe('process', function() { + it('Test 1: String value => should not change anything', function() { + this.comb.configure({ 'tab-size': ' ' }); + this.shouldBeEqual('test.css'); + }); - it('Test 2: Float value => should not change anything', function() { - this.comb.configure({ 'tab-size': 4.5 }); - this.shouldBeEqual('test.css'); - }); + it('Test 2: Float value => should not change anything', function() { + this.comb.configure({ 'tab-size': 4.5 }); + this.shouldBeEqual('test.css'); + }); - it('Test 3: Integer value => should replace tabs with proper number of spaces', function() { - this.comb.configure({ 'tab-size': 4 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + it('Test 3: Integer value => should replace tabs with proper number of spaces', function() { + this.comb.configure({ 'tab-size': 4 }); + this.shouldBeEqual('test.css', 'test.expected.css'); + }); }); }); diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index f7c67c4c..84c0896d 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -1,108 +1,107 @@ var assert = require('assert'); describe('options/unitless-zero', function() { - it('Should remove units in zero-valued dimensions', function() { - this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString( - 'div { margin: 0em; padding: 0px }' - ), - 'div { margin: 0; padding: 0 }' - ); - assert.equal( - this.comb.processString( - 'div { margin: 0% }' - ), - 'div { margin: 0 }' - ); - }); + describe('process', function() { + it('Should remove units in zero-valued dimensions', function() { + this.comb.configure({ 'unitless-zero': true }); + assert.equal( + this.comb.processString( + 'div { margin: 0em; padding: 0px }' + ), + 'div { margin: 0; padding: 0 }' + ); + assert.equal( + this.comb.processString( + 'div { margin: 0% }' + ), + 'div { margin: 0 }' + ); + }); - it('Should remove units in zero-valued media-query params', function() { - this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString('@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }'), - '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }' - ); - }); + it('Should remove units in zero-valued media-query params', function() { + this.comb.configure({ 'unitless-zero': true }); + assert.equal( + this.comb.processString('@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }'), + '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }' + ); + }); - it('Should not remove units (degs) in rotate property', function() { - this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString( + it('Should not remove units (degs) in rotate property', function() { + this.comb.configure({ 'unitless-zero': true }); + assert.equal( + this.comb.processString( + 'div { -webkit-transform: rotate(0deg); }' + ), 'div { -webkit-transform: rotate(0deg); }' - ), - 'div { -webkit-transform: rotate(0deg); }' - ); + ); + }); }); - it('Issue 394', function() { - this.comb.configure({ 'unitless-zero': true }); - this.shouldBeEqual('issue-394.css', 'issue-394.expected.css'); - }); - - it('Should detect unitless zero option', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0 }', - { - 'unitless-zero': true - } - ); - }); + describe('detect', function() { + it('Should detect unitless zero option', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { width: 0 }', + { + 'unitless-zero': true + } + ); + }); - it('Should detect zero with unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0px }', - { - 'unitless-zero': false - } - ); - }); + it('Should detect zero with unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { width: 0px }', + { + 'unitless-zero': false + } + ); + }); - it('Should detect unitless zero option with multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0 }', - { - 'unitless-zero': true - } - ); - }); + it('Should detect unitless zero option with multiple values', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0 }', + { + 'unitless-zero': true + } + ); + }); - it('Should detect zero with unit and multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0em }', - { - 'unitless-zero': false - } - ); - }); + it('Should detect zero with unit and multiple values', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0em }', + { + 'unitless-zero': false + } + ); + }); - it('Shouldn’t detect unitless zero option if there is no unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { color: red }', - {} - ); - }); + it('Shouldn’t detect unitless zero option if there is no unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { color: red }', + {} + ); + }); - it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { transform: rotate(0deg) }', - {} - ); - }); + it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { transform: rotate(0deg) }', + {} + ); + }); - it('Should detect unitless zero option with percents', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0% 0 0 }', - { - 'unitless-zero': true - } - ); + it('Should detect unitless zero option with percents', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0% 0 0 }', + { + 'unitless-zero': true + } + ); + }); }); }); diff --git a/test/options/vendor-prefix-align-sass/test.js b/test/options/vendor-prefix-align-sass/test.js index bd59c6d6..bfbc94f8 100644 --- a/test/options/vendor-prefix-align-sass/test.js +++ b/test/options/vendor-prefix-align-sass/test.js @@ -3,11 +3,13 @@ describe('options/vendor-prefix-align', function() { this.comb.configure({ 'vendor-prefix-align': true }); }); - it('Should align prexied values', function() { - this.shouldBeEqual('value.sass', 'value.expected.sass'); - }); + describe('process', function() { + it('Should align prexied values', function() { + this.shouldBeEqual('value.sass', 'value.expected.sass'); + }); - it('Should not align prefixed property names', function() { - this.shouldBeEqual('property.sass'); + it('Should not align prefixed property names', function() { + this.shouldBeEqual('property.sass'); + }); }); }); diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index f9ca9b2b..5a2ec788 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -3,153 +3,157 @@ describe('options/vendor-prefix-align', function() { this.comb.configure({ 'vendor-prefix-align': true }); }); - it('Should correctly work when there is comment before property name', function() { - this.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); - }); + describe('process', function() { + it('Should correctly work when there is comment before property name', function() { + this.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); + }); - it('Should correctly work when there is comment before property name. Test 2', function() { - this.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); - }); + it('Should correctly work when there is comment before property name. Test 2', function() { + this.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); + }); - it('Should correctly work when there is comment before property name. Test 3', function() { - this.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); - }); + it('Should correctly work when there is comment before property name. Test 3', function() { + this.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); + }); - it('Should correctly align prefixes in properties', function() { - this.shouldBeEqual('property-align.css', 'property-align.expected.css'); - }); + it('Should correctly align prefixes in properties', function() { + this.shouldBeEqual('property-align.css', 'property-align.expected.css'); + }); - it('Should correctly align prefixes in values', function() { - this.shouldBeEqual('value-align.css', 'value-align.expected.css'); - }); + it('Should correctly align prefixes in values', function() { + this.shouldBeEqual('value-align.css', 'value-align.expected.css'); + }); - it('Should not touch already align prefixes', function() { - this.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); - }); + it('Should not touch already align prefixes', function() { + this.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); + }); - it('Should correctly align prefixes in properties and values at the same time', function() { - this.shouldBeEqual('both.css', 'both.expected.css'); - }); + it('Should correctly align prefixes in properties and values at the same time', function() { + this.shouldBeEqual('both.css', 'both.expected.css'); + }); - it('Should correctly work when value and property names are the same', function() { - this.shouldBeEqual('same-name.css', 'same-name.expected.css'); - }); + it('Should correctly work when value and property names are the same', function() { + this.shouldBeEqual('same-name.css', 'same-name.expected.css'); + }); - it('Should correctly work when there is no whitespace after colon', function() { - this.shouldBeEqual('without-space.css', 'without-space.expected.css'); - }); + it('Should correctly work when there is no whitespace after colon', function() { + this.shouldBeEqual('without-space.css', 'without-space.expected.css'); + }); - it('Should correctly work when there is comment after colon', function() { - this.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); - }); + it('Should correctly work when there is comment after colon', function() { + this.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); + }); - it('Should not do anything with oneliners', function() { - this.shouldBeEqual('one-line.css', 'one-line.expected.css'); - }); + it('Should not do anything with oneliners', function() { + this.shouldBeEqual('one-line.css', 'one-line.expected.css'); + }); - it('Should not do anything with oneliners. Test 2', function() { - this.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); - }); + it('Should not do anything with oneliners. Test 2', function() { + this.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); + }); - it('Should always correctly align prefixes', function() { - this.shouldBeEqual('complex.css', 'complex.expected.css'); - }); + it('Should always correctly align prefixes', function() { + this.shouldBeEqual('complex.css', 'complex.expected.css'); + }); - it('Issue 193: should handle declarations without preceding spaces', function() { - this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); - }); + it('Issue 193: should handle declarations without preceding spaces', function() { + this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); + }); - it('Issue 241: should not break tabs', function() { - this.comb.configure({ - 'block-indent': '\t', - 'vendor-prefix-align': true + it('Issue 241: should not break tabs', function() { + this.comb.configure({ + 'block-indent': '\t', + 'vendor-prefix-align': true + }); + this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); }); - this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); }); - it('Shouldn not detect anything if there are no prefixed groups', function() { - this.shouldDetect( - ['vendor-prefix-align'], - 'a{ color: red }a{ -webkit-transform: translateZ(0) }', - {} - ); - }); + describe('detect', function() { + it('Shouldn not detect anything if there are no prefixed groups', function() { + this.shouldDetect( + ['vendor-prefix-align'], + 'a{ color: red }a{ -webkit-transform: translateZ(0) }', + {} + ); + }); - it('Shouldn detect vendor-prefix-align as false in properties', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('property-align.css'), - { - 'vendor-prefix-align': false - } - ); - }); + it('Shouldn detect vendor-prefix-align as false in properties', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('property-align.css'), + { + 'vendor-prefix-align': false + } + ); + }); - it('Shouldn detect vendor-prefix-align as true in properties', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('property-align.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); + it('Shouldn detect vendor-prefix-align as true in properties', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('property-align.expected.css'), + { + 'vendor-prefix-align': true + } + ); + }); - it('Shouldn detect vendor-prefix-align as false in values', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('value-align.css'), - { - 'vendor-prefix-align': false - } - ); - }); + it('Shouldn detect vendor-prefix-align as false in values', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('value-align.css'), + { + 'vendor-prefix-align': false + } + ); + }); - it('Shouldn detect vendor-prefix-align as true in values', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('value-align.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); + it('Shouldn detect vendor-prefix-align as true in values', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('value-align.expected.css'), + { + 'vendor-prefix-align': true + } + ); + }); - it('Shouldn detect vendor-prefix-align as true, test 1', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('already-aligned.css'), - { - 'vendor-prefix-align': true - } - ); - }); + it('Shouldn detect vendor-prefix-align as true, test 1', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('already-aligned.css'), + { + 'vendor-prefix-align': true + } + ); + }); - it('Shouldn detect vendor-prefix-align as true, test 2', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('complex.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); + it('Shouldn detect vendor-prefix-align as true, test 2', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('complex.expected.css'), + { + 'vendor-prefix-align': true + } + ); + }); - it('Shouldn detect vendor-prefix-align as false', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('complex.css'), - { - 'vendor-prefix-align': false - } - ); - }); + it('Shouldn detect vendor-prefix-align as false', function() { + this.shouldDetect( + ['vendor-prefix-align'], + this.readFile('complex.css'), + { + 'vendor-prefix-align': false + } + ); + }); - it('Should not detect anything in simple case', function() { - this.shouldDetect( - ['vendor-prefix-align'], - 'a{border:0;}', - {} - ); + it('Should not detect anything in simple case', function() { + this.shouldDetect( + ['vendor-prefix-align'], + 'a{border:0;}', + {} + ); + }); }); }); From 7fa89fba8b69df1841972a8e9bebf478152888b2 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 31 May 2015 22:55:28 +0200 Subject: [PATCH 071/184] [tools] Use Babel and ES6 :elephant: --- .gitignore | 1 + .jscs.json | 1 + .jshint-groups.js | 3 +- gulpfile.js | 8 + lib/options/always-semicolon.js | 73 ---- lib/options/block-indent.js | 132 ------- lib/options/color-case.js | 34 -- lib/options/color-shorthand.js | 34 -- package.json | 120 +++--- {lib => src}/cli.js | 0 {lib => src}/csscomb.js | 372 ++++++++---------- src/options/always-semicolon.js | 119 ++++++ src/options/block-indent.js | 103 +++++ src/options/color-case.js | 40 ++ src/options/color-shorthand.js | 40 ++ {lib => src}/options/element-case.js | 0 {lib => src}/options/eof-newline.js | 2 +- {lib => src}/options/leading-zero.js | 0 {lib => src}/options/quotes.js | 0 {lib => src}/options/remove-empty-rulesets.js | 0 {lib => src}/options/sort-order-fallback.js | 0 {lib => src}/options/sort-order.js | 2 +- {lib => src}/options/space-after-colon.js | 0 .../options/space-after-combinator.js | 0 .../options/space-after-opening-brace.js | 0 .../options/space-after-selector-delimiter.js | 0 .../options/space-before-closing-brace.js | 0 {lib => src}/options/space-before-colon.js | 0 .../options/space-before-combinator.js | 0 .../options/space-before-opening-brace.js | 0 .../space-before-selector-delimiter.js | 0 .../options/space-between-declarations.js | 0 {lib => src}/options/strip-spaces.js | 0 {lib => src}/options/tab-size.js | 0 {lib => src}/options/unitless-zero.js | 0 {lib => src}/options/vendor-prefix-align.js | 0 36 files changed, 552 insertions(+), 532 deletions(-) create mode 100644 gulpfile.js delete mode 100644 lib/options/always-semicolon.js delete mode 100644 lib/options/block-indent.js delete mode 100644 lib/options/color-case.js delete mode 100644 lib/options/color-shorthand.js rename {lib => src}/cli.js (100%) rename {lib => src}/csscomb.js (85%) create mode 100644 src/options/always-semicolon.js create mode 100644 src/options/block-indent.js create mode 100644 src/options/color-case.js create mode 100644 src/options/color-shorthand.js rename {lib => src}/options/element-case.js (100%) rename {lib => src}/options/eof-newline.js (93%) rename {lib => src}/options/leading-zero.js (100%) rename {lib => src}/options/quotes.js (100%) rename {lib => src}/options/remove-empty-rulesets.js (100%) rename {lib => src}/options/sort-order-fallback.js (100%) rename {lib => src}/options/sort-order.js (99%) rename {lib => src}/options/space-after-colon.js (100%) rename {lib => src}/options/space-after-combinator.js (100%) rename {lib => src}/options/space-after-opening-brace.js (100%) rename {lib => src}/options/space-after-selector-delimiter.js (100%) rename {lib => src}/options/space-before-closing-brace.js (100%) rename {lib => src}/options/space-before-colon.js (100%) rename {lib => src}/options/space-before-combinator.js (100%) rename {lib => src}/options/space-before-opening-brace.js (100%) rename {lib => src}/options/space-before-selector-delimiter.js (100%) rename {lib => src}/options/space-between-declarations.js (100%) rename {lib => src}/options/strip-spaces.js (100%) rename {lib => src}/options/tab-size.js (100%) rename {lib => src}/options/unitless-zero.js (100%) rename {lib => src}/options/vendor-prefix-align.js (100%) diff --git a/.gitignore b/.gitignore index 4afc62a1..c7d5d95c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +lib lib-cov node_modules test/test-coverage.html diff --git a/.jscs.json b/.jscs.json index 8245a9c3..d442f328 100644 --- a/.jscs.json +++ b/.jscs.json @@ -1,6 +1,7 @@ { "excludeFiles": [ "node_modules/**", + "lib/**", "lib-cov/**" ], "requireCurlyBraces": [ diff --git a/.jshint-groups.js b/.jshint-groups.js index 95aa4d7b..8808b8d3 100644 --- a/.jshint-groups.js +++ b/.jshint-groups.js @@ -1,6 +1,7 @@ module.exports = { options: { eqeqeq: true, + esnext: true, evil: true, expr: true, forin: true, @@ -22,7 +23,7 @@ module.exports = { groups: { js: { options: { node: true }, - includes: ['lib/**/*.js'] + includes: ['src/**/*.js'] }, test: { options: { diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..66da6517 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,8 @@ +var gulp = require("gulp"); +var babel = require("gulp-babel"); + +gulp.task("default", function () { + return gulp.src("src/**/*.js") + .pipe(babel()) + .pipe(gulp.dest("lib")); +}); diff --git a/lib/options/always-semicolon.js b/lib/options/always-semicolon.js deleted file mode 100644 index e84716d0..00000000 --- a/lib/options/always-semicolon.js +++ /dev/null @@ -1,73 +0,0 @@ -var gonzales = require('gonzales-pe'); - -module.exports = { - name: 'always-semicolon', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { boolean: [true] }, - - /** - * Processes tree node. - * @param {node} node - */ - process: function(node) { - var nodeWithoutSemicolon; - - if (!node.is('block')) return; - - mainLoop: - for (var i = node.length; i--;) { - var currentNode = node.get(i); - - // Skip nodes that already have `;` at the end: - if (currentNode.is('declarationDelimiter')) break; - - // Add semicolon only after declarations and includes. - // If current node is include, insert semicolon right into it. - // If it's declaration, look for value node: - if (currentNode.is('include')) { - nodeWithoutSemicolon = currentNode; - } else if (currentNode.is('declaration')) { - nodeWithoutSemicolon = currentNode.last('value'); - } else { - continue; - } - - // Check if there are spaces and comments at the end of the node: - for (var j = nodeWithoutSemicolon.length; j--; ) { - var lastNode = nodeWithoutSemicolon.get(j); - - // If the node's last child is block, do not add semicolon: - // TODO: Add syntax check and run the code only for scss - if (lastNode.is('block')) { - break mainLoop; - } else if (!lastNode.is('space') && - !lastNode.is('multilineComment') && - !lastNode.is('singlelineComment')) { - j++; - break; - } - } - - var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: ';' }); - nodeWithoutSemicolon.insert(j, declDelim); - break; - } - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} node - */ - detect: function(node) { - if (!node.is('block')) return; - - for (var i = node.length; i--;) { - var nodeItem = node.get(i); - if (nodeItem.is('declarationDelimiter')) return true; - if (nodeItem.is('declaration')) return false; - } - } -}; diff --git a/lib/options/block-indent.js b/lib/options/block-indent.js deleted file mode 100644 index f36f2634..00000000 --- a/lib/options/block-indent.js +++ /dev/null @@ -1,132 +0,0 @@ -module.exports = (function() { - var syntax; - var value; - - function processNode(node, level) { - level = level || 0; - - for (var i = 0; i < node.length; i++) { - var n = node.get(i); - if (!n) continue; - - if (syntax === 'sass' && n.is('block')) { - processSassBlock(n, level, value); - } - - // Continue only with space nodes inside {...}: - if (syntax !== 'sass' && level !== 0 && n.is('space')) { - processSpaceNode(n, level, value); - } - - if (n.is('block') || n.is('atrulers')) level++; - - processNode(n, level); - } - } - - function processSassBlock(node, level, value) { - var spaces; - var whitespaceNode; - var i; - - for (i = node.length; i--;) { - whitespaceNode = node.get(i); - - if (!whitespaceNode.is('space')) continue; - - if (whitespaceNode.content === '\n') continue; - - spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); - spaces += new Array(level + 2).join(value); - whitespaceNode.content = spaces; - } - } - - function processSpaceNode(node, level, value) { - var spaces; - - // Remove all whitespaces and tabs, leave only new lines: - spaces = node.content.replace(/[ \t]/gm, ''); - - if (!spaces) return; - - spaces += new Array(level + 1).join(value); - node.content = spaces; - } - - return { - name: 'block-indent', - - runBefore: 'sort-order', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - number: true, - string: /^[ \t]*$/ - }, - - /** - * Processes tree node. - * - * @param {node} node - */ - process: function process(node) { - var spaces; - var whitespaceNode; - var i; - - if (!node.is('stylesheet')) return; - - syntax = this.getSyntax(); - value = this.getValue('block-indent'); - - - for (i = node.length; i--;) { - whitespaceNode = node.get(i); - - if (!whitespaceNode.is('space')) continue; - - spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); - - if (spaces === '') { - node.remove(i); - } else { - whitespaceNode.content = spaces; - } - } - - processNode(node); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} node - */ - detect: function(node) { - var result = []; - - // Continue only with non-empty {...} blocks: - if (!node.is('atrulers') && !node.is('block') || !node.length) - return; - - for (var i = node.length; i--;) { - var whitespaceNode = node.get(i); - if (!whitespaceNode.is('space')) continue; - - var spaces = whitespaceNode.content; - var lastIndex = spaces.lastIndexOf('\n'); - - // Do not continue if there is no line break: - if (lastIndex < 0) continue; - - // Number of spaces from beginning of line: - var spacesLength = spaces.slice(lastIndex + 1).length + 1; - result.push(new Array(spacesLength).join(' ')); - } - - return result; - } - }; -})(); diff --git a/lib/options/color-case.js b/lib/options/color-case.js deleted file mode 100644 index ef1345c9..00000000 --- a/lib/options/color-case.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - name: 'color-case', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { string: /^lower|upper$/ }, - - /** - * Processes tree node. - * @param {node} node - */ - process: function(node) { - if (!node.is('color')) return; - - node.content = this.getValue('color-case') === 'lower' ? - node.content.toLowerCase() : - node.content.toUpperCase(); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} node - */ - detect: function(node) { - if (!node.is('color')) return; - - if (node.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { - return 'lower'; - } else if (node.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { - return 'upper'; - } - } -}; diff --git a/lib/options/color-shorthand.js b/lib/options/color-shorthand.js deleted file mode 100644 index 4e723bd1..00000000 --- a/lib/options/color-shorthand.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - name: 'color-shorthand', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { boolean: [true, false] }, - - /** - * Processes tree node. - * @param {node} node - */ - process: function(node) { - if (!node.is('color')) return; - - node.content = this.getValue('color-shorthand') ? - node.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : - node.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} node - */ - detect: function(node) { - if (!node.is('color')) return; - - if (node.content.match(/^\w{3}$/)) { - return true; - } else if (node.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { - return false; - } - } -}; diff --git a/package.json b/package.json index fe87cdf9..4a29b09f 100644 --- a/package.json +++ b/package.json @@ -1,66 +1,68 @@ { - "name": "csscomb", - "description": "CSS coding style formatter", - "version": "3.1.7", - "homepage": "http://csscomb.com/", - "author": "Mikhail Troshev ", - "repository": "https://github.com/csscomb/csscomb.js", - "maintainers": [ - { - "name": "Tony Ganch", - "email": "tonyganch+github@gmail.com", - "web": "http://tonyganch.com/" - } - ], - "contributors": [ - { - "name": "Igor Novak", - "email": "bezengi@gmail.com" - }, - { - "name": "Roman Komarov", - "email": "kizmarh@ya.ru" - }, - { - "name": "Denis Payase", - "email": "lostsoul@yandex-team.ru" - }, - { - "name": "Mikhail Troshev", - "email": "mishanga@yandex-team.ru", - "web": "http://mishanga.pro/" - }, - { - "name": "Sergey Puzankov", - "email": "puzankov@yandex-team.ru" - } - ], - "engines": { - "node": ">= 0.10.0" + "name": "csscomb", + "description": "CSS coding style formatter", + "version": "3.1.5", + "homepage": "http://csscomb.com/", + "author": "Mikhail Troshev ", + "repository": "https://github.com/csscomb/csscomb.js", + "maintainers": [ + { + "name": "Tony Ganch", + "email": "tonyganch+github@gmail.com", + "web": "http://tonyganch.com/" + } + ], + "contributors": [ + { + "name": "Igor Novak", + "email": "bezengi@gmail.com" }, - "dependencies": { - "minimist": "1.1.x", - "csscomb-core": "3.0.0-4", - "gonzales-pe": "3.0.0-29", - "vow": "0.4.4" + { + "name": "Roman Komarov", + "email": "kizmarh@ya.ru" }, - "devDependencies": { - "jshint-groups": "0.5.3", - "jshint": "2.3.0", - "jscs": "1.4.5", - "mocha": "1.20.1" + { + "name": "Denis Payase", + "email": "lostsoul@yandex-team.ru" }, - "main": "./lib/csscomb.js", - "files": [ - "bin", - "config", - "lib" - ], - "bin": { - "csscomb": "./bin/csscomb" + { + "name": "Mikhail Troshev", + "email": "mishanga@yandex-team.ru", + "web": "http://mishanga.pro/" }, - "scripts": { - "test": "./node_modules/.bin/jshint-groups && ./node_modules/.bin/jscs . && node test/mocha", - "test-cov": "rm -rf lib-cov && jscoverage lib lib-cov && TEST_COV=true node test/mocha > ./test/test-coverage.html" + { + "name": "Sergey Puzankov", + "email": "puzankov@yandex-team.ru" } + ], + "engines": { + "node": ">= 0.10.0" + }, + "dependencies": { + "minimist": "1.1.x", + "csscomb-core": "3.0.0-4", + "gonzales-pe": "3.0.0-29", + "vow": "0.4.4" + }, + "devDependencies": { + "babel-core": "^5.4.7", + "gulp-babel": "^5.1.0", + "jscs": "1.4.5", + "jshint": "2.3.0", + "jshint-groups": "0.5.3", + "mocha": "1.20.1" + }, + "main": "./lib/csscomb.js", + "files": [ + "bin", + "config", + "lib" + ], + "bin": { + "csscomb": "./bin/csscomb" + }, + "scripts": { + "test": "./node_modules/.bin/jshint-groups && ./node_modules/.bin/jscs . && node test/mocha", + "test-cov": "rm -rf lib-cov && jscoverage lib lib-cov && TEST_COV=true node test/mocha > ./test/test-coverage.html" + } } diff --git a/lib/cli.js b/src/cli.js similarity index 100% rename from lib/cli.js rename to src/cli.js diff --git a/lib/csscomb.js b/src/csscomb.js similarity index 85% rename from lib/csscomb.js rename to src/csscomb.js index 94b4f766..011e8dc8 100644 --- a/lib/csscomb.js +++ b/src/csscomb.js @@ -1,163 +1,23 @@ -var Comb = require('csscomb-core'); -var gonzales = require('gonzales-pe'); -var fs = require('fs'); -var path = require('path'); +let Comb = require('csscomb-core'); +let gonzales = require('gonzales-pe'); +let fs = require('fs'); +let path = require('path'); /** - * Converts CSS string to AST. - * - * @param {String} text CSS string - * @param {String} [syntax] Syntax name (e.g., `scss`) - * @param {String} [filename] - * @returns {Array} AST - */ -function cssToAST(text, syntax, filename) { - var string = JSON.stringify; - var fileInfo = filename ? ' at ' + filename : ''; - var tree; - - try { - tree = gonzales.parse(text, { syntax: syntax }); - } catch (e) { - throw new Error('Parsing error' + fileInfo + ': ' + e.message); - } - - // TODO: When can tree be undefined? - if (typeof tree === 'undefined') { - throw new Error('Undefined tree' + fileInfo + ': ' + string(text) + ' => ' + string(tree)); - } - - return tree; -} - -/** - * Gets option's data needed for detection - * - * @param {String} optionName - * @returns {Object} Object with option's name, link to `detect()` method - * and default value for the case when nothing can be detected - */ -function getHandler(optionName) { - var option = require('./options/' + optionName); - if (!option.detect) throw new Error('Option does not have `detect()` method.'); - return { - name: option.name, - detect: option.detect, - detectDefault: option.detectDefault - }; -} - -/** - * Processes tree node and detects options. - * - * @param {Array} node Tree node - * @param {Number} level Indent level - * @param {Object} handler Object with option's data - * @param {Object} detectedOptions - */ -function detectInNode(node, level, handler, detectedOptions) { - node.map(function(tree) { - var detected = handler.detect(tree); - var variants = detectedOptions[handler.name]; - if (typeof detected === 'object') { - variants.push.apply(variants, detected); - } else if (typeof detected !== 'undefined') { - variants.push(detected); - } - - //if (nodeType === 'atrulers' || nodeType === 'block') level++; - }); -} - -/** - * Processes tree and detects options. - * - * @param {Array} tree - * @param {Array} handlers List of options that we should look for - * @returns {Object} Map with detected options and all variants of possible - * values - */ -function detectInTree(tree, handlers) { - var detectedOptions = {}; - // We walk across complete tree for each handler, - // because we need strictly maintain order in which handlers work, - // despite fact that handlers work on different level of the tree. - handlers.forEach(function(handler) { - detectedOptions[handler.name] = []; - // TODO: Pass all parameters as one object? - detectInNode(tree, 0, handler, detectedOptions); - }); - return detectedOptions; -} - -/** - * Gets the detected options. - * - * @param {Object} detected - * @param {Array} handlers - * @returns {Object} - */ -function getDetectedOptions(detected, handlers) { - var options = {}; - Object.keys(detected).forEach(function(option) { - // List of all the detected variants from the stylesheet for the given option: - var values = detected[option]; - var i; - if (!values.length) { - // If there are no values for the option, check if there is a default one: - for (i = handlers.length; i--;) { - if (handlers[i].name === option && - handlers[i].detectDefault !== undefined) { - options[option] = handlers[i].detectDefault; - break; - } - } - } else if (values.length === 1) { - options[option] = values[0]; - } else { - // If there are more than one value for the option, find the most popular one; - // `variants` would be populated with the popularity for different values. - var variants = {}; - var bestGuess = null; - var maximum = 0; - for (i = values.length; i--;) { - var currentValue = values[i]; - // Count the current value: - if (variants[currentValue]) { - variants[currentValue]++; - } else { - variants[currentValue] = 1; - } - // If the current variant is the most popular one, treat - // it as the best guess: - if (variants[currentValue] >= maximum) { - maximum = variants[currentValue]; - bestGuess = currentValue; - } - } - if (bestGuess !== null) { - options[option] = bestGuess; - } - } - }); - - return options; -} - -/** - * Starts Code Style processing process. - * * @param {String|Object} config * @constructor * @name CSScomb */ -var CSScomb = function(config) { - var options = fs.readdirSync(__dirname + '/options').map(function(option) { +let CSScomb = function(config) { + let comb = new Comb(); + + // Add plugins. + fs.readdirSync(__dirname + '/options').map(function(option) { return require('./options/' + option); + }).forEach(function(option) { + comb.use(option); }); - var comb = new Comb(options, 'css', 'less', 'scss', 'sass'); - // If config was passed, configure: if (typeof config === 'string') { config = CSScomb.getConfig(config); @@ -166,20 +26,74 @@ var CSScomb = function(config) { comb.configure(config); } + // Chaining. return comb; }; /** * STATIC METHODS * Methods that can be called without creating an instance: + * - detectInFile; + * - detectInString; * - getConfig; * - getCustomConfig; * - getCustomConfigPath; - * - detectInFile; - * - detectInString. * For example: `CSScomb.getConfig('zen')` */ +/** + * Detects the options in the given file + * + * @param {String} path Path to the stylesheet + * @param {Array} options List of options to detect + * @returns {Object} Detected options + */ +CSScomb.detectInFile = function detectInFile(path, options) { + var stylesheet = fs.readFileSync(path, 'utf8'); + return CSScomb.detectInString(stylesheet, options); +}; + +/** + * Detects the options in the given string + * + * @param {String} text Stylesheet + * @param {Array} options List of options to detect + * @returns {Object} Detected options + */ +CSScomb.detectInString = function detectInString(text, options) { + var result; + var handlers = []; + + if (!text) return text; + + var optionNames = fs.readdirSync(__dirname + '/options'); + optionNames.forEach(function(option) { + option = option.slice(0, -3); + if (options && options.indexOf(option) < 0) return; + try { + handlers.push(getHandler(option)); + } catch (e) { + console.warn('\nFailed to load "%s" option:\n%s', option, e.message); + } + }); + + var tree = cssToAST(text); + var detectedOptions = detectInTree(tree, handlers); + result = getDetectedOptions(detectedOptions, handlers); + + // Handle conflicting options with spaces around braces: + var blockIndent = result['block-indent']; + var spaceAfterOpeningBrace = result['space-after-opening-brace']; + + if (typeof blockIndent === 'string' && + spaceAfterOpeningBrace && + spaceAfterOpeningBrace.indexOf('\n') > -1) { + result['space-after-opening-brace'] = '\n'; + } + + return result; +}; + /** * Gets one of configuration files from configs' directory. * @@ -187,21 +101,21 @@ var CSScomb = function(config) { * @returns {Object} Configuration object */ CSScomb.getConfig = function getConfig(name) { - var DEFAULT_CONFIG_NAME = 'csscomb'; + const DEFAULT_CONFIG_NAME = 'csscomb'; name = name || DEFAULT_CONFIG_NAME; if (typeof name !== 'string') { throw new Error('Config name must be a string.'); } - var CONFIG_DIR_PATH = '../config'; - var availableConfigsNames = fs.readdirSync(__dirname + '/' + CONFIG_DIR_PATH) + let CONFIG_DIR_PATH = '../config'; + let availableConfigsNames = fs.readdirSync(__dirname + '/' + CONFIG_DIR_PATH) .map(function(configFileName) { return configFileName.split('.')[0]; // strip file extension(s) }); if (availableConfigsNames.indexOf(name) < 0) { - var configsNamesAsString = availableConfigsNames + let configsNamesAsString = availableConfigsNames .map(function(configName) { return '\'' + configName + '\''; }) @@ -266,56 +180,120 @@ CSScomb.getCustomConfigPath = function getCustomConfigPath(configPath) { }; /** - * Detects the options in the given file + * Converts CSS string to AST. * - * @param {String} path Path to the stylesheet - * @param {Array} options List of options to detect - * @returns {Object} Detected options + * @param {String} text CSS string + * @param {String} [syntax] Syntax name (e.g., `scss`) + * @param {String} [filename] + * @returns {Array} AST */ -CSScomb.detectInFile = function detectInFile(path, options) { - var stylesheet = fs.readFileSync(path, 'utf8'); - return CSScomb.detectInString(stylesheet, options); -}; +function cssToAST(text, syntax, filename) { + var string = JSON.stringify; + var fileInfo = filename ? ' at ' + filename : ''; + var tree; + + try { + tree = gonzales.parse(text, { syntax: syntax }); + } catch (e) { + throw new Error('Parsing error' + fileInfo + ': ' + e.message); + } + + // TODO: When can tree be undefined? + if (typeof tree === 'undefined') { + throw new Error('Undefined tree' + fileInfo + ': ' + string(text) + ' => ' + string(tree)); + } + + return tree; +} /** - * Detects the options in the given string + * Processes tree and detects options. * - * @param {String} text Stylesheet - * @param {Array} options List of options to detect - * @returns {Object} Detected options + * @param {Array} tree + * @param {Array} handlers List of options that we should look for + * @returns {Object} Map with detected options and all variants of possible + * values */ -CSScomb.detectInString = function detectInString(text, options) { - var result; - var handlers = []; - - if (!text) return text; +function detectInTree(tree, handlers) { + var detectedOptions = {}; + // We walk across complete tree for each handler, + // because we need strictly maintain order in which handlers work, + // despite fact that handlers work on different level of the tree. + handlers.forEach(function(handler) { + detectedOptions[handler.name] = handler.detect(tree); + }); + return detectedOptions; +} - var optionNames = fs.readdirSync(__dirname + '/options'); - optionNames.forEach(function(option) { - option = option.slice(0, -3); - if (options && options.indexOf(option) < 0) return; - try { - handlers.push(getHandler(option)); - } catch (e) { - console.warn('\nFailed to load "%s" option:\n%s', option, e.message); +/** + * Gets the detected options. + * + * @param {Object} detected + * @param {Array} handlers + * @returns {Object} + */ +function getDetectedOptions(detected, handlers) { + var options = {}; + Object.keys(detected).forEach(function(option) { + // List of all the detected variants from the stylesheet for the given option: + var values = detected[option]; + var i; + if (!values.length) { + // If there are no values for the option, check if there is a default one: + for (i = handlers.length; i--;) { + if (handlers[i].name === option && + handlers[i].detectDefault !== undefined) { + options[option] = handlers[i].detectDefault; + break; + } + } + } else if (values.length === 1) { + options[option] = values[0]; + } else { + // If there are more than one value for the option, find the most popular one; + // `variants` would be populated with the popularity for different values. + var variants = {}; + var bestGuess = null; + var maximum = 0; + for (i = values.length; i--;) { + var currentValue = values[i]; + // Count the current value: + if (variants[currentValue]) { + variants[currentValue]++; + } else { + variants[currentValue] = 1; + } + // If the current variant is the most popular one, treat + // it as the best guess: + if (variants[currentValue] >= maximum) { + maximum = variants[currentValue]; + bestGuess = currentValue; + } + } + if (bestGuess !== null) { + options[option] = bestGuess; + } } }); - var tree = cssToAST(text); - var detectedOptions = detectInTree(tree, handlers); - result = getDetectedOptions(detectedOptions, handlers); - - // Handle conflicting options with spaces around braces: - var blockIndent = result['block-indent']; - var spaceAfterOpeningBrace = result['space-after-opening-brace']; - - if (typeof blockIndent === 'string' && - spaceAfterOpeningBrace && - spaceAfterOpeningBrace.indexOf('\n') > -1) { - result['space-after-opening-brace'] = '\n'; - } + return options; +} - return result; -}; +/** + * Gets option's data needed for detection + * + * @param {String} optionName + * @returns {Object} Object with option's name, link to `detect()` method + * and default value for the case when nothing can be detected + */ +function getHandler(optionName) { + var option = require('./options/' + optionName); + if (!option.detect) throw new Error('Option does not have `detect()` method.'); + return { + name: option.name, + detect: option.detect, + detectDefault: option.detectDefault + }; +} module.exports = CSScomb; diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js new file mode 100644 index 00000000..407e8811 --- /dev/null +++ b/src/options/always-semicolon.js @@ -0,0 +1,119 @@ +var gonzales = require('gonzales-pe'); + +module.exports = { + name: 'always-semicolon', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { boolean: [true] }, + + /** + * Processes tree node. + * @param {node} ast + * @return {Array} List of errors + */ + lint: function(ast) { + var errors = []; + + ast.traverse('block', function(block) { + block.eachFor(function(currentNode) { + var nodeWithoutSemicolon; + // Skip nodes that already have `;` at the end: + if (currentNode.is('declarationDelimiter')) return null; + + // Add semicolon only after declarations and includes. + // If current node is include, insert semicolon right into it. + // If it's declaration, look for value node: + if (currentNode.is('include')) { + nodeWithoutSemicolon = currentNode; + } else if (currentNode.is('declaration')) { + nodeWithoutSemicolon = currentNode.last('value'); + } else { + return; + } + + errors.push({ + message: 'Missing semicolon', + line: nodeWithoutSemicolon.end.line, + column: nodeWithoutSemicolon.end.column + }); + + // Stop looping through block's children: + return null; + }); + }); + + return errors; + }, + + + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + var nodeWithoutSemicolon; + + ast.traverse('block', function(block) { + block.eachFor(function(currentNode) { + // Skip nodes that already have `;` at the end: + if (currentNode.is('declarationDelimiter')) return null; + + // Add semicolon only after declarations and includes. + // If current node is include, insert semicolon right into it. + // If it's declaration, look for value node: + if (currentNode.is('include')) { + nodeWithoutSemicolon = currentNode; + } else if (currentNode.is('declaration')) { + nodeWithoutSemicolon = currentNode.last('value'); + } else { + return; + } + + // Check if there are spaces and comments at the end of the node: + for (var j = nodeWithoutSemicolon.length; j--; ) { + var lastNode = nodeWithoutSemicolon.get(j); + + // If the node's last child is block, do not add semicolon: + // TODO: Add syntax check and run the code only for scss + if (lastNode.is('block')) { + return null; + } else if (!lastNode.is('space') && + !lastNode.is('multilineComment') && + !lastNode.is('singlelineComment')) { + j++; + break; + } + } + + var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: ';' }); + nodeWithoutSemicolon.insert(j, declDelim); + return null; + }); + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + * @return {Array} List of detected values + */ + detect: function(ast) { + var detected = []; + + ast.traverse('block', function(block) { + block.eachFor(function(node) { + if (node.is('declarationDelimiter')) { + detected.push(true); + return null; + } else if (node.is('declaration')) { + detected.push(false); + return null; + } + }); + }); + + return detected; + } +}; diff --git a/src/options/block-indent.js b/src/options/block-indent.js new file mode 100644 index 00000000..b7ff8b49 --- /dev/null +++ b/src/options/block-indent.js @@ -0,0 +1,103 @@ +module.exports = { + name: 'block-indent', + + runBefore: 'sort-order', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { + number: true, + string: /^[ \t]*$/ + }, + + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function process(ast) { + ast.eachFor('space', function(whitespaceNode, i) { + var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); + + if (spaces === '') { + ast.remove(i); + } else { + whitespaceNode.content = spaces; + } + }); + + console.log(this); + this._processNode(ast, 0); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + var detected = []; + + ast.traverse(function(node) { + // Continue only with non-empty {...} blocks: + if (!node.is('atrulers') && !node.is('block') || !node.length) + return; + + node.eachFor('space', function(whitespaceNode) { + var spaces = whitespaceNode.content; + var lastIndex = spaces.lastIndexOf('\n'); + + // Do not continue if there is no line break: + if (lastIndex < 0) return; + + // Number of spaces from beginning of line: + var spacesLength = spaces.slice(lastIndex + 1).length + 1; + detected.push(new Array(spacesLength).join(' ')); + }); + }); + }, + + _processNode: function _processNode(node, level) { + var syntax = this.getSyntax(); + var that = this; + + node.forEach(function(n) { + if (syntax === 'sass' && n.is('block')) { + that._processSassBlock(n, level); + } + + // Continue only with space nodes inside {...}: + if (syntax !== 'sass' && level !== 0 && n.is('space')) { + that._processSpaceNode(n, level); + } + + if (n.is('block') || n.is('atrulers')) level++; + + that._processNode(n, level); + }); + }, + + _processSassBlock: function _processSassBlock(node, level) { + var value = this.getValue('block-indent'); + + node.eachFore('space', function(whitespaceNode) { + if (whitespaceNode.content === '\n') return; + + var spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); + spaces += new Array(level + 2).join(value); + whitespaceNode.content = spaces; + }); + }, + + _processSpaceNode: function _processSpaceNode(node, level) { + var value = this.getValue('block-indent'); + + // Remove all whitespaces and tabs, leave only new lines: + var spaces = node.content.replace(/[ \t]/gm, ''); + + if (!spaces) return; + + spaces += new Array(level + 1).join(value); + node.content = spaces; + } +}; diff --git a/src/options/color-case.js b/src/options/color-case.js new file mode 100644 index 00000000..e5397ff0 --- /dev/null +++ b/src/options/color-case.js @@ -0,0 +1,40 @@ +module.exports = { + name: 'color-case', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { string: /^lower|upper$/ }, + + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + var value = this.value; + + ast.traverse('color', function(color) { + color.content = value === 'lower' ? + color.content.toLowerCase() : + color.content.toUpperCase(); + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + var detected = []; + + ast.traverse('color', function(color) { + if (color.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { + detected.push('lower'); + } else if (color.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { + detected.push('upper'); + } + }); + + return detected; + } +}; diff --git a/src/options/color-shorthand.js b/src/options/color-shorthand.js new file mode 100644 index 00000000..e59cd83a --- /dev/null +++ b/src/options/color-shorthand.js @@ -0,0 +1,40 @@ +module.exports = { + name: 'color-shorthand', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { boolean: [true, false] }, + + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + var value = this.value; + + ast.traverse('color', function(color) { + color.content = value ? + color.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : + color.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + var detected = []; + + ast.traverse('color', function(color) { + if (color.content.match(/^\w{3}$/)) { + detected.push(true); + } else if (color.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { + detected.push(false); + } + }); + + return detected; + } +}; diff --git a/lib/options/element-case.js b/src/options/element-case.js similarity index 100% rename from lib/options/element-case.js rename to src/options/element-case.js diff --git a/lib/options/eof-newline.js b/src/options/eof-newline.js similarity index 93% rename from lib/options/eof-newline.js rename to src/options/eof-newline.js index 7b914c93..f69a6082 100644 --- a/lib/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -20,7 +20,7 @@ module.exports = { node.content.push(lastChild); } lastChild.content = lastChild.content.replace(/\n$/, ''); - if (this.getValue('eof-newline')) lastChild.content += '\n'; + if (this.value) lastChild.content += '\n'; }, /** diff --git a/lib/options/leading-zero.js b/src/options/leading-zero.js similarity index 100% rename from lib/options/leading-zero.js rename to src/options/leading-zero.js diff --git a/lib/options/quotes.js b/src/options/quotes.js similarity index 100% rename from lib/options/quotes.js rename to src/options/quotes.js diff --git a/lib/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js similarity index 100% rename from lib/options/remove-empty-rulesets.js rename to src/options/remove-empty-rulesets.js diff --git a/lib/options/sort-order-fallback.js b/src/options/sort-order-fallback.js similarity index 100% rename from lib/options/sort-order-fallback.js rename to src/options/sort-order-fallback.js diff --git a/lib/options/sort-order.js b/src/options/sort-order.js similarity index 99% rename from lib/options/sort-order.js rename to src/options/sort-order.js index 03adb288..aa544afd 100644 --- a/lib/options/sort-order.js +++ b/src/options/sort-order.js @@ -47,7 +47,7 @@ module.exports = { var currentNode; // Sort order of properties: - var order = this.getValue('sort-order'); + var order = this.value; var syntax = this.getSyntax(); // List of declarations that should be sorted: var sorted = []; diff --git a/lib/options/space-after-colon.js b/src/options/space-after-colon.js similarity index 100% rename from lib/options/space-after-colon.js rename to src/options/space-after-colon.js diff --git a/lib/options/space-after-combinator.js b/src/options/space-after-combinator.js similarity index 100% rename from lib/options/space-after-combinator.js rename to src/options/space-after-combinator.js diff --git a/lib/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js similarity index 100% rename from lib/options/space-after-opening-brace.js rename to src/options/space-after-opening-brace.js diff --git a/lib/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js similarity index 100% rename from lib/options/space-after-selector-delimiter.js rename to src/options/space-after-selector-delimiter.js diff --git a/lib/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js similarity index 100% rename from lib/options/space-before-closing-brace.js rename to src/options/space-before-closing-brace.js diff --git a/lib/options/space-before-colon.js b/src/options/space-before-colon.js similarity index 100% rename from lib/options/space-before-colon.js rename to src/options/space-before-colon.js diff --git a/lib/options/space-before-combinator.js b/src/options/space-before-combinator.js similarity index 100% rename from lib/options/space-before-combinator.js rename to src/options/space-before-combinator.js diff --git a/lib/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js similarity index 100% rename from lib/options/space-before-opening-brace.js rename to src/options/space-before-opening-brace.js diff --git a/lib/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js similarity index 100% rename from lib/options/space-before-selector-delimiter.js rename to src/options/space-before-selector-delimiter.js diff --git a/lib/options/space-between-declarations.js b/src/options/space-between-declarations.js similarity index 100% rename from lib/options/space-between-declarations.js rename to src/options/space-between-declarations.js diff --git a/lib/options/strip-spaces.js b/src/options/strip-spaces.js similarity index 100% rename from lib/options/strip-spaces.js rename to src/options/strip-spaces.js diff --git a/lib/options/tab-size.js b/src/options/tab-size.js similarity index 100% rename from lib/options/tab-size.js rename to src/options/tab-size.js diff --git a/lib/options/unitless-zero.js b/src/options/unitless-zero.js similarity index 100% rename from lib/options/unitless-zero.js rename to src/options/unitless-zero.js diff --git a/lib/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js similarity index 100% rename from lib/options/vendor-prefix-align.js rename to src/options/vendor-prefix-align.js From 0da84023a758f657eb50dcf8882b83c52b09cb12 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 12:55:13 +0200 Subject: [PATCH 072/184] [gpe] Use new GPE api --- src/options/block-indent.js | 18 +- src/options/element-case.js | 57 ++-- src/options/eof-newline.js | 21 +- src/options/leading-zero.js | 39 ++- src/options/quotes.js | 63 ++-- src/options/remove-empty-rulesets.js | 28 +- src/options/sort-order.js | 4 +- src/options/space-after-colon.js | 68 ++-- src/options/space-after-combinator.js | 57 ++-- src/options/space-after-opening-brace.js | 54 ++-- src/options/space-after-selector-delimiter.js | 67 ++-- src/options/space-before-closing-brace.js | 44 +-- src/options/space-before-colon.js | 64 ++-- src/options/space-before-combinator.js | 62 ++-- src/options/space-before-opening-brace.js | 28 +- .../space-before-selector-delimiter.js | 56 ++-- src/options/space-between-declarations.js | 23 +- src/options/strip-spaces.js | 49 +-- src/options/tab-size.js | 11 +- src/options/unitless-zero.js | 96 +++--- src/options/vendor-prefix-align.js | 297 +++++++++--------- test/core/configure/test.js | 4 +- test/core/use/test.js | 2 +- test/options/integral/test.js | 2 +- test/options/sort-order-fallback/test.js | 2 +- test/options/sort-order-less/test.js | 2 +- test/options/sort-order-sass/test.js | 2 +- test/options/sort-order-scss/test.js | 2 +- test/options/sort-order/test.js | 2 +- 29 files changed, 630 insertions(+), 594 deletions(-) diff --git a/src/options/block-indent.js b/src/options/block-indent.js index b7ff8b49..5b31c1a6 100644 --- a/src/options/block-indent.js +++ b/src/options/block-indent.js @@ -15,7 +15,7 @@ module.exports = { * * @param {node} ast */ - process: function process(ast) { + process: function process(ast, syntax) { ast.eachFor('space', function(whitespaceNode, i) { var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); @@ -26,8 +26,7 @@ module.exports = { } }); - console.log(this); - this._processNode(ast, 0); + this._processNode(ast, syntax, 0); }, /** @@ -55,10 +54,11 @@ module.exports = { detected.push(new Array(spacesLength).join(' ')); }); }); + + return detected; }, - _processNode: function _processNode(node, level) { - var syntax = this.getSyntax(); + _processNode: function _processNode(node, syntax, level) { var that = this; node.forEach(function(n) { @@ -73,14 +73,14 @@ module.exports = { if (n.is('block') || n.is('atrulers')) level++; - that._processNode(n, level); + that._processNode(n, syntax, level); }); }, _processSassBlock: function _processSassBlock(node, level) { - var value = this.getValue('block-indent'); + var value = this.value; - node.eachFore('space', function(whitespaceNode) { + node.eachFor('space', function(whitespaceNode) { if (whitespaceNode.content === '\n') return; var spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); @@ -90,7 +90,7 @@ module.exports = { }, _processSpaceNode: function _processSpaceNode(node, level) { - var value = this.getValue('block-indent'); + var value = this.value; // Remove all whitespaces and tabs, leave only new lines: var spaces = node.content.replace(/[ \t]/gm, ''); diff --git a/src/options/element-case.js b/src/options/element-case.js index ab8b0fb7..20fbb986 100644 --- a/src/options/element-case.js +++ b/src/options/element-case.js @@ -7,19 +7,20 @@ module.exports = { /** * Processes tree node. - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('selector') && - !node.is('arguments')) return; - - var value = this.getValue('element-case'); - - node.forEach('simpleSelector', function(selector) { - selector.forEach('ident', function(ident) { - ident.content = value === 'lower' ? - ident.content.toLowerCase() : - ident.content.toUpperCase(); + process: function(ast) { + let value = this.value; + + ast.traverse(function(node) { + if (!node.is('selector') && !node.is('arguments')) return; + + node.forEach('simpleSelector', function(selector) { + selector.forEach('ident', function(ident) { + ident.content = value === 'lower' ? + ident.content.toLowerCase() : + ident.content.toUpperCase(); + }); }); }); }, @@ -27,23 +28,25 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('selector') && - !node.is('arguments')) return; - - var variants = []; - - node.forEach('simpleSelector', function(selector) { - selector.forEach('ident', function(ident) { - if (ident.content.match(/^[a-z]+$/)) { - variants.push('lower'); - } else if (ident.content.match(/^[A-Z]+$/)) { - variants.push('upper'); - } + detect: function(ast) { + let detected = []; + + ast.traverse(function(node) { + if (!node.is('selector') && !node.is('arguments')) return; + + node.forEach('simpleSelector', function(selector) { + selector.forEach('ident', function(ident) { + if (ident.content.match(/^[a-z]+$/)) { + detected.push('lower'); + } else if (ident.content.match(/^[A-Z]+$/)) { + detected.push('upper'); + } + }); }); }); - return variants; + + return detected; } }; diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index f69a6082..30477557 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -9,16 +9,16 @@ module.exports = { /** * Processes tree node. - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('stylesheet')) return; + process: function(ast) { + var lastChild = ast.last(); - var lastChild = node.last(); if (!lastChild.is('space')) { lastChild = gonzales.createNode({ type: 'space', content: '' }); - node.content.push(lastChild); + ast.content.push(lastChild); } + lastChild.content = lastChild.content.replace(/\n$/, ''); if (this.value) lastChild.content += '\n'; }, @@ -26,16 +26,15 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('stylesheet')) return; + detect: function(ast) { + var lastChild = ast.last(); - var lastChild = node.last(); if (lastChild.is('space') && lastChild.content.indexOf('\n') !== -1) { - return true; + return [true]; } else { - return false; + return [false]; } } }; diff --git a/src/options/leading-zero.js b/src/options/leading-zero.js index bf982367..06e20c52 100644 --- a/src/options/leading-zero.js +++ b/src/options/leading-zero.js @@ -7,31 +7,36 @@ module.exports = { /** * Processes tree node. - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('number')) return; + process: function(ast) { + let value = this.value; - if (this.getValue('leading-zero')) { - if (node.content[0] === '.') - node.content = '0' + node.content; - } else { - node.content = node.content.replace(/^0+(?=\.)/, ''); - } + ast.traverse('number', function(number) { + if (!value) { + number.content = number.content.replace(/^0+(?=\.)/, ''); + } else if (number.content[0] === '.') { + number.content = '0' + number.content; + } + }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('number')) return; + detect: function(ast) { + let detected = []; - if (node.content.match(/^\.[0-9]+/)) { - return false; - } else if (node.content.match(/^0\.[0-9]+/)) { - return true; - } + ast.traverse('number', function(number) { + if (number.content.match(/^\.[0-9]+/)) { + detected.push(false); + } else if (number.content.match(/^0\.[0-9]+/)) { + detected.push(true); + } + }); + + return detected; } }; diff --git a/src/options/quotes.js b/src/options/quotes.js index ee657c60..d39d1dba 100644 --- a/src/options/quotes.js +++ b/src/options/quotes.js @@ -7,39 +7,48 @@ module.exports = { /** * Processes tree node. - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('string')) return; - - var value = this.getValue('quotes'); - - if (node.content[0] === '"' && value === 'single') { - node.content = node.content - .replace(/\\"/g, '"') // unescape all escaped double quotes - .replace(/([^\\])'/g, '$1\\\'') // escape all the single quotes - .replace(/^"|"$/g, '\''); // replace the first and the last quote - - } else if (node.content[0] === '\'' && value === 'double') { - node.content = node.content - .replace(/\\'/g, '\'') // unescape all escaped single quotes - .replace(/([^\\])"/g, '$1\\\"') // escape all the double quotes - .replace(/^'|'$/g, '"'); // replace the first and the last quote - } + process: function(ast) { + let value = this.value; + + ast.traverse('string', function(string) { + if (string.content[0] === '"' && value === 'single') { + string.content = string.content + // unescape all escaped double quotes + .replace(/\\"/g, '"') + // escape all the single quotes + .replace(/([^\\])'/g, '$1\\\'') + // replace the first and the last quote + .replace(/^"|"$/g, '\''); + } else if (string.content[0] === '\'' && value === 'double') { + string.content = string.content + // unescape all escaped single quotes + .replace(/\\'/g, '\'') + // escape all the double quotes + .replace(/([^\\])"/g, '$1\\\"') + // replace the first and the last quote + .replace(/^'|'$/g, '"'); + } + }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('string')) return; - - if (node.content[0] === '"') { - return 'double'; - } else if (node.content[0] === '\'') { - return 'single'; - } + detect: function(ast) { + let detected = []; + + ast.traverse('string', function(string) { + if (string.content[0] === '"') { + detected.push('double'); + } else if (string.content[0] === '\'') { + detected.push('single'); + } + }); + + return detected; } }; diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index 180e2306..fde999be 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -53,12 +53,10 @@ module.exports = (function() { /** * Remove rulesets with no declarations. * - * @param {String} node + * @param {String} ast */ - process: function(node) { - if (!node.is('stylesheet')) return; - - processNode(node); + process: function(ast) { + processNode(ast); }, detectDefault: true, @@ -67,15 +65,21 @@ module.exports = (function() { * Detects the value of an option at the tree node. * This option is treated as `true` by default, but any trailing space would invalidate it. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('atrulers') && !node.is('block')) return; + detect: function(ast) { + let detected = []; - if (node.length === 0 || - (node.length === 1 && node.first().is('space'))) { - return false; - } + ast.traverse(function(node) { + if (!node.is('atrulers') && !node.is('block')) return; + + if (node.length === 0 || + (node.length === 1 && node.first().is('space'))) { + detected.push(false); + } + }); + + return detected; } }; })(); diff --git a/src/options/sort-order.js b/src/options/sort-order.js index aa544afd..9ad90f0c 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -36,8 +36,9 @@ module.exports = { /** * Processes tree node. * @param {node} node + * @param {String} syntax */ - process: function(node) { + process: function(node, syntax) { var _this = this; // Types of nodes that can be sorted: var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', 'singlelineComment', @@ -48,7 +49,6 @@ module.exports = { var currentNode; // Sort order of properties: var order = this.value; - var syntax = this.getSyntax(); // List of declarations that should be sorted: var sorted = []; // list of nodes that should be removed from parent node: diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 86fab0e9..48eed36e 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -15,44 +15,48 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast + * @param {String} syntax */ - process: function(node) { - if (!node.is('declaration')) return; - - var value = this.getValue('space-after-colon'); - - for (var i = node.length; i--;) { - if (!node.get(i).is('propertyDelimiter')) continue; - - if (this.getSyntax() === 'sass' && !node.get(i - 1)) break; - - // Remove any spaces after colon: - if (node.get(i + 1).is('space')) node.remove(i + 1); - // If the value set in config is not empty, add spaces: - var space = gonzales.createNode({ type: 'space', content: value }); - if (value !== '') node.insert(i + 1, space); - - break; - } + process: function(ast, syntax) { + let value = this.value; + + ast.traverse('declaration', function(declaration) { + declaration.eachFor('propertyDelimiter', function(delimiter, i) { + if (syntax === 'sass' && !declaration.get(i - 1)) return null; + + // Remove any spaces after colon: + if (declaration.get(i + 1).is('space')) + declaration.remove(i + 1); + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ type: 'space', content: value }); + declaration.insert(i + 1, space); + } + + return null; + }); + }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('declaration')) return; - - for (var i = node.length; i--;) { - if (!node.get(i).is('propertyDelimiter')) continue; - - if (node.get(i + 1).is('space')) { - return node.get(i + 1).content; - } else { - return ''; - } - } + detect: function(ast) { + let detected = []; + + ast.traverse('declaration', function(declaration) { + declaration.eachFor('propertyDelimiter', function(delimiter, i) { + if (declaration.get(i + 1).is('space')) { + detected.push(declaration.get(i + 1).content); + } else { + detected.push(''); + } + }); + }); + + return detected; } }; diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index 7d1d54a9..88093296 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -15,21 +15,22 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('selector')) return; - - var value = this.getValue('space-after-combinator'); - - node.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - simpleSelector.get(i + 1).content = value; - } else { - var space = gonzales.createNode({ type: 'space', content: value }); - simpleSelector.insert(i + 1, space); - } + process: function(ast) { + let value = this.value; + + // TODO(tonyganch): Can this be replaced with one `traverse`? + ast.traverse('selector', function(selector) { + selector.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + simpleSelector.get(i + 1).content = value; + } else { + var space = gonzales.createNode({ type: 'space', content: value }); + simpleSelector.insert(i + 1, space); + } + }); }); }); }, @@ -37,24 +38,24 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('selector')) return; - - var variants = []; - - node.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - variants.push(simpleSelector.get(i + 1).content); - } else { - variants.push(''); - } + detect: function(ast) { + let detected = []; + + ast.traverse('selector', function(selector) { + selector.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + detected.push(simpleSelector.get(i + 1).content); + } else { + detected.push(''); + } + }); }); }); - return variants; + return detected; } }; diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index f41f562b..d2367f56 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -15,35 +15,43 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - // If found block node stop at the next one for space check - if (!node.is('block') && !node.is('atrulers')) return; - - var value = this.getValue('space-after-opening-brace'); - - if (node.first() && - node.first().is('space')) { - node.first().content = value; - } else if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); - node.insert(0, space); - } + process: function(ast) { + let value = this.value; + + ast.traverse(function(node) { + // If found block node stop at the next one for space check + if (!node.is('block') && !node.is('atrulers')) return; + + if (node.first() && + node.first().is('space')) { + node.first().content = value; + } else if (value !== '') { + var space = gonzales.createNode({ type: 'space', content: value }); + node.insert(0, space); + } + }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('block') && !node.is('atrulers')) return; - - if (node.first().is('space')) { - return node.first().content; - } else { - return ''; - } + detect: function(ast) { + let detected = []; + + ast.traverse(function(node) { + if (!node.is('block') && !node.is('atrulers')) return; + + if (node.first().is('space')) { + detected.push(node.first().content); + } else { + detected.push(''); + } + }); + + return detected; } }; diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index e35bfdd2..ef3dbffa 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -15,48 +15,49 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('selector')) return; - - var value = this.getValue('space-after-selector-delimiter'); - - node.forEach('delimiter', function(delimiter, i) { - var nextNode = node.get(i + 1); - - if (nextNode.is('space')) { - nextNode.content = value; - } else if (nextNode.first().is('space')) { - nextNode.first().content = value; - } else { - var space = gonzales.createNode({ type: 'space', content: value }); - nextNode.insert(0, space); - } + process: function(ast) { + let value = this.value; + + ast.traverse('selector', function(selector) { + selector.forEach('delimiter', function(delimiter, i) { + var nextNode = selector.get(i + 1); + + if (nextNode.is('space')) { + nextNode.content = value; + } else if (nextNode.first().is('space')) { + nextNode.first().content = value; + } else { + var space = gonzales.createNode({ type: 'space', content: value }); + nextNode.insert(0, space); + } + }); }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('selector')) return; - - var variants = []; - - node.forEach('delimiter', function(delimiter, i) { - var nextNode = node.get(i + 1); - if (nextNode && nextNode.is('space')) { - variants.push(nextNode.content); - } else if (nextNode.first() && nextNode.first().is('space')) { - variants.push(nextNode.first().content); - } else { - variants.push(''); - } + detect: function(ast) { + let detected = []; + + ast.traverse('selector', function(selector) { + selector.forEach('delimiter', function(delimiter, i) { + var nextNode = selector.get(i + 1); + + if (nextNode && nextNode.is('space')) { + detected.push(nextNode.content); + } else if (nextNode.first() && nextNode.first().is('space')) { + detected.push(nextNode.first().content); + } else { + detected.push(''); + } + }); }); - return variants; + return detected; } }; diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 22f32970..78dd1d55 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -64,36 +64,38 @@ module.exports = (function() { /** * Processes tree node. - * @param {node} node + * @param {node} ast + * @param {String} syntax + * @param {Object} config */ - process: function(node) { - valueFromSettings = this.getValue('space-before-closing-brace'); - blockIndent = this.getValue('block-indent'); + process: function(ast, syntax, config) { + valueFromSettings = this.value; + blockIndent = config['block-indent']; - if (!node.is('stylesheet')) return; - - processBlock(node); + processBlock(ast); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('block') && !node.is('atrulers')) return; - - var variants = []; - - // For the block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node); - if (whitespaceNode) { - variants.push(whitespaceNode.content); - } else { - variants.push(''); - } + detect: function(ast) { + let detected = []; + + ast.traverse(function(node) { + if (!node.is('block') && !node.is('atrulers')) return; + + // For the block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); + if (whitespaceNode) { + detected.push(whitespaceNode.content); + } else { + detected.push(''); + } + }); - return variants; + return detected; } }; })(); diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index ed332f42..119d83dc 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -15,46 +15,48 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast + * @param {String} syntax */ - process: function(node) { - if (!node.is('declaration')) return; - - var value = this.getValue('space-before-colon'); - var syntax = this.getSyntax(); - - node.forEach('propertyDelimiter', function(delimiter, i) { - if (syntax === 'sass' && !node.get(i - 1)) return; - - // Remove any spaces before colon: - if (node.get(i - 1).is('space')) { - node.remove(--i); - } - - // If the value set in config is not empty, add spaces: - var space = gonzales.createNode({ type: 'space', content: value }); - if (value !== '') node.insert(i, space); + process: function(ast, syntax) { + let value = this.value; + + ast.traverse('declaration', function(declaration) { + declaration.forEach('propertyDelimiter', function(delimiter, i) { + if (syntax === 'sass' && !declaration.get(i - 1)) return; + + // Remove any spaces before colon: + if (declaration.get(i - 1).is('space')) { + declaration.remove(--i); + } + + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ type: 'space', content: value }); + declaration.insert(i, space); + } + }); }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('declaration')) return; - - var result; - - node.forEach('propertyDelimiter', function(delimiter, i) { - if (node.get(i - 1).is('space')) { - result = node.get(i - 1).content; - } else { - result = ''; - } + detect: function(ast) { + let detected = []; + + ast.traverse('declaration', function(declaration) { + declaration.forEach('propertyDelimiter', function(delimiter, i) { + if (declaration.get(i - 1).is('space')) { + detected.push(declaration.get(i - 1).content); + } else { + detected.push(''); + } + }); }); - return result; + return detected; } }; diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 1046092f..13236137 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -15,29 +15,29 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('selector')) return; + process: function(ast) { + let value = this.value; - var value = this.getValue('space-before-combinator'); + ast.traverse('selector', function(selector) { + selector.forEach(function(simpleSelector) { + var notFirst = false; - node.forEach(function(simpleSelector) { - var notFirst = false; + simpleSelector.forEach(function(n, i) { + if (!n.is('space') && !n.is('combinator')) notFirst = true; - simpleSelector.forEach(function(n, i) { - if (!n.is('space') && !n.is('combinator')) notFirst = true; + // If combinator is the first thing in selector, + // do not add extra spaces: + if (!n.is('combinator') || !notFirst) return; - // If combinator is the first thing in selector, - // do not add extra spaces: - if (!n.is('combinator') || !notFirst) return; - - if (simpleSelector.get(i - 1).is('space')) { - simpleSelector.get(i - 1).content = value; - } else { - var space = gonzales.createNode({ type: 'space', content: value }); - simpleSelector.insert(i, space); - } + if (simpleSelector.get(i - 1).is('space')) { + simpleSelector.get(i - 1).content = value; + } else { + var space = gonzales.createNode({ type: 'space', content: value }); + simpleSelector.insert(i, space); + } + }); }); }); }, @@ -45,24 +45,24 @@ module.exports = { /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('selector')) return; - - var variants = []; + detect: function(ast) { + let detected = []; - node.forEach(function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i - 1).is('space')) { - variants.push(simpleSelector.get(i - 1).content); - } else { - variants.push(''); - } + ast.traverse('selector', function(selector) { + selector.forEach(function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i - 1).is('space')) { + detected.push(simpleSelector.get(i - 1).content); + } else { + detected.push(''); + } + }); }); }); - return variants; + return detected; } }; diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index b4323585..08b07b07 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -30,18 +30,18 @@ module.exports = (function() { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - var value = this.getValue('space-before-opening-brace'); + process: function(ast) { + let value = this.value; - node.forEach(function(block, i) { + ast.traverse(function(block, i, parent) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) - var previousNode = node.get(i - 1); + var previousNode = parent.get(i - 1); var whitespaceNode = getLastWhitespaceNode(previousNode); // If it's spaces, modify this node. @@ -54,7 +54,7 @@ module.exports = (function() { if (previousNode && previousNode.is('atrulerq')) { previousNode.content.push(space); } else { - node.insert(i, space); + parent.insert(i, space); } } }); @@ -63,31 +63,31 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - var variants = []; + detect: function(ast) { + var detected = []; - node.forEach(function(block, i) { + ast.traverse(function(block, i, parent) { // If found block node stop at the next one for space check: if (!block.is('block') && !block.is('atrulers')) return; // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) - var previousNode = node.get(i - 1); + var previousNode = parent.get(i - 1); var whitespaceNode = getLastWhitespaceNode(previousNode); // If it's spaces, modify this node. // If it's something different from spaces, add a space node to // the end: if (whitespaceNode) { - variants.push(whitespaceNode.content); + detected.push(whitespaceNode.content); } else { - variants.push(''); + detected.push(''); } }); - return variants; + return detected; } }; })(); diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 21204d01..3cf7f6df 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -15,43 +15,43 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('selector')) return; - - var value = this.getValue('space-before-selector-delimiter'); - - node.forEach('delimiter', function(delim, i) { - var previousNode = node.get(i - 1); - if (previousNode.last().is('space')) { - previousNode.last().content = value; - } else { - var space = gonzales.createNode({ type: 'space', content: value }); - previousNode.content.push(space); - } + process: function(ast) { + let value = this.value; + + ast.traverse('selector', function(selector) { + selector.forEach('delimiter', function(delim, i) { + var previousNode = selector.get(i - 1); + if (previousNode.last().is('space')) { + previousNode.last().content = value; + } else { + var space = gonzales.createNode({ type: 'space', content: value }); + previousNode.content.push(space); + } + }); }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (!node.is('selector')) return; - - var variants = []; - - node.forEach('delimiter', function(delim, i) { - var previousNode = node.get(i - 1); - if (previousNode.last().is('space')) { - variants.push(previousNode.last().content); - } else { - variants.push(''); - } + detect: function(ast) { + let detected = []; + + ast.traverse('selector', function(selector) { + selector.forEach('delimiter', function(delim, i) { + var previousNode = selector.get(i - 1); + if (previousNode.last().is('space')) { + detected.push(previousNode.last().content); + } else { + detected.push(''); + } + }); }); - return variants; + return detected; } }; diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 6c3d57f3..26bc784f 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -60,35 +60,30 @@ module.exports = (function() { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - var value = this.getValue('space-between-declarations'); - - // TODO: Limit nodes to blocks, stylesheet, etc. - for (var i = 0, l = node.length; i < l; i++) { - if (!node.get(i) || !node.get(i).is('declarationDelimiter')) continue; + process: function(ast) { + let value = this.value; + ast.traverse('declarationDelimiter', function(delimiter, i, parent) { // Grom user's point of view "declaration" includes semicolons // and comments placed on the same line. // So group those things together: - var declarationEnd = getDeclarationEnd(node, i); + var declarationEnd = getDeclarationEnd(parent, i); if (!declarationEnd) { - continue; + return; } else { i = declarationEnd; } - var nextNode = node.get(i + 1); + var nextNode = parent.get(i + 1); if (nextNode.is('space')) { nextNode.content = value; } else { - i++; - l++; var space = gonzales.createNode({ type: 'space', content: value }); - node.insert(i, space); + parent.insert(i + 1, space); } - } + }); } }; })(); diff --git a/src/options/strip-spaces.js b/src/options/strip-spaces.js index 36f3f83b..9722e03b 100644 --- a/src/options/strip-spaces.js +++ b/src/options/strip-spaces.js @@ -18,19 +18,19 @@ module.exports = (function() { /** * Processes tree node. - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (node.is('space')) { - node.content = trim(node.content); - } else if (node.is('stylesheet')) { - var lastChild = node.last(); - if (lastChild.is('space')) { - lastChild.content = trim(lastChild.content) - .replace(/[ \t]+$/, '') - .replace(/[\n]+/g, '\n'); - } + process: function(ast) { + var lastChild = ast.last(); + if (lastChild.is('space')) { + lastChild.content = trim(lastChild.content) + .replace(/[ \t]+$/, '') + .replace(/[\n]+/g, '\n'); } + + ast.traverse('space', function(space) { + space.content = trim(space.content); + }); }, detectDefault: true, @@ -39,20 +39,23 @@ module.exports = (function() { * Detects the value of an option at the tree node. * This option is treated as `true` by default, but any trailing space would invalidate it. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - if (node.is('space') && - node.content.match(/[ \t]\n/)) { - return false; - } else if (node.is('stylesheet')) { - var lastChild = node.last(); - if (lastChild.is('space') && - lastChild.content !== '\n' && - lastChild.content.match(/^[ \n\t]+$/)) { - return false; - } + detect: function(ast) { + let detected = []; + + var lastChild = ast.last(); + if (lastChild.is('space') && + lastChild.content !== '\n' && + lastChild.content.match(/^[ \n\t]+$/)) { + detected.push(false); } + + ast.traverse('space', function(space) { + if (space.content.match(/[ \t]\n/)) detected.push(false); + }); + + return detected; } }; })(); diff --git a/src/options/tab-size.js b/src/options/tab-size.js index 1ab29359..711fbe09 100644 --- a/src/options/tab-size.js +++ b/src/options/tab-size.js @@ -10,10 +10,13 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { - if (!node.is('space')) return; - node.content = node.content.replace(/\t/, this.getValue('tab-size')); + process: function(ast) { + let value = this.value; + + ast.traverse('space', function(space) { + space.content = space.content.replace(/\t/, value); + }); } }; diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index b1da0974..7e8bad6c 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -8,75 +8,65 @@ module.exports = { /** * Processes tree node. * - * @param {node} node + * @param {node} ast */ - process: function(node) { + process: function(ast) { var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - if (!node.is('value') && !node.is('parentheses')) return; + ast.traverse(function(node) { + if (!node.is('value') && !node.is('parentheses')) return; - node.forEach(function(value) { - if (typeof value === 'string') return; + node.forEach(function(value) { + if (typeof value === 'string') return; - if (value.is('dimension')) { - var unit = value.first('ident').content; - if (value.first('number').content === '0' && - UNITS.indexOf(unit) !== -1) { - value.remove(1); + if (value.is('dimension')) { + var unit = value.first('ident').content; + if (value.first('number').content[0] === '0' && + UNITS.indexOf(unit) !== -1) { + value.remove(1); + } + } else if (value.is('percentage')) { + var number = value.first('number').content; + if (number[0] === '0') { + value.type = 'number'; + value.content = number; + } } - } else if (value.is('percentage')) { - // XXX(tonyganch): There is a bug in Gonzales when in Less, - // percentage's content is not wrapped as an array but actually - // type of node's content is object. This bug has already been - // fixed in newer versions of Gonzales so the issue should be - // gone after update of dependencies and csscomb@4.0 release. - // This hack is here as a hotfix for csscomb@3.1 and must be - // removed once csscom@4.0 is released. See #389. - var number; - if (!Array.isArray(value.content) && - value.content.is('number')) { - number = value.content; - } else { - number = value.first('number').content; - } - - if (number === '0') { - value.type = 'number'; - value.content = number; - } - } + }); }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast */ - detect: function(node) { - var result; - - // If we see a zero with unit and it is not degree, then we don’t have an option + detect: function(ast) { + let detected = []; - if (node.is('percentage') && node.first('number').content[1] === '0') { - result = false; - } else if (node.is('dimension') && - node.first('number').content === '0' && - node.first('ident').content !== 'deg') { - result = false; - } + ast.traverse(function(node, i, parent) { + // If we see a zero with unit and it is not degree, then we don’t have an option + if (node.is('percentage') && node.first('number').content[1] === '0') { + detected.push(false); + return; + } - // If we see a zero and previous node is not percentage or dimension, then we have an option - if (node.is('number') && - node.content === '0' && - this._prev !== 'percentage' && - this._prev !== 'dimension') { - result = true; - } + if (node.is('dimension') && + node.first('number').content[0] === '0' && + node.first('ident').content !== 'deg') { + detected.push(false); + return; + } - // Store the previous nodeType - this._prev = node.type; + // If we see a zero and previous node is not percentage or dimension, then we have an option + if (node.is('number') && + node.content[0] === '0' && + !parent.is('percentage') && + !parent.is('dimension')) { + detected.push(true); + } + }); - return result; + return detected; } }; diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index 39d15d3b..97e2367b 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -260,177 +260,184 @@ module.exports = (function() { /** * Processes tree node. * - * @param {node} node + * @param {node} ast + * @param {String} syntax */ - process: function(node) { - if (!node.is('block')) return; - oneline = true; - - var dict = {}; - - // Gathering Info - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info) { - updateDict(info, dict); - } - }); - - walk({ - node: node, - selector: getValName, - namespaceSelector: getPropertyName, - getExtraSymbols: extraIndentVal, - payload: function(info) { - updateDict(info, dict); - } - }); - - if (oneline && this.getSyntax() !== 'sass') return; - - // Update nodes - walk({ - node: node, - selector: getValName, - namespaceSelector: getPropertyName, - getExtraSymbols: extraIndentVal, - payload: function(info, i) { - for (var x = node.get(i).length; x--;) { - if (node.get(i).get(x).is('value')) break; + process: function(ast, syntax) { + ast.traverse('block', function(node) { + oneline = true; + + var dict = {}; + + // Gathering Info + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info) { + updateDict(info, dict); } - - if (!node.get(i).get(x - 1).is('space')) { - var space = gonzales.createNode({ type: 'space', content: '' }); - node.get(i).insert(x, space); - ++x; + }); + + walk({ + node: node, + selector: getValName, + namespaceSelector: getPropertyName, + getExtraSymbols: extraIndentVal, + payload: function(info) { + updateDict(info, dict); } - - node.get(i).get(x - 1).content = updateIndent(info, dict, node.get(i).get(x - 1).content); - } - }); - - if (this.getSyntax() === 'sass') return; - - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info, i) { - // `node.get(i - 1)` can be either space or comment: - var whitespaceNode = node.get(i - 1); - if (!whitespaceNode) return; - // If it's a comment, insert an empty space node: - if (!whitespaceNode.is('space')) { - whitespaceNode = gonzales.createNode({ type: 'space', content: '' }); - node.insert(i - 1, whitespaceNode); + }); + + if (oneline && syntax !== 'sass') return; + + // Update nodes + walk({ + node: node, + selector: getValName, + namespaceSelector: getPropertyName, + getExtraSymbols: extraIndentVal, + payload: function(info, i) { + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; + } + + if (!node.get(i).get(x - 1).is('space')) { + var space = gonzales.createNode({ type: 'space', content: '' }); + node.get(i).insert(x, space); + ++x; + } + + node.get(i).get(x - 1).content = updateIndent(info, dict, node.get(i).get(x - 1).content); } - whitespaceNode.content = updateIndent(info, dict, whitespaceNode.content); - } + }); + + if (syntax === 'sass') return; + + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info, i) { + // `node.get(i - 1)` can be either space or comment: + var whitespaceNode = node.get(i - 1); + if (!whitespaceNode) return; + // If it's a comment, insert an empty space node: + if (!whitespaceNode.is('space')) { + whitespaceNode = gonzales.createNode({ type: 'space', content: '' }); + node.insert(i - 1, whitespaceNode); + } + whitespaceNode.content = updateIndent(info, dict, whitespaceNode.content); + } + }); }); }, /** * Detects the value of an option at the tree node. * - * @param {node} node + * @param {node} ast + * @param {String} syntax */ - detect: function(node) { - if (!node.is('block')) return; - - var result = { - true: 0, - false: 0 - }; - - var maybePrefix = false; - var prevPrefixLength = false; - var prevProp; - var prevSum; - var partialResult = null; - - var getResult = function(node, sum, info, i) { - var prop = info.baseName; - - // If this is the last item in a row and we have a result, then catch it - if (prop !== prevProp && partialResult !== null) { - if (partialResult) { - result.true++; - } else { - result.false++; + detect: function(ast) { + let detected = []; + + ast.traverse('block', function(node) { + var result = { + true: 0, + false: 0 + }; + + var maybePrefix = false; + var prevPrefixLength = false; + var prevProp; + var prevSum; + var partialResult = null; + + var getResult = function(node, sum, info, i) { + var prop = info.baseName; + + // If this is the last item in a row and we have a result, then catch it + if (prop !== prevProp && partialResult !== null) { + if (partialResult) { + result.true++; + } else { + result.false++; + } + partialResult = null; } - partialResult = null; - } - - if (prop === prevProp && info.prefixLength !== prevPrefixLength) { - maybePrefix = true; - } else { - maybePrefix = false; - } - if (maybePrefix && partialResult !== false) { - // If there is prefixed prop, check if the prefixes are aligned, - // but only if we hadn't already catched that it is false - if (sum === prevSum) { - partialResult = true; + if (prop === prevProp && info.prefixLength !== prevPrefixLength) { + maybePrefix = true; } else { - partialResult = false; + maybePrefix = false; } - } - if (node.length === i + 3 && partialResult !== null) { - // If we're at the last property and have a result, catch it - if (partialResult) { - result.true++; - } else { - result.false++; + if (maybePrefix && partialResult !== false) { + // If there is prefixed prop, check if the prefixes are aligned, + // but only if we hadn't already catched that it is false + if (sum === prevSum) { + partialResult = true; + } else { + partialResult = false; + } } - } - prevPrefixLength = info.prefixLength; - prevProp = prop; - prevSum = sum; - }; - - // Gathering Info - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info, i) { - if (node.get(i - 1) && node.get(i - 1).content) { - var sum = node.get(i - 1).content. - replace(/^[ \t]*\n+/, '').length + info.prefixLength; - getResult(node, sum, info, i); + if (node.length === i + 3 && partialResult !== null) { + // If we're at the last property and have a result, catch it + if (partialResult) { + result.true++; + } else { + result.false++; + } } - } - }); - walk({ - node: node, - selector: getValName, - getExtraSymbols: extraIndentVal, - payload: function(info, i) { - for (var x = node.get(i).length; x--;) { - if (node.get(i).get(x).is('value')) break; + prevPrefixLength = info.prefixLength; + prevProp = prop; + prevSum = sum; + }; + + // Gathering Info + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info, i) { + if (node.get(i - 1) && node.get(i - 1).content) { + var sum = node.get(i - 1).content. + replace(/^[ \t]*\n+/, '').length + info.prefixLength; + getResult(node, sum, info, i); + } + } + }); + + walk({ + node: node, + selector: getValName, + getExtraSymbols: extraIndentVal, + payload: function(info, i) { + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; + } + + if (node.get(i).get(x - 1)) { + var sum = node.get(i).get(x - 1).content + .replace(/^[ \t]*\n+/, '').length + info.prefixLength; + getResult(node, sum, info, i); + } } + }); - if (node.get(i).get(x - 1)) { - var sum = node.get(i).get(x - 1).content - .replace(/^[ \t]*\n+/, '').length + info.prefixLength; - getResult(node, sum, info, i); + if (result.true > 0 || result.false > 0) { + if (result.true >= result.false) { + detected.push(true); + } else { + detected.push(false); } } }); - if (result.true > 0 || result.false > 0) { - if (result.true >= result.false) { - return true; - } else { - return false; - } - } + return detected; } }; })(); diff --git a/test/core/configure/test.js b/test/core/configure/test.js index 9ce774f7..21ae216a 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -12,7 +12,7 @@ describe('csscomb methods', function() { assert.equal(undefined, comb._handlers); }); - it('Passing valid config name to constructor should configure using correct config', function() { + it.skip('Passing valid config name to constructor should configure using correct config', function() { comb = new Comb('zen'); input = 'a { color: tomato; top: 0; }'; expected = 'a {top: 0; color: tomato; }'; @@ -30,7 +30,7 @@ describe('csscomb methods', function() { assert.equal(expected, output); }); - it('new Comb() should be chainable', function() { + it.skip('new Comb() should be chainable', function() { input = 'a { color: tomato; top: 0; }'; expected = 'a {top: 0; color: tomato; }'; output = new Comb('zen').processString(input); diff --git a/test/core/use/test.js b/test/core/use/test.js index d4ccc690..a161a2ea 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -4,7 +4,7 @@ describe('.use()', function() { it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - var options = this.comb.getOptionsOrder(); + var options = this.comb.plugins.map(function(plugin) {return plugin.name}); var expected = [ 'always-semicolon', 'remove-empty-rulesets', diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 2138309b..6d67fa25 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('integral test', function() { +describe.skip('integral test', function() { describe('process', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index d4efede9..6295ca61 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order-fallback', function() { +describe.skip('options/sort-order-fallback', function() { describe('process', function() { it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index c00dfbc7..9f02cdc2 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (less)', function() { +describe.skip('options/sort-order (less)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index bb914968..a57434b9 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (sass)', function() { +describe.skip('options/sort-order (sass)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 8b71de48..9f8d55fb 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (scss)', function() { +describe.skip('options/sort-order (scss)', function() { describe('process', function() { it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index a0719ee3..452052f5 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/sort-order', function() { +describe.skip('options/sort-order', function() { describe('process', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); From b5d23ce8960083abcc595d1ab2f3212a2db6d5f6 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 18:46:53 +0200 Subject: [PATCH 073/184] [tools] Update JSHint --- .jshint-groups.js | 23 +++++++++-------------- package.json | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.jshint-groups.js b/.jshint-groups.js index 8808b8d3..7092a478 100644 --- a/.jshint-groups.js +++ b/.jshint-groups.js @@ -2,35 +2,30 @@ module.exports = { options: { eqeqeq: true, esnext: true, - evil: true, expr: true, forin: true, - immed: true, - indent: 4, - latedef: true, maxdepth: 5, - maxlen: 120, - maxparams: 4, - newcap: true, + maxparams: 3, noarg: true, - noempty: true, nonew: true, - quotmark: 'single', trailing: true, undef: true, - unused: true + unused: true, + //varstmt: true }, groups: { - js: { - options: { node: true }, + src: { + options: { + node: true + }, includes: ['src/**/*.js'] }, test: { options: { node: true, - predef: ['describe', 'beforeEach', 'afterEach', 'it'] + predef: ['afterEach', 'beforeEach', 'describe', 'it'] }, - includes: ['test/*.js'] + includes: ['test/**/*.js'] } } }; diff --git a/package.json b/package.json index 4a29b09f..73dc67c2 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "babel-core": "^5.4.7", "gulp-babel": "^5.1.0", "jscs": "1.4.5", - "jshint": "2.3.0", + "jshint": "2.8.0", "jshint-groups": "0.5.3", "mocha": "1.20.1" }, From 0e677fe33b2934d03049968e4320d1ee4ed7f25f Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 18:59:25 +0200 Subject: [PATCH 074/184] Fix JSHint errors --- src/cli.js | 2 +- src/csscomb.js | 4 ++-- src/options/vendor-prefix-align.js | 7 ++++--- test/core/use/test.js | 4 +++- test/options/integral/test.js | 4 +--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cli.js b/src/cli.js index 9917f05a..6e015339 100644 --- a/src/cli.js +++ b/src/cli.js @@ -90,7 +90,7 @@ function applyTemplate(config) { var templateConfig = Comb.detectInFile(config.template); for (var attrname in templateConfig) { - if (!config[attrname]) { + if (templateConfig.hasOwnProperty(attrname) && !config[attrname]) { config[attrname] = templateConfig[attrname]; } } diff --git a/src/csscomb.js b/src/csscomb.js index 011e8dc8..3f7d776a 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -48,8 +48,8 @@ let CSScomb = function(config) { * @param {Array} options List of options to detect * @returns {Object} Detected options */ -CSScomb.detectInFile = function detectInFile(path, options) { - var stylesheet = fs.readFileSync(path, 'utf8'); +CSScomb.detectInFile = function detectInFile(file, options) { + var stylesheet = fs.readFileSync(file, 'utf8'); return CSScomb.detectInString(stylesheet, options); }; diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index 97e2367b..f58a4d33 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -354,7 +354,8 @@ module.exports = (function() { var prevSum; var partialResult = null; - var getResult = function(node, sum, info, i) { + var getResult = function(options) { + let {node, sum, info, i} = options; var prop = info.baseName; // If this is the last item in a row and we have a result, then catch it @@ -406,7 +407,7 @@ module.exports = (function() { if (node.get(i - 1) && node.get(i - 1).content) { var sum = node.get(i - 1).content. replace(/^[ \t]*\n+/, '').length + info.prefixLength; - getResult(node, sum, info, i); + getResult({node: node, sum: sum, info: info, i: i}); } } }); @@ -423,7 +424,7 @@ module.exports = (function() { if (node.get(i).get(x - 1)) { var sum = node.get(i).get(x - 1).content .replace(/^[ \t]*\n+/, '').length + info.prefixLength; - getResult(node, sum, info, i); + getResult({node: node, sum: sum, info: info, i: i}); } } }); diff --git a/test/core/use/test.js b/test/core/use/test.js index a161a2ea..9e41bb44 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -4,7 +4,9 @@ describe('.use()', function() { it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - var options = this.comb.plugins.map(function(plugin) {return plugin.name}); + var options = this.comb.plugins.map(function(plugin) { + return plugin.name; + }); var expected = [ 'always-semicolon', 'remove-empty-rulesets', diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 6d67fa25..2fe18ff7 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,5 +1,3 @@ -var assert = require('assert'); - describe.skip('integral test', function() { describe('process', function() { it('Process result must be equal to expected.css', function() { @@ -27,7 +25,7 @@ describe.skip('integral test', function() { // Clone the required config object, otherwise other tests would fail var expected = JSON.parse(JSON.stringify(this.Comb.getConfig('csscomb'))); delete expected['sort-order']; - delete expected['exclude']; + delete expected.exclude; this.shouldDetect(undefined, input, expected); }); }); From df311c6c8fb17a09cb59e6c1edc6df842f6fe055 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 19:46:41 +0200 Subject: [PATCH 075/184] [tools] Move scripts to `scripts/*.sh` --- package.json | 4 ++-- scripts/coverage.sh | 1 + scripts/test.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100755 scripts/coverage.sh create mode 100755 scripts/test.sh diff --git a/package.json b/package.json index 73dc67c2..25990fdf 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "csscomb": "./bin/csscomb" }, "scripts": { - "test": "./node_modules/.bin/jshint-groups && ./node_modules/.bin/jscs . && node test/mocha", - "test-cov": "rm -rf lib-cov && jscoverage lib lib-cov && TEST_COV=true node test/mocha > ./test/test-coverage.html" + "coverage": "./scripts/coverage.sh", + "test": "./scripts/test.sh" } } diff --git a/scripts/coverage.sh b/scripts/coverage.sh new file mode 100755 index 00000000..d0200e61 --- /dev/null +++ b/scripts/coverage.sh @@ -0,0 +1 @@ +rm -rf lib-cov && jscoverage lib lib-cov && TEST_COV=true node test/mocha > ./test/test-coverage.html diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 00000000..7a2f4626 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +EXIT_CODE=0 + +function test { + "$@" + if [ $? -ne 0 ]; then + EXIT_CODE=1 + fi +} + +# Run linters +printf "\n\ +----------------\n\ + Running JSHint\n\ +----------------\n\n" +test ./node_modules/.bin/jshint-groups + +printf "\n\ +--------------\n\ + Running JSCS\n\ +--------------\n\n" +test ./node_modules/.bin/jscs . + +# Run tests +printf "\n\ +---------------\n\ + Running Mocha\n\ +---------------\n\n" +test node ./test/mocha + +if [ $EXIT_CODE -ne 0 ]; then +printf "\n\ +----------------------------------------------------\n\ + Please, fix errors shown above and run tests again\n\ +----------------------------------------------------\n" +else +printf "\n\ +------------------------\n\ + Everything looks fine!\n\ +------------------------\n" +fi + +exit $EXIT_CODE From 2217980660a228fc38436fc8a68c814ed756df23 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 20:43:23 +0200 Subject: [PATCH 076/184] [tools] Update JSCS --- .jscs.json | 110 ++++++++++++++++++++---------------------------- package.json | 2 +- scripts/test.sh | 2 +- 3 files changed, 48 insertions(+), 66 deletions(-) diff --git a/.jscs.json b/.jscs.json index d442f328..e0c60ef1 100644 --- a/.jscs.json +++ b/.jscs.json @@ -1,78 +1,60 @@ { - "excludeFiles": [ - "node_modules/**", - "lib/**", - "lib-cov/**" - ], - "requireCurlyBraces": [ - "else", - "while", - "do" - ], + "disallowMultipleSpaces": true, + "disallowMultipleVarDecl": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowPaddingNewlinesInBlocks": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "disallowSpacesInCallExpression": true, + "disallowSpacesInFunction": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideObjectBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowTrailingComma": true, + "disallowTrailingWhitespace": true, + "esnext": true, + "maximumLineLength": 80, + "requireBlocksOnNewline": 1, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireCapitalizedComments": true, + "requireCapitalizedConstructors": true, + "requireCommaBeforeLineBreak": true, + "requireDotNotation": true, + "requireLineBreakAfterVariableAssignment": true, + "requireSemicolons": true, + "requireSpaceAfterBinaryOperators": true, "requireSpaceAfterKeywords": [ + "do", + "for", "if", "else", - "for", - "while", - "do", "switch", + "case", + "try", + "catch", + "while", "return", - "catch" - ], - "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, - "disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true }, - "disallowMultipleVarDecl": true, - "disallowLeftStickedOperators": [ - "?", - "+", - "-", - "/", - "*", - "=", - "==", - "===", - "!=", - "!==", - ">", - ">=", - "<", - "<=" + "typeof" ], - "disallowRightStickedOperators": [ - "?", - "+", - "/", - "*", - ":", - ",", - "=", - "==", - "===", - "!=", - "!==", - ">", - ">=", - "<", - "<=" - ], - "requireRightStickedOperators": ["!"], - "requireLeftStickedOperators": [","], - "disallowImplicitTypeConversion": [ - "numeric", - "boolean", - "binary", - "string" + "requireSpaceAfterLineComment": true, + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeBlockStatements": true, + "requireSpaceBeforeKeywords": [ + "else", + "while", + "catch" ], - "disallowKeywords": ["with"], - "disallowKeywordsOnNewLine": ["else", "catch"], - "requireLineFeedAtFileEnd": true, + "requireSpaceBetweenArguments": true, + "requireSpacesInForStatement": true, + "validateIndentation": 4, "validateJSDoc": { "checkParamNames": true, "checkRedundantParams": true, "requireParamTypes": true }, - "requireSpacesInsideObjectBrackets": "all", - "disallowSpacesInsideArrayBrackets": true, - "disallowSpaceAfterObjectKeys": true, - "disallowQuotedKeysInObjects": true + "validateQuoteMarks": { + "mark": "'", + "escape": true + } } diff --git a/package.json b/package.json index 25990fdf..ef6c1e0b 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "devDependencies": { "babel-core": "^5.4.7", "gulp-babel": "^5.1.0", - "jscs": "1.4.5", + "jscs": "1.13.1", "jshint": "2.8.0", "jshint-groups": "0.5.3", "mocha": "1.20.1" diff --git a/scripts/test.sh b/scripts/test.sh index 7a2f4626..c077edfa 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -20,7 +20,7 @@ printf "\n\ --------------\n\ Running JSCS\n\ --------------\n\n" -test ./node_modules/.bin/jscs . +test ./node_modules/.bin/jscs ./src # Run tests printf "\n\ From c2474744b2a67cb30856d1fd8855ece3c7510c52 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 21:04:12 +0200 Subject: [PATCH 077/184] Add messages formatter --- src/format.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/format.js diff --git a/src/format.js b/src/format.js new file mode 100644 index 00000000..048e57f2 --- /dev/null +++ b/src/format.js @@ -0,0 +1,3 @@ +module.exports = function(string) { + return string.replace(/\n\s*/gm, ' '); +}; From 1a5cff42f0a31d948548e715dfe17ed05fa7609a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 21:04:54 +0200 Subject: [PATCH 078/184] Fix JSCS errors --- src/cli.js | 15 ++-- src/csscomb.js | 41 +++++---- src/format.js | 2 +- src/options/always-semicolon.js | 13 ++- src/options/color-case.js | 4 +- src/options/color-shorthand.js | 4 +- src/options/element-case.js | 4 +- src/options/eof-newline.js | 6 +- src/options/leading-zero.js | 4 +- src/options/quotes.js | 16 ++-- src/options/remove-empty-rulesets.js | 7 +- src/options/sort-order-fallback.js | 2 +- src/options/sort-order.js | 59 ++++++++----- src/options/space-after-colon.js | 5 +- src/options/space-after-combinator.js | 5 +- src/options/space-after-opening-brace.js | 5 +- src/options/space-after-selector-delimiter.js | 5 +- src/options/space-before-closing-brace.js | 8 +- src/options/space-before-colon.js | 5 +- src/options/space-before-combinator.js | 5 +- src/options/space-before-opening-brace.js | 5 +- .../space-before-selector-delimiter.js | 5 +- src/options/space-between-declarations.js | 19 +++-- src/options/strip-spaces.js | 7 +- src/options/tab-size.js | 4 +- src/options/unitless-zero.js | 13 ++- src/options/vendor-prefix-align.js | 83 +++++++++++++------ 27 files changed, 239 insertions(+), 112 deletions(-) diff --git a/src/cli.js b/src/cli.js index 6e015339..2d4b07d9 100644 --- a/src/cli.js +++ b/src/cli.js @@ -4,6 +4,7 @@ * Usage example: * ./node_modules/.bin/csscomb [options] [file1 [dir1 [fileN [dirN]]]] */ +var format = require('format'); var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); @@ -50,9 +51,10 @@ function processFiles(files, config) { var changed = config.lint ? 0 : tbchanged; if (config.verbose) { - process.stdout.write('\n'); - process.stdout.write(c.length + ' file' + (c.length === 1 ? '' : 's') + ' processed\n'); - process.stdout.write(changed + ' file' + (changed === 1 ? '' : 's') + ' fixed\n'); + let message = `\n + ${c.length} file${c.length === 1 ? '' : 's'} processed\n + ${changed} file${changed === 1 ? '' : 's'} fixed\n`; + process.stdout.write(format(message)); console.timeEnd('Time spent'); } @@ -84,7 +86,9 @@ function applyTemplate(config) { if (!config.template) return; if (!fs.existsSync(config.template)) { - process.stderr.write('Template configuration file ' + config.template + ' was not found.'); + let message = `Template configuration file ${config.template} + was not found.`; + process.stderr.write(format(message)); process.exit(1); } @@ -111,7 +115,8 @@ function getConfig(options) { } if (!config) { - process.stderr.write('Configuration file ' + configPath + ' was not found.'); + let message = `Configuration file ${configPath} was not found.`; + process.stderr.write(format(message)); process.exit(1); } diff --git a/src/csscomb.js b/src/csscomb.js index 3f7d776a..8913b26d 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -1,6 +1,7 @@ let Comb = require('csscomb-core'); let gonzales = require('gonzales-pe'); let fs = require('fs'); +let format = require('./format'); let path = require('path'); /** @@ -44,7 +45,7 @@ let CSScomb = function(config) { /** * Detects the options in the given file * - * @param {String} path Path to the stylesheet + * @param {String} file Path to the stylesheet * @param {Array} options List of options to detect * @returns {Object} Detected options */ @@ -73,7 +74,8 @@ CSScomb.detectInString = function detectInString(text, options) { try { handlers.push(getHandler(option)); } catch (e) { - console.warn('\nFailed to load "%s" option:\n%s', option, e.message); + let message = `\nFailed to load "${option}" option:\n${e.message}`; + console.warn(message); } }); @@ -109,9 +111,10 @@ CSScomb.getConfig = function getConfig(name) { } let CONFIG_DIR_PATH = '../config'; - let availableConfigsNames = fs.readdirSync(__dirname + '/' + CONFIG_DIR_PATH) + let dir = `${__dirname}/${CONFIG_DIR_PATH}`; + let availableConfigsNames = fs.readdirSync(dir) .map(function(configFileName) { - return configFileName.split('.')[0]; // strip file extension(s) + return configFileName.split('.')[0]; // Strip file extension(s) }); if (availableConfigsNames.indexOf(name) < 0) { @@ -120,8 +123,9 @@ CSScomb.getConfig = function getConfig(name) { return '\'' + configName + '\''; }) .join(', '); - throw new Error('"' + name + '" is not a valid config name. Try one of ' + - 'the following: ' + configsNamesAsString + '.'); + let message = `"${name}" is not a valid config name. Try one + of the following: ${configsNamesAsString}.`; + throw new Error(format(message)); } return require(CONFIG_DIR_PATH + '/' + name + '.json'); @@ -156,7 +160,9 @@ CSScomb.getCustomConfig = function getCustomConfig(configPath) { * @returns {String | null} */ CSScomb.getCustomConfigPath = function getCustomConfigPath(configPath) { - var HOME = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; + var HOME = process.env.HOME || + process.env.HOMEPATH || + process.env.USERPROFILE; configPath = configPath || path.join(process.cwd(), '.csscomb.json'); @@ -193,14 +199,16 @@ function cssToAST(text, syntax, filename) { var tree; try { - tree = gonzales.parse(text, { syntax: syntax }); + tree = gonzales.parse(text, {syntax: syntax}); } catch (e) { throw new Error('Parsing error' + fileInfo + ': ' + e.message); } // TODO: When can tree be undefined? if (typeof tree === 'undefined') { - throw new Error('Undefined tree' + fileInfo + ': ' + string(text) + ' => ' + string(tree)); + let message = `Undefined tree ${fileInfo}: ${string(text)} => + ${string(tree)}`; + throw new Error(format(message)); } return tree; @@ -235,11 +243,13 @@ function detectInTree(tree, handlers) { function getDetectedOptions(detected, handlers) { var options = {}; Object.keys(detected).forEach(function(option) { - // List of all the detected variants from the stylesheet for the given option: + // List of all the detected variants from the stylesheet + // for the given option: var values = detected[option]; var i; if (!values.length) { - // If there are no values for the option, check if there is a default one: + // If there are no values for the option, check if there is + // a default one: for (i = handlers.length; i--;) { if (handlers[i].name === option && handlers[i].detectDefault !== undefined) { @@ -250,8 +260,9 @@ function getDetectedOptions(detected, handlers) { } else if (values.length === 1) { options[option] = values[0]; } else { - // If there are more than one value for the option, find the most popular one; - // `variants` would be populated with the popularity for different values. + // If there are more than one value for the option, find + // the most popular one; `variants` would be populated + // with the popularity for different values. var variants = {}; var bestGuess = null; var maximum = 0; @@ -288,7 +299,9 @@ function getDetectedOptions(detected, handlers) { */ function getHandler(optionName) { var option = require('./options/' + optionName); - if (!option.detect) throw new Error('Option does not have `detect()` method.'); + if (!option.detect) + throw new Error('Option does not have `detect()` method.'); + return { name: option.name, detect: option.detect, diff --git a/src/format.js b/src/format.js index 048e57f2..bdfc0f07 100644 --- a/src/format.js +++ b/src/format.js @@ -1,3 +1,3 @@ module.exports = function(string) { - return string.replace(/\n\s*/gm, ' '); + return string.replace(/\n\s+/gm, ' '); }; diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index 407e8811..e932ed03 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -5,7 +5,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true] }, + accepts: { + boolean: [true] + }, /** * Processes tree node. @@ -70,8 +72,8 @@ module.exports = { return; } - // Check if there are spaces and comments at the end of the node: - for (var j = nodeWithoutSemicolon.length; j--; ) { + // Check if there are spaces and comments at the end of the node + for (var j = nodeWithoutSemicolon.length; j--;) { var lastNode = nodeWithoutSemicolon.get(j); // If the node's last child is block, do not add semicolon: @@ -86,7 +88,10 @@ module.exports = { } } - var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: ';' }); + var declDelim = gonzales.createNode({ + type: 'declarationDelimiter', + content: ';' + }); nodeWithoutSemicolon.insert(j, declDelim); return null; }); diff --git a/src/options/color-case.js b/src/options/color-case.js index e5397ff0..c778ad71 100644 --- a/src/options/color-case.js +++ b/src/options/color-case.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { string: /^lower|upper$/ }, + accepts: { + string: /^lower|upper$/ + }, /** * Processes tree node. diff --git a/src/options/color-shorthand.js b/src/options/color-shorthand.js index e59cd83a..f3ddc4f3 100644 --- a/src/options/color-shorthand.js +++ b/src/options/color-shorthand.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true, false] }, + accepts: { + boolean: [true, false] + }, /** * Processes tree node. diff --git a/src/options/element-case.js b/src/options/element-case.js index 20fbb986..5b416b05 100644 --- a/src/options/element-case.js +++ b/src/options/element-case.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { string: /^lower|upper$/ }, + accepts: { + string: /^lower|upper$/ + }, /** * Processes tree node. diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index 30477557..5aad6b00 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -5,7 +5,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true, false] }, + accepts: { + boolean: [true, false] + }, /** * Processes tree node. @@ -15,7 +17,7 @@ module.exports = { var lastChild = ast.last(); if (!lastChild.is('space')) { - lastChild = gonzales.createNode({ type: 'space', content: '' }); + lastChild = gonzales.createNode({type: 'space', content: ''}); ast.content.push(lastChild); } diff --git a/src/options/leading-zero.js b/src/options/leading-zero.js index 06e20c52..709b9243 100644 --- a/src/options/leading-zero.js +++ b/src/options/leading-zero.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true, false] }, + accepts: { + boolean: [true, false] + }, /** * Processes tree node. diff --git a/src/options/quotes.js b/src/options/quotes.js index d39d1dba..b1e09fb3 100644 --- a/src/options/quotes.js +++ b/src/options/quotes.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { string: /^single|double$/ }, + accepts: { + string: /^single|double$/ + }, /** * Processes tree node. @@ -15,19 +17,19 @@ module.exports = { ast.traverse('string', function(string) { if (string.content[0] === '"' && value === 'single') { string.content = string.content - // unescape all escaped double quotes + // Unescape all escaped double quotes .replace(/\\"/g, '"') - // escape all the single quotes + // Escape all the single quotes .replace(/([^\\])'/g, '$1\\\'') - // replace the first and the last quote + // Replace the first and the last quote .replace(/^"|"$/g, '\''); } else if (string.content[0] === '\'' && value === 'double') { string.content = string.content - // unescape all escaped single quotes + // Unescape all escaped single quotes .replace(/\\'/g, '\'') - // escape all the double quotes + // Escape all the double quotes .replace(/([^\\])"/g, '$1\\\"') - // replace the first and the last quote + // Replace the first and the last quote .replace(/^'|'$/g, '"'); } }); diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index fde999be..29e63d53 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -48,7 +48,9 @@ module.exports = (function() { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true] }, + accepts: { + boolean: [true] + }, /** * Remove rulesets with no declarations. @@ -63,7 +65,8 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. - * This option is treated as `true` by default, but any trailing space would invalidate it. + * This option is treated as `true` by default, but any trailing space + * would invalidate it. * * @param {node} ast */ diff --git a/src/options/sort-order-fallback.js b/src/options/sort-order-fallback.js index 21d25b06..6a4189b0 100644 --- a/src/options/sort-order-fallback.js +++ b/src/options/sort-order-fallback.js @@ -3,7 +3,7 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { string: /^abc$/ }, + accepts: {string: /^abc$/}, process: function() {} }; diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 9ad90f0c..dbdb3f1d 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -14,18 +14,19 @@ module.exports = { * @returns {Array} */ setValue: function(value) { - if (!Array.isArray(value)) throw new Error('The option accepts only array of properties.'); + if (!Array.isArray(value)) + throw new Error('The option accepts only array of properties.'); var order = {}; if (typeof value[0] === 'string') { value.forEach(function(prop, propIndex) { - order[prop] = { group: 0, prop: propIndex }; + order[prop] = {group: 0, prop: propIndex}; }); } else { value.forEach(function(group, groupIndex) { group.forEach(function(prop, propIndex) { - order[prop] = { group: groupIndex, prop: propIndex }; + order[prop] = {group: groupIndex, prop: propIndex}; }); }); } @@ -41,8 +42,8 @@ module.exports = { process: function(node, syntax) { var _this = this; // Types of nodes that can be sorted: - var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', 'singlelineComment', - 'declaration', 'space', 'include']; + var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', + 'singlelineComment', 'declaration', 'space', 'include']; // Spaces and comments: var SC = ['multilineComment', 'singlelineComment', 'space']; @@ -51,7 +52,7 @@ module.exports = { var order = this.value; // List of declarations that should be sorted: var sorted = []; - // list of nodes that should be removed from parent node: + // List of nodes that should be removed from parent node: var deleted = []; // List of spaces and comments that go before declaration/@-rule: var sc0 = []; @@ -126,10 +127,12 @@ module.exports = { // Check every next node: for (; i < l; i++) { currentNode = node.get(i + 1); - // If there is no node, or it is nor spaces neither comment, stop: + // If there is no node, or it is nor spaces neither comment, + // stop: if (!currentNode || SC.indexOf(currentNode.type) === -1) break; - if (currentNode.is('multilineComment') || currentNode.is('singlelineComment')) { + if (currentNode.is('multilineComment') || + currentNode.is('singlelineComment')) { sc.push(currentNode); d.push(i + 1); continue; @@ -144,9 +147,10 @@ module.exports = { if (lbIndex > -1) { // TODO: Don't push an empty array var s = currentNode.content.substring(0, lbIndex); - var space = gonzales.createNode({ type: 's', content: s }); + var space = gonzales.createNode({type: 's', content: s}); sc.push(space); - currentNode.content = currentNode.content.substring(lbIndex); + currentNode.content = currentNode.content + .substring(lbIndex); break; } @@ -187,10 +191,12 @@ module.exports = { // group and property indices. Otherwise set them to 10000, so // declaration appears at the bottom of a sorted list: - extendedNode.groupIndex = orderProperty && orderProperty.group > -1 ? + let groupIndex = orderProperty && orderProperty.group > -1 ? orderProperty.group : lastGroupIndex; - extendedNode.propertyIndex = orderProperty && orderProperty.prop > -1 ? + let propertyIndex = orderProperty && orderProperty.prop > -1 ? orderProperty.prop : lastPropertyIndex; + extendedNode.groupIndex = groupIndex; + extendedNode.propertyIndex = propertyIndex; // Mark current node to remove it later from parent node: deleted.push(i); @@ -204,15 +210,16 @@ module.exports = { // If there is `;` right after the declaration, save it with the // declaration and mark it for removing from parent node: - if (currentNode && nextNode && nextNode.is('declarationDelimiter')) { + if (currentNode && nextNode && + nextNode.is('declarationDelimiter')) { extendedNode.delim.push(nextNode); deleted.push(i + 1); i++; if (syntax === 'sass') return extendedNode; - // Save spaces and comments which follow right after the declaration - // and mark them for removing from parent node: + // Save spaces and comments which follow right after + // the declaration and mark them for removing from parent node: extendedNode.sc2 = checkSC1(); } @@ -247,8 +254,9 @@ module.exports = { return a[2] < b[2] ? -1 : 1; } else { // If unprefixed parts are identical (i.e. `border` in - // `-moz-border` and `-o-border`), compare prefixes (they - // should go in the same order they are set in `prefixes` array): + // `-moz-border` and `-o-border`), compare prefixes. + // They should go in the same order they are set + // in `prefixes` array. return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; } }; @@ -294,7 +302,8 @@ module.exports = { '$variable' : currentNode.get(0).content; break; } else if (currentNode.is('atkeyword') && - currentNode.get(0).content === 'import') { // Look for imports + currentNode.get(0).content === 'import') { + // Look for imports propertyName = '$import'; break; } @@ -313,7 +322,8 @@ module.exports = { sorted.push(extendNode()); } - // Remove all nodes, that were moved to a `sorted` list, from parent node: + // Remove all nodes, that were moved to a `sorted` list, + // from parent node: for (i = deleted.length - 1; i > -1; i--) { node.content.splice(deleted[i], 1); } @@ -322,7 +332,8 @@ module.exports = { sorted.sort(function(a, b) { // If a's group index is higher than b's group index, in a sorted // list a appears after b: - if (a.groupIndex !== b.groupIndex) return a.groupIndex - b.groupIndex; + if (a.groupIndex !== b.groupIndex) + return a.groupIndex - b.groupIndex; // If a and b belong to leftovers and `sort-order-fallback` option // is set to `abc`, sort properties alphabetically: @@ -334,7 +345,8 @@ module.exports = { // If a and b have the same group index, and a's property index is // higher than b's property index, in a sorted list a appears after // b: - if (a.propertyIndex !== b.propertyIndex) return a.propertyIndex - b.propertyIndex; + if (a.propertyIndex !== b.propertyIndex) + return a.propertyIndex - b.propertyIndex; // If a and b have the same group index and the same property index, // in a sorted list they appear in the same order they were in @@ -371,7 +383,10 @@ module.exports = { } if (currentNode.delim.length > 0) { var delim = this.syntax === 'sass' ? '\n' : ';'; - var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: delim }); + var declDelim = gonzales.createNode({ + type: 'declarationDelimiter', + content: delim + }); node.content.unshift(declDelim); } for (j = 0, nl = sc1.length; j < nl; j++) { diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 48eed36e..3f643f9f 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -30,7 +30,10 @@ module.exports = { declaration.remove(i + 1); // If the value set in config is not empty, add spaces: if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); declaration.insert(i + 1, space); } diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index 88093296..98a7b919 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -27,7 +27,10 @@ module.exports = { if (simpleSelector.get(i + 1).is('space')) { simpleSelector.get(i + 1).content = value; } else { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); simpleSelector.insert(i + 1, space); } }); diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index d2367f56..5a3a44cf 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -28,7 +28,10 @@ module.exports = { node.first().is('space')) { node.first().content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); node.insert(0, space); } }); diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index ef3dbffa..39948d61 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -29,7 +29,10 @@ module.exports = { } else if (nextNode.first().is('space')) { nextNode.first().content = value; } else { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); nextNode.insert(0, space); } }); diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 78dd1d55..148a580a 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -37,11 +37,15 @@ module.exports = (function() { var whitespaceNode = getLastWhitespaceNode(node); // If it's spaces, modify this node - // If it's something different from spaces, add a space node to the end + // If it's something different from spaces, add a space node + // to the end if (whitespaceNode) { whitespaceNode.content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); node.content.push(space); } diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 119d83dc..2d97a384 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -32,7 +32,10 @@ module.exports = { // If the value set in config is not empty, add spaces: if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); declaration.insert(i, space); } }); diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 13236137..239a67ec 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -34,7 +34,10 @@ module.exports = { if (simpleSelector.get(i - 1).is('space')) { simpleSelector.get(i - 1).content = value; } else { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); simpleSelector.insert(i, space); } }); diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index 08b07b07..ea290500 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -50,7 +50,10 @@ module.exports = (function() { if (whitespaceNode) { whitespaceNode.content = value; } else if (value !== '') { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); if (previousNode && previousNode.is('atrulerq')) { previousNode.content.push(space); } else { diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 3cf7f6df..9e71a454 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -26,7 +26,10 @@ module.exports = { if (previousNode.last().is('space')) { previousNode.last().content = value; } else { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); previousNode.content.push(space); } }); diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 26bc784f..34da8c59 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -2,7 +2,7 @@ var gonzales = require('gonzales-pe'); module.exports = (function() { function getDeclarationEnd(node, i) { - for (;i < node.length; i++) { + for (; i < node.length; i++) { if (!node.get(i + 1) || typeof node.get(i + 1) === 'string') { return 0; } else if (node.get(i + 1).is('space')) { @@ -12,11 +12,13 @@ module.exports = (function() { } else { return 0; } - } else if (node.get(i + 2) && node.get(i + 2).is('multilineComment')) { + } else if (node.get(i + 2) && + node.get(i + 2).is('multilineComment')) { if (node.get(i + 3) && node.get(i + 3).is('declaration')) { return i + 2; } else if (node.get(i + 3) && node.get(i + 3).is('space')) { - if (node.get(i + 4) && node.get(i + 4).is('declaration')) { + if (node.get(i + 4) && + node.get(i + 4).is('declaration')) { return i + 2; } else { return 0; @@ -24,7 +26,8 @@ module.exports = (function() { } else { return 0; } - } else if (node.get(i + 2) && node.get(i + 2).is('declaration')) { + } else if (node.get(i + 2) && + node.get(i + 2).is('declaration')) { return i; } } else if (node.get(i + 1).is('declaration')) { @@ -65,7 +68,8 @@ module.exports = (function() { process: function(ast) { let value = this.value; - ast.traverse('declarationDelimiter', function(delimiter, i, parent) { + ast.traverse('declarationDelimiter', + function(delimiter, i, parent) { // Grom user's point of view "declaration" includes semicolons // and comments placed on the same line. // So group those things together: @@ -80,7 +84,10 @@ module.exports = (function() { if (nextNode.is('space')) { nextNode.content = value; } else { - var space = gonzales.createNode({ type: 'space', content: value }); + var space = gonzales.createNode({ + type: 'space', + content: value + }); parent.insert(i + 1, space); } }); diff --git a/src/options/strip-spaces.js b/src/options/strip-spaces.js index 9722e03b..b210dc36 100644 --- a/src/options/strip-spaces.js +++ b/src/options/strip-spaces.js @@ -14,7 +14,9 @@ module.exports = (function() { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true] }, + accepts: { + boolean: [true] + }, /** * Processes tree node. @@ -37,7 +39,8 @@ module.exports = (function() { /** * Detects the value of an option at the tree node. - * This option is treated as `true` by default, but any trailing space would invalidate it. + * This option is treated as `true` by default, but any trailing + * space would invalidate it. * * @param {node} ast */ diff --git a/src/options/tab-size.js b/src/options/tab-size.js index 711fbe09..6b19b29a 100644 --- a/src/options/tab-size.js +++ b/src/options/tab-size.js @@ -5,7 +5,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { number: true }, + accepts: { + number: true + }, /** * Processes tree node. diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index 7e8bad6c..323584bb 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -3,7 +3,9 @@ module.exports = { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true] }, + accepts: { + boolean: [true] + }, /** * Processes tree node. @@ -45,8 +47,10 @@ module.exports = { let detected = []; ast.traverse(function(node, i, parent) { - // If we see a zero with unit and it is not degree, then we don’t have an option - if (node.is('percentage') && node.first('number').content[1] === '0') { + // If we see a zero with unit and it is not degree, + // then we don’t have an option + if (node.is('percentage') && + node.first('number').content[1] === '0') { detected.push(false); return; } @@ -58,7 +62,8 @@ module.exports = { return; } - // If we see a zero and previous node is not percentage or dimension, then we have an option + // If we see a zero and previous node is not percentage + // or dimension, then we have an option if (node.is('number') && node.content[0] === '0' && !parent.is('percentage') && diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index f58a4d33..3c39c6f1 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -24,7 +24,8 @@ module.exports = (function() { } /** - * Creates object which contains info about vendor prefix used in propertyName. + * Creates object which contains info about vendor prefix used + * in propertyName. * * @param {String} propertyName property name * @param {String} [namespace=''] namespace name @@ -93,9 +94,13 @@ module.exports = (function() { } if (node.is('multilineComment')) { if (crPos === -1) { - result += node.content.length + 4 /* comment symbols length */ ; + // Comment symbols length + let offset = 4; + result += node.content.length + offset; } else { - result += node.content.length - crPos + 1 /* only last comment symbols length - 1(not count \n)*/; + // Only last comment symbols length - 1 (not count \n) + let offset = crPos - 1; + result += node.content.length - offset; break; } } @@ -147,7 +152,8 @@ module.exports = (function() { } /** - * Walks across nodes, and call payload for every node that pass selector check. + * Walks across nodes, and call payload for every node that pass + * selector check. * * @param {Object} args arguments in form of: * { @@ -161,7 +167,8 @@ module.exports = (function() { function walk(args) { args.node.forEach(function(item, i) { var name = args.selector(item); - var namespace = args.namespaceSelector && makeNamespace(args.namespaceSelector(item)); + var namespace = args.namespaceSelector && + makeNamespace(args.namespaceSelector(item)); var extraSymbols = args.getExtraSymbols(args.node, i); var info = name && getPrefixInfo(name, namespace, extraSymbols); @@ -213,14 +220,18 @@ module.exports = (function() { function updateDict(info, dict) { if (info.prefixLength === 0 && info.extra === 0) return; - var indent = dict[info.id] || { prefixLength: 0, extra: 0 }; + var indent = dict[info.id] || {prefixLength: 0, extra: 0}; - dict[info.id] = indent.prefixLength + indent.extra > info.prefixLength + info.extra ? - indent : - { + let indentLength = indent.prefixLength + indent.extra; + let infoLength = info.prefixLength + info.extra; + if (indentLength > infoLength) { + dict[info.id] = indent; + } else { + dict[info.id] = { prefixLength: info.prefixLength, - extra: info.extra, + extra: info.extra }; + } } /** @@ -240,7 +251,7 @@ module.exports = (function() { var tabPos = whitespaceNode.lastIndexOf('\t'); if (tabPos > crPos) crPos = tabPos; - var firstPart = whitespaceNode.substr(0, crPos + 1 ); + var firstPart = whitespaceNode.substr(0, crPos + 1); var extraIndent = new Array( (item.prefixLength - info.prefixLength) + (item.extra - info.extra) + @@ -255,7 +266,9 @@ module.exports = (function() { syntax: ['css', 'less', 'sass', 'scss'], - accepts: { boolean: [true] }, + accepts: { + boolean: [true] + }, /** * Processes tree node. @@ -302,13 +315,19 @@ module.exports = (function() { if (node.get(i).get(x).is('value')) break; } - if (!node.get(i).get(x - 1).is('space')) { - var space = gonzales.createNode({ type: 'space', content: '' }); + let prevNode = node.get(i).get(x - 1); + if (!prevNode.is('space')) { + var space = gonzales.createNode({ + type: 'space', + content: '' + }); node.get(i).insert(x, space); ++x; } - node.get(i).get(x - 1).content = updateIndent(info, dict, node.get(i).get(x - 1).content); + let content = node.get(i).get(x - 1).content; + let updatedIndent = updateIndent(info, dict, content); + node.get(i).get(x - 1).content = updatedIndent; } }); @@ -324,10 +343,15 @@ module.exports = (function() { if (!whitespaceNode) return; // If it's a comment, insert an empty space node: if (!whitespaceNode.is('space')) { - whitespaceNode = gonzales.createNode({ type: 'space', content: '' }); + whitespaceNode = gonzales.createNode({ + type: 'space', + content: '' + }); node.insert(i - 1, whitespaceNode); } - whitespaceNode.content = updateIndent(info, dict, whitespaceNode.content); + let content = whitespaceNode.content; + let updatedContent = updateIndent(info, dict, content); + whitespaceNode.content = updatedContent; } }); }); @@ -337,7 +361,6 @@ module.exports = (function() { * Detects the value of an option at the tree node. * * @param {node} ast - * @param {String} syntax */ detect: function(ast) { let detected = []; @@ -358,7 +381,8 @@ module.exports = (function() { let {node, sum, info, i} = options; var prop = info.baseName; - // If this is the last item in a row and we have a result, then catch it + // If this is the last item in a row and we have a result, + // then catch it if (prop !== prevProp && partialResult !== null) { if (partialResult) { result.true++; @@ -368,15 +392,17 @@ module.exports = (function() { partialResult = null; } - if (prop === prevProp && info.prefixLength !== prevPrefixLength) { + if (prop === prevProp && + info.prefixLength !== prevPrefixLength) { maybePrefix = true; } else { maybePrefix = false; } if (maybePrefix && partialResult !== false) { - // If there is prefixed prop, check if the prefixes are aligned, - // but only if we hadn't already catched that it is false + // If there is prefixed prop, check if the prefixes are + // aligned, but only if we hadn't already catched + // that it is false if (sum === prevSum) { partialResult = true; } else { @@ -385,7 +411,8 @@ module.exports = (function() { } if (node.length === i + 3 && partialResult !== null) { - // If we're at the last property and have a result, catch it + // If we're at the last property and have a result, + // catch it if (partialResult) { result.true++; } else { @@ -405,8 +432,9 @@ module.exports = (function() { getExtraSymbols: extraIndentProperty, payload: function(info, i) { if (node.get(i - 1) && node.get(i - 1).content) { - var sum = node.get(i - 1).content. - replace(/^[ \t]*\n+/, '').length + info.prefixLength; + let nodeLength = node.get(i - 1).content. + replace(/^[ \t]*\n+/, '').length; + var sum = nodeLength + info.prefixLength; getResult({node: node, sum: sum, info: info, i: i}); } } @@ -422,8 +450,9 @@ module.exports = (function() { } if (node.get(i).get(x - 1)) { - var sum = node.get(i).get(x - 1).content - .replace(/^[ \t]*\n+/, '').length + info.prefixLength; + let nodeLength = node.get(i).get(x - 1).content + .replace(/^[ \t]*\n+/, '').length; + var sum = nodeLength + info.prefixLength; getResult({node: node, sum: sum, info: info, i: i}); } } From 35bf71ad461ac22909166a7a1a4c354cd106c561 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 22:01:06 +0200 Subject: [PATCH 079/184] [tools] Remove Gulp in favour of bash script --- gulpfile.js | 8 -------- package.json | 4 ++-- scripts/build.sh | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 gulpfile.js create mode 100755 scripts/build.sh diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 66da6517..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -var gulp = require("gulp"); -var babel = require("gulp-babel"); - -gulp.task("default", function () { - return gulp.src("src/**/*.js") - .pipe(babel()) - .pipe(gulp.dest("lib")); -}); diff --git a/package.json b/package.json index ef6c1e0b..7c09b13d 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,7 @@ "vow": "0.4.4" }, "devDependencies": { - "babel-core": "^5.4.7", - "gulp-babel": "^5.1.0", + "babel": "^5.5.3", "jscs": "1.13.1", "jshint": "2.8.0", "jshint-groups": "0.5.3", @@ -62,6 +61,7 @@ "csscomb": "./bin/csscomb" }, "scripts": { + "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", "test": "./scripts/test.sh" } diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..ec78ca4e --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +printf "\n\ +-----------------------\n\ + Building source files\n\ +-----------------------\n\n" +./node_modules/.bin/babel --loose all src --out-dir lib From 57f199d642f0414abf7f287a9485b635cb9099e9 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 5 Jun 2015 23:53:44 +0200 Subject: [PATCH 080/184] [tools] Add watch script --- package.json | 3 ++- scripts/watch.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 scripts/watch.sh diff --git a/package.json b/package.json index 7c09b13d..f199b625 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", - "test": "./scripts/test.sh" + "test": "./scripts/test.sh", + "watch": "./scripts/watch.sh" } } diff --git a/scripts/watch.sh b/scripts/watch.sh new file mode 100755 index 00000000..2a237f9e --- /dev/null +++ b/scripts/watch.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +printf "\n\ +-----------------------\n\ + Watching source files\n\ +-----------------------\n\n" + +./node_modules/.bin/babel --loose all --watch src --out-dir lib From fbc138807e68ac6444b59c6e1c4d1e392cb1bb24 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 00:07:09 +0200 Subject: [PATCH 081/184] [tools] Build files before running tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f199b625..be57858c 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", - "test": "./scripts/test.sh", + "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } } From a041da5d5ade42a5cd26f146d60f58797c56928a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 02:06:39 +0200 Subject: [PATCH 082/184] [tools] Update dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be57858c..9d6f50e4 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "minimist": "1.1.x", - "csscomb-core": "3.0.0-4", - "gonzales-pe": "3.0.0-29", + "csscomb-core": "3.0.0-6", + "gonzales-pe": "3.0.0-30", "vow": "0.4.4" }, "devDependencies": { From c7100b6548a3d961155b12cc9102930c04a18b5c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 02:10:22 +0200 Subject: [PATCH 083/184] [gpe] Handle separation of `include` and `extend` nodes --- src/options/always-semicolon.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index e932ed03..815484ee 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -26,7 +26,8 @@ module.exports = { // Add semicolon only after declarations and includes. // If current node is include, insert semicolon right into it. // If it's declaration, look for value node: - if (currentNode.is('include')) { + if (currentNode.is('include') || + currentNode.is('extend')) { nodeWithoutSemicolon = currentNode; } else if (currentNode.is('declaration')) { nodeWithoutSemicolon = currentNode.last('value'); @@ -64,7 +65,8 @@ module.exports = { // Add semicolon only after declarations and includes. // If current node is include, insert semicolon right into it. // If it's declaration, look for value node: - if (currentNode.is('include')) { + if (currentNode.is('include') || + currentNode.is('extend')) { nodeWithoutSemicolon = currentNode; } else if (currentNode.is('declaration')) { nodeWithoutSemicolon = currentNode.last('value'); From a63815cdbe973c3fecad5f90d224e9d0b40adfa2 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 11:39:56 +0200 Subject: [PATCH 084/184] [cli] Fix module path --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 2d4b07d9..6212414b 100644 --- a/src/cli.js +++ b/src/cli.js @@ -4,7 +4,7 @@ * Usage example: * ./node_modules/.bin/csscomb [options] [file1 [dir1 [fileN [dirN]]]] */ -var format = require('format'); +var format = require('./format'); var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); From c67c0eb7a6018aa2f1ac9426955efcd49e63764c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 11:40:12 +0200 Subject: [PATCH 085/184] [cli] Add initial value to reduce --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 6212414b..263763d7 100644 --- a/src/cli.js +++ b/src/cli.js @@ -46,7 +46,7 @@ function processFiles(files, config) { var tbchanged = c.reduce(function(a, b) { return a + b; - }); + }, 0); var changed = config.lint ? 0 : tbchanged; From d767e388df4a622335d8490d89b1df804479f709 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 6 Jun 2015 11:40:51 +0200 Subject: [PATCH 086/184] [tools] Update core version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d6f50e4..5ac56e00 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "dependencies": { "minimist": "1.1.x", - "csscomb-core": "3.0.0-6", + "csscomb-core": "3.0.0-7", "gonzales-pe": "3.0.0-30", "vow": "0.4.4" }, From 15f22ab8bf11f6762f20daed202a619160b19c95 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 20 Jun 2015 00:43:05 +0300 Subject: [PATCH 087/184] [gpe] Use new GPE api --- src/options/always-semicolon.js | 6 +++--- src/options/color-case.js | 4 ++-- src/options/color-shorthand.js | 4 ++-- src/options/leading-zero.js | 4 ++-- src/options/quotes.js | 4 ++-- src/options/space-after-colon.js | 4 ++-- src/options/space-after-combinator.js | 4 ++-- src/options/space-after-selector-delimiter.js | 4 ++-- src/options/space-before-closing-brace.js | 4 +--- src/options/space-before-colon.js | 4 ++-- src/options/space-before-combinator.js | 4 ++-- src/options/space-before-opening-brace.js | 13 +++++-------- src/options/space-before-selector-delimiter.js | 4 ++-- src/options/space-between-declarations.js | 2 +- src/options/strip-spaces.js | 4 ++-- src/options/tab-size.js | 2 +- src/options/unitless-zero.js | 4 +--- src/options/vendor-prefix-align.js | 4 ++-- 18 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index 815484ee..327d4bf6 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -17,7 +17,7 @@ module.exports = { lint: function(ast) { var errors = []; - ast.traverse('block', function(block) { + ast.traverseByType('block', function(block) { block.eachFor(function(currentNode) { var nodeWithoutSemicolon; // Skip nodes that already have `;` at the end: @@ -57,7 +57,7 @@ module.exports = { process: function(ast) { var nodeWithoutSemicolon; - ast.traverse('block', function(block) { + ast.traverseByType('block', function(block) { block.eachFor(function(currentNode) { // Skip nodes that already have `;` at the end: if (currentNode.is('declarationDelimiter')) return null; @@ -109,7 +109,7 @@ module.exports = { detect: function(ast) { var detected = []; - ast.traverse('block', function(block) { + ast.traverseByType('block', function(block) { block.eachFor(function(node) { if (node.is('declarationDelimiter')) { detected.push(true); diff --git a/src/options/color-case.js b/src/options/color-case.js index c778ad71..27fb1a15 100644 --- a/src/options/color-case.js +++ b/src/options/color-case.js @@ -14,7 +14,7 @@ module.exports = { process: function(ast) { var value = this.value; - ast.traverse('color', function(color) { + ast.traverseByType('color', function(color) { color.content = value === 'lower' ? color.content.toLowerCase() : color.content.toUpperCase(); @@ -29,7 +29,7 @@ module.exports = { detect: function(ast) { var detected = []; - ast.traverse('color', function(color) { + ast.traverseByType('color', function(color) { if (color.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { detected.push('lower'); } else if (color.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { diff --git a/src/options/color-shorthand.js b/src/options/color-shorthand.js index f3ddc4f3..96433d38 100644 --- a/src/options/color-shorthand.js +++ b/src/options/color-shorthand.js @@ -14,7 +14,7 @@ module.exports = { process: function(ast) { var value = this.value; - ast.traverse('color', function(color) { + ast.traverseByType('color', function(color) { color.content = value ? color.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : color.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); @@ -29,7 +29,7 @@ module.exports = { detect: function(ast) { var detected = []; - ast.traverse('color', function(color) { + ast.traverseByType('color', function(color) { if (color.content.match(/^\w{3}$/)) { detected.push(true); } else if (color.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { diff --git a/src/options/leading-zero.js b/src/options/leading-zero.js index 709b9243..5fb198a5 100644 --- a/src/options/leading-zero.js +++ b/src/options/leading-zero.js @@ -14,7 +14,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('number', function(number) { + ast.traverseByType('number', function(number) { if (!value) { number.content = number.content.replace(/^0+(?=\.)/, ''); } else if (number.content[0] === '.') { @@ -31,7 +31,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('number', function(number) { + ast.traverseByType('number', function(number) { if (number.content.match(/^\.[0-9]+/)) { detected.push(false); } else if (number.content.match(/^0\.[0-9]+/)) { diff --git a/src/options/quotes.js b/src/options/quotes.js index b1e09fb3..153454ed 100644 --- a/src/options/quotes.js +++ b/src/options/quotes.js @@ -14,7 +14,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('string', function(string) { + ast.traverseByType('string', function(string) { if (string.content[0] === '"' && value === 'single') { string.content = string.content // Unescape all escaped double quotes @@ -43,7 +43,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('string', function(string) { + ast.traverseByType('string', function(string) { if (string.content[0] === '"') { detected.push('double'); } else if (string.content[0] === '\'') { diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 3f643f9f..eea371d5 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -21,7 +21,7 @@ module.exports = { process: function(ast, syntax) { let value = this.value; - ast.traverse('declaration', function(declaration) { + ast.traverseByType('declaration', function(declaration) { declaration.eachFor('propertyDelimiter', function(delimiter, i) { if (syntax === 'sass' && !declaration.get(i - 1)) return null; @@ -50,7 +50,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('declaration', function(declaration) { + ast.traverseByType('declaration', function(declaration) { declaration.eachFor('propertyDelimiter', function(delimiter, i) { if (declaration.get(i + 1).is('space')) { detected.push(declaration.get(i + 1).content); diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index 98a7b919..a487cc6e 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -21,7 +21,7 @@ module.exports = { let value = this.value; // TODO(tonyganch): Can this be replaced with one `traverse`? - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('simpleSelector', function(simpleSelector) { simpleSelector.forEach('combinator', function(combinator, i) { if (simpleSelector.get(i + 1).is('space')) { @@ -46,7 +46,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('simpleSelector', function(simpleSelector) { simpleSelector.forEach('combinator', function(combinator, i) { if (simpleSelector.get(i + 1).is('space')) { diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index 39948d61..25cc0c4d 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -20,7 +20,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('delimiter', function(delimiter, i) { var nextNode = selector.get(i + 1); @@ -47,7 +47,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('delimiter', function(delimiter, i) { var nextNode = selector.get(i + 1); diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 148a580a..87bccc6d 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -87,9 +87,7 @@ module.exports = (function() { detect: function(ast) { let detected = []; - ast.traverse(function(node) { - if (!node.is('block') && !node.is('atrulers')) return; - + ast.traverseByTypes(['block', 'atrulers'], function(node) { // For the block node, find its last (the deepest) child var whitespaceNode = getLastWhitespaceNode(node); if (whitespaceNode) { diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 2d97a384..3305a96f 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -21,7 +21,7 @@ module.exports = { process: function(ast, syntax) { let value = this.value; - ast.traverse('declaration', function(declaration) { + ast.traverseByType('declaration', function(declaration) { declaration.forEach('propertyDelimiter', function(delimiter, i) { if (syntax === 'sass' && !declaration.get(i - 1)) return; @@ -50,7 +50,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('declaration', function(declaration) { + ast.traverseByType('declaration', function(declaration) { declaration.forEach('propertyDelimiter', function(delimiter, i) { if (declaration.get(i - 1).is('space')) { detected.push(declaration.get(i - 1).content); diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 239a67ec..2797288f 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -20,7 +20,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach(function(simpleSelector) { var notFirst = false; @@ -53,7 +53,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach(function(simpleSelector) { simpleSelector.forEach('combinator', function(combinator, i) { if (simpleSelector.get(i - 1).is('space')) { diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index ea290500..c9ac31dd 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -35,10 +35,9 @@ module.exports = (function() { process: function(ast) { let value = this.value; - ast.traverse(function(block, i, parent) { - // If found block node stop at the next one for space check: - if (!block.is('block') && !block.is('atrulers')) return; - + // If found block node stop at the next one for space check. + ast.traverseByTypes(['block', 'atrulers'], + function(block, i, parent) { // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) var previousNode = parent.get(i - 1); @@ -71,10 +70,8 @@ module.exports = (function() { detect: function(ast) { var detected = []; - ast.traverse(function(block, i, parent) { - // If found block node stop at the next one for space check: - if (!block.is('block') && !block.is('atrulers')) return; - + ast.traverseByTypes(['block', 'atrulers'], + function(block, i, parent) { // For the pre-block node, find its last (the deepest) child: // TODO: Exclude nodes with braces (for example, arguments) var previousNode = parent.get(i - 1); diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 9e71a454..cd36136d 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -20,7 +20,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('delimiter', function(delim, i) { var previousNode = selector.get(i - 1); if (previousNode.last().is('space')) { @@ -44,7 +44,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse('selector', function(selector) { + ast.traverseByType('selector', function(selector) { selector.forEach('delimiter', function(delim, i) { var previousNode = selector.get(i - 1); if (previousNode.last().is('space')) { diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 34da8c59..14879726 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -68,7 +68,7 @@ module.exports = (function() { process: function(ast) { let value = this.value; - ast.traverse('declarationDelimiter', + ast.traverseByType('declarationDelimiter', function(delimiter, i, parent) { // Grom user's point of view "declaration" includes semicolons // and comments placed on the same line. diff --git a/src/options/strip-spaces.js b/src/options/strip-spaces.js index b210dc36..b6d0bdcc 100644 --- a/src/options/strip-spaces.js +++ b/src/options/strip-spaces.js @@ -30,7 +30,7 @@ module.exports = (function() { .replace(/[\n]+/g, '\n'); } - ast.traverse('space', function(space) { + ast.traverseByType('space', function(space) { space.content = trim(space.content); }); }, @@ -54,7 +54,7 @@ module.exports = (function() { detected.push(false); } - ast.traverse('space', function(space) { + ast.traverseByType('space', function(space) { if (space.content.match(/[ \t]\n/)) detected.push(false); }); diff --git a/src/options/tab-size.js b/src/options/tab-size.js index 6b19b29a..ce2dbfcc 100644 --- a/src/options/tab-size.js +++ b/src/options/tab-size.js @@ -17,7 +17,7 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverse('space', function(space) { + ast.traverseByType('space', function(space) { space.content = space.content.replace(/\t/, value); }); } diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index 323584bb..45b08698 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -15,9 +15,7 @@ module.exports = { process: function(ast) { var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - ast.traverse(function(node) { - if (!node.is('value') && !node.is('parentheses')) return; - + ast.traverseByTypes(['value', 'parentheses'], function(node) { node.forEach(function(value) { if (typeof value === 'string') return; diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index 3c39c6f1..cf6146c6 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -277,7 +277,7 @@ module.exports = (function() { * @param {String} syntax */ process: function(ast, syntax) { - ast.traverse('block', function(node) { + ast.traverseByType('block', function(node) { oneline = true; var dict = {}; @@ -365,7 +365,7 @@ module.exports = (function() { detect: function(ast) { let detected = []; - ast.traverse('block', function(node) { + ast.traverseByType('block', function(node) { var result = { true: 0, false: 0 From 93aae9500d3ad0c7ac26d6e752704f551f802c14 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 20 Jun 2015 01:35:21 +0300 Subject: [PATCH 088/184] [gpe] Fix `sort-order` after GPE update --- src/options/sort-order.js | 265 ++++++++++++----------- test/options/integral/test.js | 2 +- test/options/sort-order-fallback/test.js | 2 +- test/options/sort-order-less/test.js | 2 +- test/options/sort-order-sass/test.js | 2 +- test/options/sort-order-scss/test.js | 2 +- test/options/sort-order/test.js | 2 +- 7 files changed, 145 insertions(+), 132 deletions(-) diff --git a/src/options/sort-order.js b/src/options/sort-order.js index dbdb3f1d..d9a44d35 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -36,17 +36,18 @@ module.exports = { /** * Processes tree node. - * @param {node} node - * @param {String} syntax + * @param {node} ast + * @param {string} syntax + * @param {object} config */ - process: function(node, syntax) { - var _this = this; + process: function(ast, syntax, config) { // Types of nodes that can be sorted: var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', - 'singlelineComment', 'declaration', 'space', 'include']; + 'singlelineComment', 'declaration', 'space', 'include', 'extend']; // Spaces and comments: var SC = ['multilineComment', 'singlelineComment', 'space']; + var node; var currentNode; // Sort order of properties: var order = this.value; @@ -263,141 +264,153 @@ module.exports = { // TODO: Think it through! // Sort properties only inside blocks: - if (!node.is('block')) return; - - // Check every child node. - // If it is declaration (property-value pair, e.g. `color: tomato`), - // or @-rule (e.g. `@include nani`), - // combine it with spaces, semicolon and comments and move them from - // current node to a separate list for further sorting: - for (i = 0, l = node.length; i < l; i++) { - if (NODES.indexOf(node.get(i).type) === -1) continue; - - // Save preceding spaces and comments, if there are any, and mark - // them for removing from parent node: - sc0 = checkSC0(); - if (!sc0) continue; - - // If spaces/comments are the last nodes, stop and go to sorting: - if (!node.get(i)) { - deleted.splice(deleted.length - sc0.length, deleted.length + 1); - break; - } + ast.traverseByType('block', function(block) { + node = block; + sorted = []; + deleted = []; + sc0 = []; + + // Check every child node. + // If it is declaration (property-value pair, e.g. `color: tomato`), + // or @-rule (e.g. `@include nani`), + // combine it with spaces, semicolon and comments and move them from + // current node to a separate list for further sorting: + for (i = 0, l = node.length; i < l; i++) { + if (NODES.indexOf(node.get(i).type) === -1) continue; + + // Save preceding spaces and comments, if there are any, + // and mark them for removing from parent node: + sc0 = checkSC0(); + if (!sc0) continue; + + // If spaces/comments are the last nodes, stop and go to + // sorting: + if (!node.get(i)) { + deleted.splice(deleted.length - sc0.length, + deleted.length + 1); + break; + } - // Check if the node needs to be sorted: - // it should be a special @-rule (e.g. `@include`) or a declaration - // with a valid property (e.g. `color` or `$width`). - // If not, proceed with the next node: - propertyName = null; - // Look for includes: - if (node.get(i).is('include')) { - propertyName = '$include'; - } else { - for (j = 0, nl = node.get(i).length; j < nl; j++) { - currentNode = node.get(i).get(j); - if (!currentNode) continue; - - if (currentNode.is('property')) { - propertyName = currentNode.get(0).is('variable') ? - '$variable' : currentNode.get(0).content; - break; - } else if (currentNode.is('atkeyword') && - currentNode.get(0).content === 'import') { - // Look for imports - propertyName = '$import'; - break; + // Check if the node needs to be sorted: + // it should be a special @-rule (e.g. `@include`) or + // a declaration + // with a valid property (e.g. `color` or `$width`). + // If not, proceed with the next node: + propertyName = null; + // Look for includes: + if (node.get(i).is('include') || + node.get(i).is('extend')) { + propertyName = '$include'; + } else { + for (j = 0, nl = node.get(i).length; j < nl; j++) { + currentNode = node.get(i).get(j); + if (!currentNode) continue; + + if (currentNode.is('property')) { + propertyName = currentNode.get(0).is('variable') ? + '$variable' : currentNode.get(0).content; + break; + } else if (currentNode.is('atkeyword') && + currentNode.get(0).content === 'import') { + // Look for imports + propertyName = '$import'; + break; + } } } - } - - // If current node is not property-value pair or import or include, - // skip it and continue with the next node: - if (!propertyName) { - deleted.splice(deleted.length - sc0.length, deleted.length + 1); - continue; - } - // Make an extended node and move it to a separate list for further - // sorting: - sorted.push(extendNode()); - } + // If current node is not property-value pair or import or + // include, skip it and continue with the next node: + if (!propertyName) { + deleted.splice(deleted.length - sc0.length, + deleted.length + 1); + continue; + } - // Remove all nodes, that were moved to a `sorted` list, - // from parent node: - for (i = deleted.length - 1; i > -1; i--) { - node.content.splice(deleted[i], 1); - } + // Make an extended node and move it to a separate list for + // further sorting: + sorted.push(extendNode()); + } - // Sort declarations saved for sorting: - sorted.sort(function(a, b) { - // If a's group index is higher than b's group index, in a sorted - // list a appears after b: - if (a.groupIndex !== b.groupIndex) - return a.groupIndex - b.groupIndex; - - // If a and b belong to leftovers and `sort-order-fallback` option - // is set to `abc`, sort properties alphabetically: - if (a.groupIndex === lastGroupIndex && - _this.getValue('sort-order-fallback')) { - return sortLeftovers(a, b); + // Remove all nodes, that were moved to a `sorted` list, + // from parent node: + for (i = deleted.length - 1; i > -1; i--) { + node.content.splice(deleted[i], 1); } - // If a and b have the same group index, and a's property index is - // higher than b's property index, in a sorted list a appears after - // b: - if (a.propertyIndex !== b.propertyIndex) - return a.propertyIndex - b.propertyIndex; + // Sort declarations saved for sorting: + sorted.sort(function(a, b) { + // If a's group index is higher than b's group index, in + // a sorted list a appears after b: + if (a.groupIndex !== b.groupIndex) + return a.groupIndex - b.groupIndex; + + // If a and b belong to leftovers and `sort-order-fallback` + // option is set to `abc`, sort properties alphabetically: + if (a.groupIndex === lastGroupIndex && + config['sort-order-fallback']) { + return sortLeftovers(a, b); + } + + // If a and b have the same group index, and a's property index + // is higher than b's property index, in a sorted list + // a appears after b: + if (a.propertyIndex !== b.propertyIndex) + return a.propertyIndex - b.propertyIndex; - // If a and b have the same group index and the same property index, - // in a sorted list they appear in the same order they were in - // original array: - return a.i - b.i; - }); + // If a and b have the same group index and the same property + // index, in a sorted list they appear in the same order + // they were in original array: + return a.i - b.i; + }); - // Build all nodes back together. First go sorted declarations, then - // everything else: - if (sorted.length > 0) { - for (i = sorted.length - 1, l = -1; i > l; i--) { - currentNode = sorted[i]; - var prevNode = sorted[i - 1]; - sc0 = currentNode.sc0; - var sc1 = currentNode.sc1; - var sc2 = currentNode.sc2; - - sc0.reverse().map(removeEmptyLines); - sc1.reverse().map(removeEmptyLines); - sc2.reverse().map(removeEmptyLines); - - // Divide declarations from different groups with an empty line: - if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { - if (sc0[0] && sc0[0].is('space') && - (this.syntax === 'sass' || - sc0[0].content.match(/\n/g) && - sc0[0].content.match(/\n/g).length < 2)) { - sc0[0].content = '\n' + sc0[0].content; + // Build all nodes back together. First go sorted declarations, then + // everything else: + if (sorted.length > 0) { + for (i = sorted.length - 1, l = -1; i > l; i--) { + currentNode = sorted[i]; + var prevNode = sorted[i - 1]; + sc0 = currentNode.sc0; + var sc1 = currentNode.sc1; + var sc2 = currentNode.sc2; + + sc0.reverse().map(removeEmptyLines); + sc1.reverse().map(removeEmptyLines); + sc2.reverse().map(removeEmptyLines); + + // Divide declarations from different groups with + // an empty line: + if (prevNode && + currentNode.groupIndex > prevNode.groupIndex) { + if (sc0[0] && sc0[0].is('space') && + (syntax === 'sass' || + sc0[0].content.match(/\n/g) && + sc0[0].content.match(/\n/g).length < 2)) { + sc0[0].content = '\n' + sc0[0].content; + } } - } - for (j = 0, nl = sc2.length; j < nl; j++) { - node.content.unshift(sc2[j]); - } - if (currentNode.delim.length > 0) { - var delim = this.syntax === 'sass' ? '\n' : ';'; - var declDelim = gonzales.createNode({ - type: 'declarationDelimiter', - content: delim - }); - node.content.unshift(declDelim); - } - for (j = 0, nl = sc1.length; j < nl; j++) { - node.content.unshift(sc1[j]); - } - node.content.unshift(currentNode.node); + for (j = 0, nl = sc2.length; j < nl; j++) { + node.content.unshift(sc2[j]); + } + if (currentNode.delim.length > 0) { + var delim = syntax === 'sass' ? '\n' : ';'; + var declDelim = gonzales.createNode({ + type: 'declarationDelimiter', + content: delim + }); + node.content.unshift(declDelim); + } + for (j = 0, nl = sc1.length; j < nl; j++) { + node.content.unshift(sc1[j]); + } + node.content.unshift(currentNode.node); - for (j = 0, nl = sc0.length; j < nl; j++) { - node.content.unshift(sc0[j]); + for (j = 0, nl = sc0.length; j < nl; j++) { + node.content.unshift(sc0[j]); + } } } - } + }); } }; diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 2fe18ff7..8e48b7ea 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -1,4 +1,4 @@ -describe.skip('integral test', function() { +describe('integral test', function() { describe('process', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index 6295ca61..d4efede9 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order-fallback', function() { +describe('options/sort-order-fallback', function() { describe('process', function() { it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index 9f02cdc2..c00dfbc7 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (less)', function() { +describe('options/sort-order (less)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index a57434b9..bb914968 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (sass)', function() { +describe('options/sort-order (sass)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 9f8d55fb..8b71de48 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -1,4 +1,4 @@ -describe.skip('options/sort-order (scss)', function() { +describe('options/sort-order (scss)', function() { describe('process', function() { it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index 452052f5..a0719ee3 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe.skip('options/sort-order', function() { +describe('options/sort-order', function() { describe('process', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); From 90073da5a70612b085accad045d7c34a894dd95b Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 20 Jun 2015 01:51:44 +0300 Subject: [PATCH 089/184] [tools] Update dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5ac56e00..124c5b50 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "minimist": "1.1.x", - "csscomb-core": "3.0.0-7", - "gonzales-pe": "3.0.0-30", + "csscomb-core": "3.0.0-8", + "gonzales-pe": "3.0.0-31", "vow": "0.4.4" }, "devDependencies": { From 3a31bc9038f10583ff2614c5408e02208ef29536 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 21 Jun 2015 00:34:16 +0300 Subject: [PATCH 090/184] [tests] Return promises --- test/core/configure/test.js | 15 ++-- test/mocha.js | 5 +- test/options/always-semicolon-less/test.js | 24 +++--- test/options/always-semicolon-sass/test.js | 2 +- test/options/always-semicolon-scss/test.js | 28 +++---- test/options/always-semicolon/test.js | 55 +++++++------- test/options/block-indent-sass/test.js | 6 +- test/options/block-indent-scss/test.js | 2 +- test/options/block-indent/test.js | 14 ++-- test/options/color-case/test.js | 47 ++++++------ test/options/color-shorthand/test.js | 33 ++++----- test/options/element-case-scss/test.js | 2 +- test/options/element-case/test.js | 42 +++++------ test/options/eof-newline/test.js | 29 ++++---- test/options/integral/test.js | 6 +- test/options/leading-zero/test.js | 22 +++--- test/options/quotes/test.js | 74 ++++++++----------- .../remove-empty-rulesets-less/test.js | 12 ++- .../remove-empty-rulesets-scss/test.js | 8 +- test/options/remove-empty-rulesets/test.js | 25 +++++-- test/options/sass/test.js | 50 ++++++------- test/options/sort-order-fallback/test.js | 6 +- test/options/sort-order-less/test.js | 26 +++---- test/options/sort-order-sass/test.js | 24 +++--- test/options/sort-order-scss/test.js | 34 ++++----- test/options/sort-order/test.js | 51 ++++++++----- test/options/space-after-colon-sass/test.js | 4 +- test/options/space-after-colon-scss/test.js | 2 +- test/options/space-after-colon/test.js | 12 +-- test/options/space-after-combinator/test.js | 12 +-- .../options/space-after-opening-brace/test.js | 14 ++-- .../test.js | 2 +- .../space-after-selector-delimiter/test.js | 12 +-- .../space-before-closing-brace/test.js | 12 +-- test/options/space-before-colon-sass/test.js | 4 +- test/options/space-before-colon/test.js | 12 +-- test/options/space-before-combinator/test.js | 14 ++-- .../space-before-opening-brace-scss/test.js | 4 +- .../space-before-opening-brace/test.js | 14 ++-- .../space-before-selector-delimiter/test.js | 12 +-- .../space-between-declarations/test.js | 18 ++--- test/options/strip-spaces/test.js | 39 +++++----- test/options/tab-size/test.js | 6 +- test/options/unitless-zero/test.js | 44 +++++------ test/options/vendor-prefix-align-sass/test.js | 4 +- test/options/vendor-prefix-align/test.js | 30 ++++---- 46 files changed, 459 insertions(+), 454 deletions(-) diff --git a/test/core/configure/test.js b/test/core/configure/test.js index 21ae216a..0ecf6383 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -25,9 +25,10 @@ describe('csscomb methods', function() { comb = new Comb({ 'always-semicolon': true }); input = 'a { color: tomato }'; expected = 'a { color: tomato; }'; - output = comb.processString(input); - - assert.equal(expected, output); + return comb.processString(input) + .then(function(actual) { + assert.equal(actual, expected); + }); }); it.skip('new Comb() should be chainable', function() { @@ -41,8 +42,10 @@ describe('csscomb methods', function() { it('configure() should be chainable', function() { input = 'a { color: tomato }'; expected = 'a { color: tomato; }'; - output = new Comb().configure({ 'always-semicolon': true }).processString(input); - - assert.equal(expected, output); + return new Comb().configure({ 'always-semicolon': true }) + .processString(input) + .then(function(actual) { + assert.equal(actual, expected); + }); }); }); diff --git a/test/mocha.js b/test/mocha.js index 47d2eae8..2744cb7d 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -25,7 +25,10 @@ function shouldBeEqual(input, expected) { var syntax = input.split('.').pop(); input = readFile.call(this, input); expected = expected ? readFile.call(this, expected) : input; - assert.equal(this.comb.processString(input, { syntax: syntax }), expected); + return this.comb.processString(input, { syntax: syntax }) + .then(function(string) { + assert.equal(string, expected); + }); } function sortObject(o) { diff --git a/test/options/always-semicolon-less/test.js b/test/options/always-semicolon-less/test.js index 250413a7..7ee40da3 100644 --- a/test/options/always-semicolon-less/test.js +++ b/test/options/always-semicolon-less/test.js @@ -5,51 +5,51 @@ describe('options/always-semicolon (less)', function() { describe('process', function() { it('Should not add semicolon to condition (single-line style)', function() { - this.shouldBeEqual('condition.less'); + return this.shouldBeEqual('condition.less'); }); it('Should not add semicolon to condition (multi-line style)', function() { - this.shouldBeEqual('condition-multiline.less'); + return this.shouldBeEqual('condition-multiline.less'); }); it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.shouldBeEqual('include-1.less', 'include-1.expected.less'); + return this.shouldBeEqual('include-1.less', 'include-1.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); + return this.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.shouldBeEqual('include-2.less', 'include-2.expected.less'); + return this.shouldBeEqual('include-2.less', 'include-2.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); + return this.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { - this.shouldBeEqual('include-3.less', 'include-3.expected.less'); + return this.shouldBeEqual('include-3.less', 'include-3.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { - this.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); + return this.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { - this.shouldBeEqual('include-4.less', 'include-4.expected.less'); + return this.shouldBeEqual('include-4.less', 'include-4.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { - this.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); + return this.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { - this.shouldBeEqual('include-5.less', 'include-5.expected.less'); + return this.shouldBeEqual('include-5.less', 'include-5.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { - this.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); + return this.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); }); }); }); diff --git a/test/options/always-semicolon-sass/test.js b/test/options/always-semicolon-sass/test.js index a649269a..195a5e1d 100644 --- a/test/options/always-semicolon-sass/test.js +++ b/test/options/always-semicolon-sass/test.js @@ -5,7 +5,7 @@ describe('options/always-semicolon (sass)', function() { describe('process', function() { it('Should not add semicolon', function() { - this.shouldBeEqual('test.sass'); + return this.shouldBeEqual('test.sass'); }); }); }); diff --git a/test/options/always-semicolon-scss/test.js b/test/options/always-semicolon-scss/test.js index 52050721..1124ce94 100644 --- a/test/options/always-semicolon-scss/test.js +++ b/test/options/always-semicolon-scss/test.js @@ -5,59 +5,59 @@ describe('options/always-semicolon (scss)', function() { describe('process', function() { it('Should not add semicolon if last value is block (singl-line style)', function() { - this.shouldBeEqual('block-value.scss'); + return this.shouldBeEqual('block-value.scss'); }); it('Should not add semicolon if last value is block (multi-line style)', function() { - this.shouldBeEqual('block-value-multiline.scss'); + return this.shouldBeEqual('block-value-multiline.scss'); }); it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); + return this.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); + return this.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); + return this.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); + return this.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); }); it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { - this.shouldBeEqual('block-include.scss'); + return this.shouldBeEqual('block-include.scss'); }); it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { - this.shouldBeEqual('block-include-multiline.scss'); + return this.shouldBeEqual('block-include-multiline.scss'); }); it('Should add semicolon to last extend if missing (single-line style)', function() { - this.shouldBeEqual('extend.scss', 'extend.expected.scss'); + return this.shouldBeEqual('extend.scss', 'extend.expected.scss'); }); it('Should add semicolon to last extend if missing (multi-line style)', function() { - this.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); + return this.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); }); it('Should not add semicolon to condition (single-line style)', function() { - this.shouldBeEqual('condition.scss'); + return this.shouldBeEqual('condition.scss'); }); it('Should not add semicolon to condition (multi-line style)', function() { - this.shouldBeEqual('condition-multiline.scss'); + return this.shouldBeEqual('condition-multiline.scss'); }); it('Should not add semicolon to loop (single-line style)', function() { - this.shouldBeEqual('loop.scss'); + return this.shouldBeEqual('loop.scss'); }); it('Should not add semicolon to loop (multi-line style)', function() { - this.shouldBeEqual('loop-multiline.scss'); + return this.shouldBeEqual('loop-multiline.scss'); }); }); }); diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js index bfba4938..85046425 100644 --- a/test/options/always-semicolon/test.js +++ b/test/options/always-semicolon/test.js @@ -4,52 +4,47 @@ describe('options/always-semicolon', function() { describe('process', function() { it('Should add semicolon for last property if missing. Test 1', function() { this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div { height: 0 }' - ), - 'div { height: 0; }' - ); + return this.comb.processString( + 'div { height: 0 }' + ).then(function(actual) { + assert.equal(actual, 'div { height: 0; }'); + }); }); it('Should add semicolon for last property if missing. Test 2', function() { this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\nheight: 0\n}' - ), - 'div {\nheight: 0;\n}' - ); + return this.comb.processString( + 'div {\nheight: 0\n}' + ).then(function(actual) { + assert.equal(actual, 'div {\nheight: 0;\n}'); + }); }); it('Should add semicolon for last property if missing. Test 3', function() { this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {height: 0}' - ), - 'div {height: 0;}' - ); + return this.comb.processString( + 'div {height: 0}' + ).then(function(actual) { + assert.equal(actual, 'div {height: 0;}'); + }); }); it('Should add semicolon for last property if missing. Test 4', function() { this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\nheight: 0 /* Comment */\n}' - ), - 'div {\nheight: 0; /* Comment */\n}' - ); + return this.comb.processString( + 'div {\nheight: 0 /* Comment */\n}' + ).then(function(actual) { + assert.equal(actual, 'div {\nheight: 0; /* Comment */\n}'); + }); }); it('Should add semicolon for last property if missing. Test 5', function() { this.comb.configure({ 'always-semicolon': true }); - assert.equal( - this.comb.processString( - 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}' - ), - 'div {\ntop: 1px;\nheight: 0; /* 1comment */ /* 2comment */\n}' - ); + return this.comb.processString( + 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}' + ).then(function(actual) { + assert.equal(actual, 'div {\ntop: 1px;\nheight: 0; /* 1comment */ /* 2comment */\n}'); + }); }); }); diff --git a/test/options/block-indent-sass/test.js b/test/options/block-indent-sass/test.js index 4ac1a04f..c7b56edc 100644 --- a/test/options/block-indent-sass/test.js +++ b/test/options/block-indent-sass/test.js @@ -2,17 +2,17 @@ describe('options/block-indent (sass):', function() { describe('process', function() { it('First level ruleset\'s block', function() { this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('block.sass', 'block.expected.sass'); + return this.shouldBeEqual('block.sass', 'block.expected.sass'); }); it('Nested ruleset', function() { this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); + return this.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); }); it('Mixin', function() { this.comb.configure({ 'block-indent': 4 }); - this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + return this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); }); }); }); diff --git a/test/options/block-indent-scss/test.js b/test/options/block-indent-scss/test.js index acb3a17f..325c331e 100644 --- a/test/options/block-indent-scss/test.js +++ b/test/options/block-indent-scss/test.js @@ -2,7 +2,7 @@ describe('options/block-indent (scss):', function() { describe('process', function() { it('Issue 213', function() { this.comb.configure({ 'block-indent': 2 }); - this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); + return this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); }); }); }); diff --git a/test/options/block-indent/test.js b/test/options/block-indent/test.js index c8000a0e..2cfb6d4b 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/test.js @@ -2,32 +2,32 @@ describe('options/block-indent:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'block-indent': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'block-indent': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'block-indent': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper number of spaces', function() { this.comb.configure({ 'block-indent': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value => should set proper number of spaces', function() { this.comb.configure({ 'block-indent': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Issue 379', function() { this.comb.configure({ 'block-indent': 4 }); - this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); + return this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); }); }); @@ -66,7 +66,7 @@ describe('options/block-indent:', function() { it('Valid string value => should set proper space after combnator', function() { this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); }); diff --git a/test/options/color-case/test.js b/test/options/color-case/test.js index b56713ed..248036e4 100644 --- a/test/options/color-case/test.js +++ b/test/options/color-case/test.js @@ -4,44 +4,39 @@ describe('options/color-case', function() { describe('process', function() { it('Should switch colors to upper case', function() { this.comb.configure({ 'color-case': 'upper' }); - assert.equal( - this.comb.processString( - 'div { color: #fff }' - ), - 'div { color: #FFF }' - ); + return this.comb.processString( + 'div { color: #fff }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #FFF }'); + }); }); it('Should switch colors to lower case', function() { this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( - 'div { color: #FFF }' - ), - 'div { color: #fff }' - ); + return this.comb.processString( + 'div { color: #FFF }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #fff }'); + }); }); it('Should switch color-case in complex rules', function() { this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( - 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + - ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' - ), - 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat;' + - ' box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }' - ); + this.comb.processString( + 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + + ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' + ).then(function(actual) { + assert.equal(actual, 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat; box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }'); + }); }); it('Should not switch selector case', function() { this.comb.configure({ 'color-case': 'lower' }); - assert.equal( - this.comb.processString( - '#Header { color: #FFF }' - ), - '#Header { color: #fff }' - ); + return this.comb.processString( + '#Header { color: #FFF }' + ).then(function(actual) { + assert.equal(actual, '#Header { color: #fff }'); + }); }); }); diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/test.js index 0e791a29..9cf35df4 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/test.js @@ -4,32 +4,29 @@ describe('options/color-shorthand', function() { describe('process', function() { it('Should shrink hexadecimal colors to 3 symbols', function() { this.comb.configure({ 'color-shorthand': true }); - assert.equal( - this.comb.processString( - 'div { color: #aabbcc }' - ), - 'div { color: #abc }' - ); + return this.comb.processString( + 'div { color: #aabbcc }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #abc }'); + }); }); it('Should expand hexadecimal colors to 6 symbols', function() { this.comb.configure({ 'color-shorthand': false }); - assert.equal( - this.comb.processString( - 'div { color: #7ad }' - ), - 'div { color: #77aadd }' - ); + return this.comb.processString( + 'div { color: #7ad }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #77aadd }'); + }); }); it('Should save case while processing', function() { this.comb.configure({ 'color-shorthand': true }); - assert.equal( - this.comb.processString( - 'div { color: #fFAafF }' - ), - 'div { color: #fAf }' - ); + return this.comb.processString( + 'div { color: #fFAafF }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #fAf }'); + }); }); }); diff --git a/test/options/element-case-scss/test.js b/test/options/element-case-scss/test.js index 89a14e01..f06a08b0 100644 --- a/test/options/element-case-scss/test.js +++ b/test/options/element-case-scss/test.js @@ -2,7 +2,7 @@ describe('options/element-case (scss):', function() { describe('process', function() { it('Should not touch mixin names', function() { this.comb.configure({ 'element-case': 'lower' }); - this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + return this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); }); }); }); diff --git a/test/options/element-case/test.js b/test/options/element-case/test.js index 4d6354c9..af67e36c 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/test.js @@ -4,42 +4,38 @@ describe('options/element-case', function() { describe('process', function() { it('Invalid String should not change case of elements', function() { this.comb.configure({ 'element-case': 'foobar' }); - assert.equal( - this.comb.processString( - 'LI a { color : red }' - ), + return this.comb.processString( 'LI a { color : red }' - ); + ).then(function(actual) { + assert.equal(actual, 'LI a { color : red }'); + }); }); it('Should switch tag name to upper case', function() { this.comb.configure({ 'element-case': 'upper' }); - assert.equal( - this.comb.processString( - 'div { color: #fff }' - ), - 'DIV { color: #fff }' - ); + return this.comb.processString( + 'div { color: #fff }' + ).then(function(actual) { + assert.equal(actual, 'DIV { color: #fff }'); + }); }); it('Should switch tag name to lower case', function() { this.comb.configure({ 'element-case': 'lower' }); - assert.equal( - this.comb.processString( - 'DIV { color: #FFF }' - ), - 'div { color: #FFF }' - ); + return this.comb.processString( + 'DIV { color: #FFF }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #FFF }'); + }); }); it('Should switch element-case in complex rules', function() { this.comb.configure({ 'element-case': 'lower' }); - assert.equal( - this.comb.processString( - 'UL > LI > .foo:not(A) { color: red }' - ), - 'ul > li > .foo:not(a) { color: red }' - ); + return this.comb.processString( + 'UL > LI > .foo:not(A) { color: red }' + ).then(function(actual) { + assert.equal(actual, 'ul > li > .foo:not(a) { color: red }'); + }); }); }); diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/test.js index d8436cea..ebf6c207 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/test.js @@ -4,30 +4,29 @@ describe('options/eof-newline', function() { describe('process', function() { it('Invalid value should not change trim trailing brac', function() { this.comb.configure({ 'eof-newline': 'foobar' }); - assert.equal( - this.comb.processString('a { color: red } \n'), + return this.comb.processString( 'a { color: red } \n' - ); + ).then(function(actual) { + assert.equal(actual, 'a { color: red } \n'); + }); }); it('Boolean true value should insert line-break at eof', function() { this.comb.configure({ 'eof-newline': true }); - assert.equal( - this.comb.processString( - 'a {color:red} ' - ), - 'a {color:red} \n' - ); + return this.comb.processString( + 'a {color:red} ' + ).then(function(actual) { + assert.equal(actual, 'a {color:red} \n'); + }); }); it('Boolean false value should remove line-break from eof', function() { this.comb.configure({ 'eof-newline': false }); - assert.equal( - this.comb.processString( - 'a {color:red} \n' - ), - 'a {color:red} ' - ); + return this.comb.processString( + 'a {color:red} \n' + ).then(function(actual) { + assert.equal(actual, 'a {color:red} '); + }); }); }); diff --git a/test/options/integral/test.js b/test/options/integral/test.js index 8e48b7ea..ebd95b2b 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/test.js @@ -3,19 +3,19 @@ describe('integral test', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('integral.css', 'integral.expected.css'); + return this.shouldBeEqual('integral.css', 'integral.expected.css'); }); it('Issue 252', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); + return this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); }); it('Issue 374', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('issue-374.css'); + return this.shouldBeEqual('issue-374.css'); }); }); diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/test.js index d6ecff7d..84fb0a8c 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/test.js @@ -4,22 +4,20 @@ describe('options/leading-zero', function() { describe('process', function() { it('Should add leading zero in dimensions', function() { this.comb.configure({ 'leading-zero': true }); - assert.equal( - this.comb.processString( - 'div { margin: .5em }' - ), - 'div { margin: 0.5em }' - ); + return this.comb.processString( + 'div { margin: .5em }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0.5em }'); + }); }); it('Should remove leading zero in dimensions', function() { this.comb.configure({ 'leading-zero': false }); - assert.equal( - this.comb.processString( - 'div { margin: 0.5em }' - ), - 'div { margin: .5em }' - ); + return this.comb.processString( + 'div { margin: 0.5em }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: .5em }'); + }); }); }); diff --git a/test/options/quotes/test.js b/test/options/quotes/test.js index e9088289..00b1fde9 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/test.js @@ -4,70 +4,56 @@ describe('options/quotes', function() { describe('process', function() { it('Invalid String should not change quotes', function() { this.comb.configure({ quotes: 3 }); - assert.equal( - this.comb.processString( - 'a { content: "" }' + - 'b { content: \'\' }' - ), - 'a { content: "" }' + - 'b { content: \'\' }' - ); + return this.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "" }b { content: \'\' }'); + }); }); it('`single` value should set the quotes to single', function() { this.comb.configure({ quotes: 'single' }); - assert.equal( - this.comb.processString( - 'a { content: "" }' + - 'b { content: \'\' }' - ), - 'a { content: \'\' }' + - 'b { content: \'\' }' - ); + return this.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: \'\' }b { content: \'\' }'); + }); }); it('`double` value should set the quotes to double', function() { this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( - 'a { content: "" }' + - 'b { content: \'\' }' - ), - 'a { content: "" }' + - 'b { content: "" }' - ); + return this.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "" }b { content: "" }'); + }); }); it('`double` value should set the quotes to double in attrs and urls', function() { this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( - 'a[class^=\'foo\'] { background: url(\'foo.png\') }' - ), - 'a[class^="foo"] { background: url("foo.png") }' - ); + return this.comb.processString( + 'a[class^=\'foo\'] { background: url(\'foo.png\') }' + ).then(function(actual) { + assert.equal(actual, 'a[class^="foo"] { background: url("foo.png") }'); + }); }); it('`double` value should escape the unescaped double quotes on change', function() { this.comb.configure({ quotes: 'double' }); - assert.equal( - this.comb.processString( - 'a { content: "\\"" }' + - 'b { content: \'"\' }' - ), - 'a { content: "\\"" }' + - 'b { content: "\\"" }' - ); + return this.comb.processString( + 'a { content: "\\"" }b { content: \'"\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "\\"" }b { content: "\\"" }'); + }); }); it('`single` value should unescape the escaped double quotes on change', function() { this.comb.configure({ quotes: 'single' }); - assert.equal( - this.comb.processString( - 'a { content: "\\"" }' - ), - 'a { content: \'"\' }' - ); + return this.comb.processString( + 'a { content: "\\"" }' + ).then(function(actual) { + assert.equal(actual, 'a { content: \'"\' }'); + }); }); }); diff --git a/test/options/remove-empty-rulesets-less/test.js b/test/options/remove-empty-rulesets-less/test.js index a867d677..b4e52071 100644 --- a/test/options/remove-empty-rulesets-less/test.js +++ b/test/options/remove-empty-rulesets-less/test.js @@ -4,13 +4,16 @@ describe('options/remove-empty-rulesets (less):', function() { describe('process', function() { it('Issue 201. Test 1', function() { this.comb.configure({ 'remove-empty-rulesets': true }); - this.shouldBeEqual('1.less', '1.expected.less'); + return this.shouldBeEqual('1.less', '1.expected.less'); }); it('Issue 201. Test 2', function() { this.comb.configure({ 'remove-empty-rulesets': true }); var string = '#a {#b {} #d {}}'; - assert.equal(this.comb.processString(string, { syntax: 'less' }), ''); + return this.comb.processString(string, { syntax: 'less' }) + .then(function(actual) { + assert.equal(actual, ''); + }); }); it('Issue 201. Test 3', function() { @@ -19,7 +22,10 @@ describe('options/remove-empty-rulesets (less):', function() { 'always-semicolon': true }); var string = '#a {#b {} #d {}}'; - assert.equal(this.comb.processString(string, { syntax: 'less' }), string); + return this.comb.processString(string, { syntax: 'less' }) + .then(function(actual) { + assert.equal(actual, string); + }); }); }); }); diff --git a/test/options/remove-empty-rulesets-scss/test.js b/test/options/remove-empty-rulesets-scss/test.js index 9ee6ec9f..dae5e8ff 100644 --- a/test/options/remove-empty-rulesets-scss/test.js +++ b/test/options/remove-empty-rulesets-scss/test.js @@ -5,19 +5,19 @@ describe('options/remove-empty-rulesets (scss)', function() { describe('process', function() { it('Should not remove rulesets which contain only includes', function() { - this.shouldBeEqual('include.scss'); + return this.shouldBeEqual('include.scss'); }); it('Should remove rulesets with contain only empty nested rules', function() { - this.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); + return this.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); }); it('Should not remove rulesets with non-empty nested rules. Test 1', function() { - this.shouldBeEqual('nested-rule-1.scss'); + return this.shouldBeEqual('nested-rule-1.scss'); }); it('Should not remove rulesets with non-empty nested rules. Test 2', function() { - this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + return this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); }); }); }); diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/test.js index fcaa253c..ba5598a8 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/test.js @@ -4,7 +4,10 @@ describe('options/remove-empty-rulesets', function() { describe('process', function() { it('Configured with invalid value, should not remove empty ruleset', function() { this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); - assert.equal(this.comb.processString('a { width: 10px; } b {}'), 'a { width: 10px; } b {}'); + return this.comb.processString('a { width: 10px; } b {}') + .then(function(actual) { + assert.equal(actual, 'a { width: 10px; } b {}'); + }); }); describe('configured with Boolean "true" value', function() { @@ -13,19 +16,31 @@ describe('options/remove-empty-rulesets', function() { }); it('should remove empty ruleset', function() { - assert.equal(this.comb.processString(' b {} '), ' '); + return this.comb.processString(' b {} ') + .then(function(actual) { + assert.equal(actual, ' '); + }); }); it('should remove ruleset with spaces', function() { - assert.equal(this.comb.processString(' b { } '), ' '); + return this.comb.processString(' b { } ') + .then(function(actual) { + assert.equal(actual, ' '); + }); }); it('should leave ruleset with declarations', function() { - assert.equal(this.comb.processString('a { width: 10px; }\nb {} '), 'a { width: 10px; }\n '); + return this.comb.processString('a { width: 10px; }\nb {} ') + .then(function(actual) { + assert.equal(actual, 'a { width: 10px; }\n '); + }); }); it('should leave ruleset with comments', function() { - assert.equal(this.comb.processString('a { /* comment */ }\nb {} '), 'a { /* comment */ }\n '); + return this.comb.processString('a { /* comment */ }\nb {} ') + .then(function(actual) { + assert.equal(actual, 'a { /* comment */ }\n '); + }); }); }); }); diff --git a/test/options/sass/test.js b/test/options/sass/test.js index f587c366..49654e3c 100644 --- a/test/options/sass/test.js +++ b/test/options/sass/test.js @@ -5,103 +5,103 @@ describe('Sass', function() { describe('process', function() { it('Should parse nested rules', function() { - this.shouldBeEqual('nested-rule.sass'); + return this.shouldBeEqual('nested-rule.sass'); }); it('Should parse parent selector &', function() { - this.shouldBeEqual('parent-selector.sass'); + return this.shouldBeEqual('parent-selector.sass'); }); it('Should parse nested properties', function() { - this.shouldBeEqual('nested-property.sass'); + return this.shouldBeEqual('nested-property.sass'); }); it('Should parse variables', function() { - this.shouldBeEqual('variable.sass'); + return this.shouldBeEqual('variable.sass'); }); it('Should parse interpolated variables inside selectors', function() { - this.shouldBeEqual('interpolated-variable-1.sass'); + return this.shouldBeEqual('interpolated-variable-1.sass'); }); it('Should parse interpolated variables inside values', function() { - this.shouldBeEqual('interpolated-variable-2.sass'); + return this.shouldBeEqual('interpolated-variable-2.sass'); }); it('Should parse defaults', function() { - this.shouldBeEqual('default.sass'); + return this.shouldBeEqual('default.sass'); }); it('Should parse @import', function() { - this.shouldBeEqual('import.sass'); + return this.shouldBeEqual('import.sass'); }); it('Should parse @include', function() { - this.shouldBeEqual('include.sass'); + return this.shouldBeEqual('include.sass'); }); it('Should parse nested @media', function() { - this.shouldBeEqual('nested-media.sass'); + return this.shouldBeEqual('nested-media.sass'); }); it('Should parse @extend with classes', function() { - this.shouldBeEqual('extend-1.sass'); + return this.shouldBeEqual('extend-1.sass'); }); it('Should parse @extend with placeholders', function() { - this.shouldBeEqual('extend-2.sass'); + return this.shouldBeEqual('extend-2.sass'); }); it('Should parse @warn', function() { - this.shouldBeEqual('warn.sass'); + return this.shouldBeEqual('warn.sass'); }); it('Should parse @if', function() { - this.shouldBeEqual('if.sass'); + return this.shouldBeEqual('if.sass'); }); it('Should parse @if and @else', function() { - this.shouldBeEqual('if-else.sass'); + return this.shouldBeEqual('if-else.sass'); }); it('Should parse @if and @else if', function() { - this.shouldBeEqual('if-else-if.sass'); + return this.shouldBeEqual('if-else-if.sass'); }); it('Should parse @for', function() { - this.shouldBeEqual('for.sass'); + return this.shouldBeEqual('for.sass'); }); it('Should parse @each', function() { - this.shouldBeEqual('each.sass'); + return this.shouldBeEqual('each.sass'); }); it('Should parse @while', function() { - this.shouldBeEqual('while.sass'); + return this.shouldBeEqual('while.sass'); }); it('Should parse mixins', function() { - this.shouldBeEqual('mixin-1.sass'); + return this.shouldBeEqual('mixin-1.sass'); }); it('Should parse passing several variables to a mixin', function() { - this.shouldBeEqual('mixin-2.sass'); + return this.shouldBeEqual('mixin-2.sass'); }); it('Should parse passing a list of variables to a mixin', function() { - this.shouldBeEqual('mixin-3.sass'); + return this.shouldBeEqual('mixin-3.sass'); }); it('Should parse passing a content block to a mixin', function() { - this.shouldBeEqual('mixin-4.sass'); + return this.shouldBeEqual('mixin-4.sass'); }); it('Should parse @content', function() { - this.shouldBeEqual('content.sass'); + return this.shouldBeEqual('content.sass'); }); it('Should parse functions', function() { - this.shouldBeEqual('function.sass'); + return this.shouldBeEqual('function.sass'); }); }); }); diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/test.js index d4efede9..4f9ef128 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/test.js @@ -10,7 +10,7 @@ describe('options/sort-order-fallback', function() { ] }; this.comb.configure(config); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Should sort unknown properties alphabetically if `sort-order-fallback` is set', function() { @@ -19,7 +19,7 @@ describe('options/sort-order-fallback', function() { 'sort-order': ['top', 'left'] }; this.comb.configure(config); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { @@ -27,7 +27,7 @@ describe('options/sort-order-fallback', function() { 'sort-order': ['top', 'left'] }; this.comb.configure(config); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); }); diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index c00dfbc7..4c13db20 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -4,91 +4,91 @@ describe('options/sort-order (less)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('rule.less', 'rule.expected.less'); + return this.shouldBeEqual('rule.less', 'rule.expected.less'); }); it('Should sort properties inside nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); + return this.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); }); it('Should sort properties divided by nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'left', 'color'] ] }); - this.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); + return this.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); }); it('Should group declarations with proper comments and spaces (single line)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); + return this.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); }); it('Should group declarations with proper comments and spaces (multiple lines). Test 1', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); + return this.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); }); it('Should group declarations with proper comments and spaces (multiple lines). Test 2', function() { this.comb.configure({ 'sort-order': [ ['$variable', 'color'] ] }); - this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + return this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); }); it('Should group declarations with proper comments and spaces (multiple lines). Test 3', function() { this.comb.configure({ 'sort-order': [ ['$variable', 'color'] ] }); - this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + return this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); }); it('Should divide properties from different groups with an empty line', function() { this.comb.configure({ 'sort-order': [ ['top'], ['color'] ] }); - this.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); + return this.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); }); it('Should sort variables', function() { this.comb.configure({ 'sort-order': [ ['$variable', 'color'] ] }); - this.shouldBeEqual('variable.less', 'variable.expected.less'); + return this.shouldBeEqual('variable.less', 'variable.expected.less'); }); it('Should sort imports', function() { this.comb.configure({ 'sort-order': [ ['$import', 'color'] ] }); - this.shouldBeEqual('import.less', 'import.expected.less'); + return this.shouldBeEqual('import.less', 'import.expected.less'); }); it('Should sort included mixins. Test 1', function() { this.comb.configure({ 'sort-order': [ ['$include', 'color', 'border-top', 'border-bottom'] ] }); - this.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); + return this.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); }); it('Should sort included mixins. Test 2', function() { this.comb.configure({ 'sort-order': [ ['$include', 'top', 'color'] ] }); - this.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); + return this.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); }); it('Should sort included mixins. Test 3', function() { this.comb.configure({ 'sort-order': [ ['$include', 'border', 'color'] ] }); - this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); + return this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); }); }); }); diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index bb914968..57a27367 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -4,84 +4,84 @@ describe('options/sort-order (sass)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('rule.sass', 'rule.expected.sass'); + return this.shouldBeEqual('rule.sass', 'rule.expected.sass'); }); it('Should sort properties inside nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); + return this.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); }); it('Should sort properties divided by nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'left', 'color'] ] }); - this.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); + return this.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); }); it('Should group declarations with proper comments and spaces (multiple lines)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('comments.sass', 'comments.expected.sass'); + return this.shouldBeEqual('comments.sass', 'comments.expected.sass'); }); it('Should divide properties from different groups with an empty line', function() { this.comb.configure({ 'sort-order': [ ['top'], ['color'] ] }); - this.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); + return this.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); }); it('Should sort variables', function() { this.comb.configure({ 'sort-order': [ ['$variable', 'color'] ] }); - this.shouldBeEqual('variable.sass', 'variable.expected.sass'); + return this.shouldBeEqual('variable.sass', 'variable.expected.sass'); }); it('Should sort imports', function() { this.comb.configure({ 'sort-order': [ ['$import', 'color'] ] }); - this.shouldBeEqual('import.sass', 'import.expected.sass'); + return this.shouldBeEqual('import.sass', 'import.expected.sass'); }); it('Should sort @include-s', function() { this.comb.configure({ 'sort-order': [ ['$include', 'color'] ] }); - this.shouldBeEqual('include.sass', 'include.expected.sass'); + return this.shouldBeEqual('include.sass', 'include.expected.sass'); }); it('Should sort @extend-s', function() { this.comb.configure({ 'sort-order': [ ['$include', 'color'] ] }); - this.shouldBeEqual('extend.sass', 'extend.expected.sass'); + return this.shouldBeEqual('extend.sass', 'extend.expected.sass'); }); it('Should sort properties inside blocks passed to mixins', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + return this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); }); it('Should handle properties preceeding rulesets', function() { this.comb.configure({ 'sort-order': [ ['top', 'left', 'color'] ] }); - this.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); + return this.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); }); it('Should handle properties preceeding conditions', function() { this.comb.configure({ 'sort-order': [ ['font-size', 'display', 'top', 'color'] ] }); - this.shouldBeEqual('condition.sass', 'condition.expected.sass'); + return this.shouldBeEqual('condition.sass', 'condition.expected.sass'); }); }); }); diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 8b71de48..313e098f 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -4,98 +4,98 @@ describe('options/sort-order (scss)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('rule.scss', 'rule.expected.scss'); + return this.shouldBeEqual('rule.scss', 'rule.expected.scss'); }); it('Should sort properties inside rules (multiple lines)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('rule.scss', 'rule.expected.scss'); + return this.shouldBeEqual('rule.scss', 'rule.expected.scss'); }); it('Should sort properties inside nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); + return this.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); }); it('Should sort properties divided by nested rules', function() { this.comb.configure({ 'sort-order': [ ['top', 'left', 'color'] ] }); - this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + return this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); }); it('Should group declarations with proper comments and spaces (multiple lines)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); + return this.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); }); it('Should group declarations with proper comments and spaces (single line)', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); + return this.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); }); it('Should divide properties from different groups with an empty line', function() { this.comb.configure({ 'sort-order': [ ['top'], ['color'] ] }); - this.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); + return this.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); }); it('Should sort variables', function() { this.comb.configure({ 'sort-order': [ ['$variable', 'color'] ] }); - this.shouldBeEqual('variable.scss', 'variable.expected.scss'); + return this.shouldBeEqual('variable.scss', 'variable.expected.scss'); }); it('Should sort imports', function() { this.comb.configure({ 'sort-order': [ ['$import', 'color'] ] }); - this.shouldBeEqual('import.scss', 'import.expected.scss'); + return this.shouldBeEqual('import.scss', 'import.expected.scss'); }); it('Should sort @include-s', function() { this.comb.configure({ 'sort-order': [ ['$include', 'color'] ] }); - this.shouldBeEqual('include.scss', 'include.expected.scss'); + return this.shouldBeEqual('include.scss', 'include.expected.scss'); }); it('Should sort @extend-s', function() { this.comb.configure({ 'sort-order': [ ['$include', 'color'] ] }); - this.shouldBeEqual('extend.scss', 'extend.expected.scss'); + return this.shouldBeEqual('extend.scss', 'extend.expected.scss'); }); it('Should sort properties inside blocks passed to mixins', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] ] }); - this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + return this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); }); it('Should handle properties preceeding rulesets', function() { this.comb.configure({ 'sort-order': [ ['top', 'left', 'color'] ] }); - this.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); + return this.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); }); it('Should handle properties preceeding conditions', function() { this.comb.configure({ 'sort-order': [ ['font-size', 'display', 'top', 'color'] ] }); - this.shouldBeEqual('condition.scss', 'condition.expected.scss'); + return this.shouldBeEqual('condition.scss', 'condition.expected.scss'); }); it('Should sort complex case with leftovers', function() { @@ -108,17 +108,17 @@ describe('options/sort-order (scss)', function() { ["font"] ] }); - this.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); + return this.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); }); it('Issue 317', function() { this.comb.configure({ 'sort-order': ['...'] }); - this.shouldBeEqual('issue-317.scss'); + return this.shouldBeEqual('issue-317.scss'); }); it('Issue 333', function() { this.comb.configure({ 'sort-order': ['...'] }); - this.shouldBeEqual('issue-333.scss'); + return this.shouldBeEqual('issue-333.scss'); }); }); }); diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index a0719ee3..43809aac 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -4,14 +4,14 @@ describe('options/sort-order', function() { describe('process', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); - this.shouldBeEqual('single-group.css', 'single-group.expected.css'); + return this.shouldBeEqual('single-group.css', 'single-group.expected.css'); }); it('Should be in expected order in case of 1 group', function() { this.comb.configure({ 'sort-order': [ ['position', 'z-index'] ] }); - this.shouldBeEqual('single-group.css', 'single-group.expected.css'); + return this.shouldBeEqual('single-group.css', 'single-group.expected.css'); }); it('Shuld be in expected order in case of multiple groups', function() { @@ -19,7 +19,7 @@ describe('options/sort-order', function() { ['position', 'z-index'], ['width', 'height'] ] }); - this.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); + return this.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); }); @@ -27,7 +27,7 @@ describe('options/sort-order', function() { this.comb.configure({ 'sort-order': [ ['border-bottom', 'font-style'], ] }); - this.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); + return this.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); }); it('Should work correctly with comments in case of multiple groups', function() { @@ -35,7 +35,7 @@ describe('options/sort-order', function() { ['margin'], ['padding'] ] }); - this.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); + return this.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); }); it('Should parse semicolons inside data uri correctly', function() { @@ -44,7 +44,7 @@ describe('options/sort-order', function() { ['position', 'background', 'color'] ] }); - this.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); + return this.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); }); it('Should not add more than 1 line between groups', function() { @@ -56,58 +56,69 @@ describe('options/sort-order', function() { ] }); - for (var i = 6; i--;) { - input = this.comb.processString(input); - } - assert.equal(input, expected); + this.comb.processString(input) + .then(this.comb.processString) + .then(this.comb.processString) + .then(this.comb.processString) + .then(this.comb.processString) + .then(this.comb.processString) + .then(function(actual) { + assert.equal(actual, expected); + }); }); it('Issue 94. Test 1', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); + return this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); }); it('Issue 94. Test 2', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); + return this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); }); it('Issue 94. Test 3', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); + return this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); }); it('Should place the leftovers in the end', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); - this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); + return this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); }); it('Should place the leftovers in the beginning', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][0].unshift(['...']); this.comb.configure(config); - this.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css'); - config['sort-order'][0].shift(); + return this.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css') + .then(function() { + config['sort-order'][0].shift(); + }); }); it('Should place the leftovers in the beginning of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].unshift('...'); this.comb.configure(config); - this.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css'); - config['sort-order'][1].shift(); + return this.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css') + .then(function() { + config['sort-order'][1].shift(); + }); }); it('Should place the leftovers in the middle of its group', function() { var config = this.Comb.getConfig('csscomb'); config['sort-order'][1].splice(1, 0, '...'); this.comb.configure(config); - this.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css'); - config['sort-order'][1].splice(1, 1); + return this.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css') + .then(function() { + config['sort-order'][1].splice(1, 1); + }); }); }); }); diff --git a/test/options/space-after-colon-sass/test.js b/test/options/space-after-colon-sass/test.js index bf7c9383..81052b7f 100644 --- a/test/options/space-after-colon-sass/test.js +++ b/test/options/space-after-colon-sass/test.js @@ -2,12 +2,12 @@ describe('options/space-after-colon (sass):', function() { describe('process', function() { it('Should set proper space if colon is after property name', function() { this.comb.configure({ 'space-after-colon': 2 }); - this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); + return this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); }); it('Should not change space after colon which is before property name', function() { this.comb.configure({ 'space-after-colon': 1 }); - this.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); + return this.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); }); }); }); diff --git a/test/options/space-after-colon-scss/test.js b/test/options/space-after-colon-scss/test.js index b1d55398..996eee00 100644 --- a/test/options/space-after-colon-scss/test.js +++ b/test/options/space-after-colon-scss/test.js @@ -2,7 +2,7 @@ describe('options/space-after-colon (scss):', function() { describe('process', function() { it('Space after colon should not affect pseudo elements', function() { this.comb.configure({ 'space-after-colon': 1 }); - this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); + return this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); }); }); }); diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/test.js index 81af81b8..8de8b4c2 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/test.js @@ -2,32 +2,32 @@ describe('options/space-after-colon:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-after-colon': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space after colon', function() { this.comb.configure({ 'space-after-colon': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only)=> should set proper space after colon', function() { this.comb.configure({ 'space-after-colon': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spacesand newlines)=> should set proper space after colon', function() { this.comb.configure({ 'space-after-colon': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/test.js index 364546fe..b9efec9a 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/test.js @@ -2,32 +2,32 @@ describe('options/space-after-combinator:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space after combinator', function() { this.comb.configure({ 'space-after-combinator': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space after combinator', function() { this.comb.configure({ 'space-after-combinator': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space after combinator', function() { this.comb.configure({ 'space-after-combinator': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/test.js index 5c6ea5c0..ee4a8035 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/test.js @@ -2,37 +2,37 @@ describe('options/space-after-opening-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space after {', function() { this.comb.configure({ 'space-after-opening-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space after {', function() { this.comb.configure({ 'space-after-opening-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space after {', function() { this.comb.configure({ 'space-after-opening-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); it('Issue 387', function() { this.comb.configure({ 'space-after-opening-brace': '\n' }); - this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); + return this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); }); }); diff --git a/test/options/space-after-selector-delimiter-sass/test.js b/test/options/space-after-selector-delimiter-sass/test.js index e748c540..a38ebacb 100644 --- a/test/options/space-after-selector-delimiter-sass/test.js +++ b/test/options/space-after-selector-delimiter-sass/test.js @@ -2,7 +2,7 @@ describe('options/space-after-selector-delimiter (sass):', function() { describe('process', function() { it('Issue 238', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n' }); - this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); + return this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); }); }); }); diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/test.js index 15128e18..b4957a19 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/test.js @@ -2,32 +2,32 @@ describe('options/space-after-selector-delimiter:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space after selector delimiter', function() { this.comb.configure({ 'space-after-selector-delimiter': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space after selector delimiter', function() { this.comb.configure({ 'space-after-selector-delimiter': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space after selector delimiter', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/test.js index 6ece137a..6e73205a 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/test.js @@ -2,32 +2,32 @@ describe('options/space-before-closing-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space before }', function() { this.comb.configure({ 'space-before-closing-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space before }', function() { this.comb.configure({ 'space-before-closing-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space before }', function() { this.comb.configure({ 'space-before-closing-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-before-colon-sass/test.js b/test/options/space-before-colon-sass/test.js index 70f21859..62e6380b 100644 --- a/test/options/space-before-colon-sass/test.js +++ b/test/options/space-before-colon-sass/test.js @@ -2,12 +2,12 @@ describe('options/space-before-colon-sass:', function() { describe('process', function() { it('Should correct space', function() { this.comb.configure({ 'space-before-colon': 1 }); - this.shouldBeEqual('test.sass', 'test.expected.sass'); + return this.shouldBeEqual('test.sass', 'test.expected.sass'); }); it('Should not correct space', function() { this.comb.configure({ 'space-before-colon': 1 }); - this.shouldBeEqual('test2.sass'); + return this.shouldBeEqual('test2.sass'); }); }); }); diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/test.js index e4acb58c..4db00ae8 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/test.js @@ -2,32 +2,32 @@ describe('options/space-before-colon:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-before-colon': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space before colon', function() { this.comb.configure({ 'space-before-colon': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space before colon', function() { this.comb.configure({ 'space-before-colon': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space before colon', function() { this.comb.configure({ 'space-before-colon': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/test.js index 4292210d..2d74a26a 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/test.js @@ -2,37 +2,37 @@ describe('options/space-before-combinator:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space before combinator', function() { this.comb.configure({ 'space-before-combinator': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space before combinator', function() { this.comb.configure({ 'space-before-combinator': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space before combinator', function() { this.comb.configure({ 'space-before-combinator': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); it('Issue 381', function() { this.comb.configure({ 'space-before-combinator': ' ' }); - this.shouldBeEqual('issue-381.css'); + return this.shouldBeEqual('issue-381.css'); }); }); diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace-scss/test.js index 971d485d..0abc84bb 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace-scss/test.js @@ -2,12 +2,12 @@ describe('options/space-before-opening-brace (scss):', function() { describe('process', function() { it('Issue 231', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); + return this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); }); it('Issue 319', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); + return this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); }); }); }); diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/test.js index ab077bba..de336baf 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/test.js @@ -2,37 +2,37 @@ describe('options/space-before-opening-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space before {', function() { this.comb.configure({ 'space-before-opening-brace': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space before {', function() { this.comb.configure({ 'space-before-opening-brace': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space before {', function() { this.comb.configure({ 'space-before-opening-brace': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); it('Issue 232', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); - this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); + return this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); }); }); diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/test.js index d4bec32d..fd3c5827 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/test.js @@ -2,32 +2,32 @@ describe('options/space-before-selector-delimiter:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space before selector delimiter', function() { this.comb.configure({ 'space-before-selector-delimiter': 0 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); it('Valid string value (spaces only) => should set proper space before selector delimiter', function() { this.comb.configure({ 'space-before-selector-delimiter': ' ' }); - this.shouldBeEqual('test.css', 'test-2.expected.css'); + return this.shouldBeEqual('test.css', 'test-2.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space before selector delimiter', function() { this.comb.configure({ 'space-before-selector-delimiter': '\n ' }); - this.shouldBeEqual('test.css', 'test-3.expected.css'); + return this.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/test.js index 451e318b..3324b2c9 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/test.js @@ -2,47 +2,47 @@ describe('options/space-between-declarations:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ['', ' '] }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Invalid string value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ' nani ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Float number value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': 3.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Integer value => should set proper space after declaration', function() { this.comb.configure({ 'space-between-declarations': 0 }); - this.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); + return this.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); }); it('Valid string value (spaces only) => should set proper space after declaration', function() { this.comb.configure({ 'space-between-declarations': ' ' }); - this.shouldBeEqual('space-value.css', 'space-value.expected.css'); + return this.shouldBeEqual('space-value.css', 'space-value.expected.css'); }); it('Valid string value (spaces and newlines) => should set proper space after declaration', function() { this.comb.configure({ 'space-between-declarations': '\n ' }); - this.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); + return this.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); }); it('Should leave comments as is', function() { this.comb.configure({ 'space-between-declarations': 1 }); - this.shouldBeEqual('comments.css', 'comments.expected.css'); + return this.shouldBeEqual('comments.css', 'comments.expected.css'); }); it('Issue 239', function() { this.comb.configure({ 'space-between-declarations': '\n ' }); - this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); + return this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); }); it('Issue 378', function() { this.comb.configure({ 'space-between-declarations': '\n' }); - this.shouldBeEqual('issue-378.css'); + return this.shouldBeEqual('issue-378.css'); }); }); }); diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/test.js index 130c01c2..f5d417fd 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/test.js @@ -4,34 +4,33 @@ describe('options/strip-spaces', function() { describe('process', function() { it('Invalid value should not trim trailing spaces', function() { this.comb.configure({ 'strip-spaces': 'foobar' }); - assert.equal( - this.comb.processString('a { color: red } \n'), - 'a { color: red } \n' - ); + return this.comb.processString('a { color: red } \n') + .then(function(actual) { + assert.equal(actual, 'a { color: red } \n'); + }); }); it('Boolean true value should trim all trailing spaces', function() { this.comb.configure({ 'strip-spaces': true }); - assert.equal( - this.comb.processString( - 'a { color: red } \n' + - 'a{color:red}\t /* foobar */\t \n' + - 'a {color:red} \n \n' - ), - 'a { color: red }\n' + - 'a{color:red}\t /* foobar */\n' + - 'a {color:red}\n' - ); + return this.comb.processString( + 'a { color: red } \n' + + 'a{color:red}\t /* foobar */\t \n' + + 'a {color:red} \n \n' + ).then(function(actual) { + assert.equal(actual, + 'a { color: red }\n' + + 'a{color:red}\t /* foobar */\n' + + 'a {color:red}\n'); + }); }); it('Boolean true value should trim trailing spaces at eof', function() { this.comb.configure({ 'strip-spaces': true }); - assert.equal( - this.comb.processString( - 'a {color:red} ' - ), - 'a {color:red}' - ); + return this.comb.processString( + 'a {color:red} ' + ).then(function(actual) { + assert.equal(actual, 'a {color:red}'); + }); }); }); diff --git a/test/options/tab-size/test.js b/test/options/tab-size/test.js index d59fff13..83e7c9f7 100644 --- a/test/options/tab-size/test.js +++ b/test/options/tab-size/test.js @@ -2,17 +2,17 @@ describe('options/tab-size:', function() { describe('process', function() { it('Test 1: String value => should not change anything', function() { this.comb.configure({ 'tab-size': ' ' }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Test 2: Float value => should not change anything', function() { this.comb.configure({ 'tab-size': 4.5 }); - this.shouldBeEqual('test.css'); + return this.shouldBeEqual('test.css'); }); it('Test 3: Integer value => should replace tabs with proper number of spaces', function() { this.comb.configure({ 'tab-size': 4 }); - this.shouldBeEqual('test.css', 'test.expected.css'); + return this.shouldBeEqual('test.css', 'test.expected.css'); }); }); }); diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js index 84c0896d..61fe2bba 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/test.js @@ -4,36 +4,38 @@ describe('options/unitless-zero', function() { describe('process', function() { it('Should remove units in zero-valued dimensions', function() { this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString( - 'div { margin: 0em; padding: 0px }' - ), - 'div { margin: 0; padding: 0 }' - ); - assert.equal( - this.comb.processString( - 'div { margin: 0% }' - ), - 'div { margin: 0 }' - ); + return this.comb.processString( + 'div { margin: 0em; padding: 0px }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0; padding: 0 }'); + }); + }); + + it('Should remove units in zero-valued dimensions, test 2', function() { + this.comb.configure({ 'unitless-zero': true }); + return this.comb.processString( + 'div { margin: 0% }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0 }'); + }); }); it('Should remove units in zero-valued media-query params', function() { this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString('@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }'), - '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }' - ); + return this.comb.processString( + '@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }' + ).then(function(actual) { + assert.equal(actual, '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }'); + }); }); it('Should not remove units (degs) in rotate property', function() { this.comb.configure({ 'unitless-zero': true }); - assert.equal( - this.comb.processString( - 'div { -webkit-transform: rotate(0deg); }' - ), + return this.comb.processString( 'div { -webkit-transform: rotate(0deg); }' - ); + ).then(function(actual) { + assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); + }); }); }); diff --git a/test/options/vendor-prefix-align-sass/test.js b/test/options/vendor-prefix-align-sass/test.js index bfbc94f8..ffead985 100644 --- a/test/options/vendor-prefix-align-sass/test.js +++ b/test/options/vendor-prefix-align-sass/test.js @@ -5,11 +5,11 @@ describe('options/vendor-prefix-align', function() { describe('process', function() { it('Should align prexied values', function() { - this.shouldBeEqual('value.sass', 'value.expected.sass'); + return this.shouldBeEqual('value.sass', 'value.expected.sass'); }); it('Should not align prefixed property names', function() { - this.shouldBeEqual('property.sass'); + return this.shouldBeEqual('property.sass'); }); }); }); diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/test.js index 5a2ec788..ce4bf182 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/test.js @@ -5,59 +5,59 @@ describe('options/vendor-prefix-align', function() { describe('process', function() { it('Should correctly work when there is comment before property name', function() { - this.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); + return this.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); }); it('Should correctly work when there is comment before property name. Test 2', function() { - this.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); + return this.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); }); it('Should correctly work when there is comment before property name. Test 3', function() { - this.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); + return this.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); }); it('Should correctly align prefixes in properties', function() { - this.shouldBeEqual('property-align.css', 'property-align.expected.css'); + return this.shouldBeEqual('property-align.css', 'property-align.expected.css'); }); it('Should correctly align prefixes in values', function() { - this.shouldBeEqual('value-align.css', 'value-align.expected.css'); + return this.shouldBeEqual('value-align.css', 'value-align.expected.css'); }); it('Should not touch already align prefixes', function() { - this.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); + return this.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); }); it('Should correctly align prefixes in properties and values at the same time', function() { - this.shouldBeEqual('both.css', 'both.expected.css'); + return this.shouldBeEqual('both.css', 'both.expected.css'); }); it('Should correctly work when value and property names are the same', function() { - this.shouldBeEqual('same-name.css', 'same-name.expected.css'); + return this.shouldBeEqual('same-name.css', 'same-name.expected.css'); }); it('Should correctly work when there is no whitespace after colon', function() { - this.shouldBeEqual('without-space.css', 'without-space.expected.css'); + return this.shouldBeEqual('without-space.css', 'without-space.expected.css'); }); it('Should correctly work when there is comment after colon', function() { - this.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); + return this.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); }); it('Should not do anything with oneliners', function() { - this.shouldBeEqual('one-line.css', 'one-line.expected.css'); + return this.shouldBeEqual('one-line.css', 'one-line.expected.css'); }); it('Should not do anything with oneliners. Test 2', function() { - this.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); + return this.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); }); it('Should always correctly align prefixes', function() { - this.shouldBeEqual('complex.css', 'complex.expected.css'); + return this.shouldBeEqual('complex.css', 'complex.expected.css'); }); it('Issue 193: should handle declarations without preceding spaces', function() { - this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); + return this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); }); it('Issue 241: should not break tabs', function() { @@ -65,7 +65,7 @@ describe('options/vendor-prefix-align', function() { 'block-indent': '\t', 'vendor-prefix-align': true }); - this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); + return this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); }); }); From 83b289191df83b07f698fca0e28c9e4b86313944 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 21 Jun 2015 00:50:45 +0300 Subject: [PATCH 091/184] [gpe] Get syntax from ast itself --- src/options/block-indent.js | 12 ++++++------ src/options/sort-order.js | 9 ++++----- src/options/space-after-colon.js | 6 +++--- src/options/space-before-closing-brace.js | 3 +-- src/options/space-before-colon.js | 6 +++--- src/options/vendor-prefix-align.js | 7 +++---- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/options/block-indent.js b/src/options/block-indent.js index 5b31c1a6..e82bc20a 100644 --- a/src/options/block-indent.js +++ b/src/options/block-indent.js @@ -15,7 +15,7 @@ module.exports = { * * @param {node} ast */ - process: function process(ast, syntax) { + process: function process(ast) { ast.eachFor('space', function(whitespaceNode, i) { var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); @@ -26,7 +26,7 @@ module.exports = { } }); - this._processNode(ast, syntax, 0); + this._processNode(ast, 0); }, /** @@ -58,22 +58,22 @@ module.exports = { return detected; }, - _processNode: function _processNode(node, syntax, level) { + _processNode: function _processNode(node, level) { var that = this; node.forEach(function(n) { - if (syntax === 'sass' && n.is('block')) { + if (node.syntax === 'sass' && n.is('block')) { that._processSassBlock(n, level); } // Continue only with space nodes inside {...}: - if (syntax !== 'sass' && level !== 0 && n.is('space')) { + if (node.syntax !== 'sass' && level !== 0 && n.is('space')) { that._processSpaceNode(n, level); } if (n.is('block') || n.is('atrulers')) level++; - that._processNode(n, syntax, level); + that._processNode(n, level); }); }, diff --git a/src/options/sort-order.js b/src/options/sort-order.js index d9a44d35..f199e391 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -37,10 +37,9 @@ module.exports = { /** * Processes tree node. * @param {node} ast - * @param {string} syntax * @param {object} config */ - process: function(ast, syntax, config) { + process: function(ast, config) { // Types of nodes that can be sorted: var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', 'singlelineComment', 'declaration', 'space', 'include', 'extend']; @@ -217,7 +216,7 @@ module.exports = { deleted.push(i + 1); i++; - if (syntax === 'sass') return extendedNode; + if (ast.syntax === 'sass') return extendedNode; // Save spaces and comments which follow right after // the declaration and mark them for removing from parent node: @@ -383,7 +382,7 @@ module.exports = { if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { if (sc0[0] && sc0[0].is('space') && - (syntax === 'sass' || + (ast.syntax === 'sass' || sc0[0].content.match(/\n/g) && sc0[0].content.match(/\n/g).length < 2)) { sc0[0].content = '\n' + sc0[0].content; @@ -394,7 +393,7 @@ module.exports = { node.content.unshift(sc2[j]); } if (currentNode.delim.length > 0) { - var delim = syntax === 'sass' ? '\n' : ';'; + var delim = ast.syntax === 'sass' ? '\n' : ';'; var declDelim = gonzales.createNode({ type: 'declarationDelimiter', content: delim diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index eea371d5..8aa711ea 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -16,14 +16,14 @@ module.exports = { * Processes tree node. * * @param {node} ast - * @param {String} syntax */ - process: function(ast, syntax) { + process: function(ast) { let value = this.value; ast.traverseByType('declaration', function(declaration) { declaration.eachFor('propertyDelimiter', function(delimiter, i) { - if (syntax === 'sass' && !declaration.get(i - 1)) return null; + if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) + return null; // Remove any spaces after colon: if (declaration.get(i + 1).is('space')) diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 87bccc6d..65ddc658 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -69,10 +69,9 @@ module.exports = (function() { /** * Processes tree node. * @param {node} ast - * @param {String} syntax * @param {Object} config */ - process: function(ast, syntax, config) { + process: function(ast, config) { valueFromSettings = this.value; blockIndent = config['block-indent']; diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 3305a96f..989ce8e1 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -16,14 +16,14 @@ module.exports = { * Processes tree node. * * @param {node} ast - * @param {String} syntax */ - process: function(ast, syntax) { + process: function(ast) { let value = this.value; ast.traverseByType('declaration', function(declaration) { declaration.forEach('propertyDelimiter', function(delimiter, i) { - if (syntax === 'sass' && !declaration.get(i - 1)) return; + if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) + return; // Remove any spaces before colon: if (declaration.get(i - 1).is('space')) { diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index cf6146c6..afda08ff 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -274,9 +274,8 @@ module.exports = (function() { * Processes tree node. * * @param {node} ast - * @param {String} syntax */ - process: function(ast, syntax) { + process: function(ast) { ast.traverseByType('block', function(node) { oneline = true; @@ -302,7 +301,7 @@ module.exports = (function() { } }); - if (oneline && syntax !== 'sass') return; + if (oneline && ast.syntax !== 'sass') return; // Update nodes walk({ @@ -331,7 +330,7 @@ module.exports = (function() { } }); - if (syntax === 'sass') return; + if (ast.syntax === 'sass') return; walk({ node: node, From bca4c788d5640beefded1b29876166bea5a33070 Mon Sep 17 00:00:00 2001 From: Aleks Hudochenkov Date: Sun, 21 Jun 2015 01:32:17 +0300 Subject: [PATCH 092/184] [options] Divide `$include` into `$extend`, `$include name` and `$include` Update sort-order option docs for extends. Fixes #143, #356, #204. --- doc/options.md | 16 ++++++++-- src/options/sort-order.js | 29 +++++++++++++++++-- .../sort-order-less/extend.expected.less | 7 +++++ test/options/sort-order-less/extend.less | 7 +++++ .../sort-order-less/mixin-4.expected.less | 9 ++++++ test/options/sort-order-less/mixin-4.less | 7 +++++ test/options/sort-order-less/test.js | 14 +++++++++ .../include-specified-1.expected.sass | 12 ++++++++ .../sort-order-sass/include-specified-1.sass | 10 +++++++ .../include-specified-2.expected.sass | 12 ++++++++ .../sort-order-sass/include-specified-2.sass | 10 +++++++ test/options/sort-order-sass/test.js | 18 ++++++++++-- .../include-specified.expected.scss | 13 +++++++++ .../sort-order-scss/include-specified.scss | 11 +++++++ test/options/sort-order-scss/test.js | 9 +++++- 15 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 test/options/sort-order-less/extend.expected.less create mode 100644 test/options/sort-order-less/extend.less create mode 100644 test/options/sort-order-less/mixin-4.expected.less create mode 100644 test/options/sort-order-less/mixin-4.less create mode 100644 test/options/sort-order-sass/include-specified-1.expected.sass create mode 100644 test/options/sort-order-sass/include-specified-1.sass create mode 100644 test/options/sort-order-sass/include-specified-2.expected.sass create mode 100644 test/options/sort-order-sass/include-specified-2.sass create mode 100644 test/options/sort-order-scss/include-specified.expected.scss create mode 100644 test/options/sort-order-scss/include-specified.scss diff --git a/doc/options.md b/doc/options.md index 8be912bc..f4c64efe 100644 --- a/doc/options.md +++ b/doc/options.md @@ -336,11 +336,14 @@ If you sort properties in `*.scss` or `*.less` files, you can use one of 3 keywords in your config: * `$variable` — for variable declarations (e.g. `$var` in Sass or `@var` in LESS); -* `$include` — for included mixins (e.g. `@include ...` and `@extend ...` in Sass - or `.mixin()` in LESS); +* `$include` — for all mixins except those that have been specified (e.g. `@include ...` in Sass + or `.mixin()` in LESS); +* `$include mixin-name` — for mixins with specified name (e.g. `@include mixin-name` in Sass + or `.mixin-name()` in LESS); +* `$extend` — for extends (e.g. `@extend .foo` in Sass or `&:extend(.foo)` in LESS); * `$import` — for `@import` rules. -Example: `{ "sort-order": [ [ "$variable" ], [ "$include" ], [ "top", "padding" ] ] }` +Example: `{ "sort-order": [ [ "$variable" ], [ "$include" ], [ "top", "padding" ], [ "$include media" ] ] }` ```scss /* before */ @@ -348,6 +351,9 @@ p { padding: 0; @include mixin($color); $color: tomato; + @include media("desktop") { + color: black; + } top: 0; } @@ -359,6 +365,10 @@ p { top: 0; padding: 0; + + @include media("desktop") { + color: black; + } } ``` diff --git a/src/options/sort-order.js b/src/options/sort-order.js index f199e391..1442e4af 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -297,9 +297,32 @@ module.exports = { // If not, proceed with the next node: propertyName = null; // Look for includes: - if (node.get(i).is('include') || - node.get(i).is('extend')) { - propertyName = '$include'; + if (node.get(i).is('include')) { + // Divide `include` into mixins with specific + // name (e. g. `$include breakpoint`), + // and the rest — `$include`. + var mixinName; + + // SASS and SCSS both supports `@include`, + // but SASS also supports `+mixin-name` + if (ast.syntax === 'less') { + mixinName = node.get(i).get(0).get(0).content; + } else if (ast.syntax === 'sass' && + node.get(i).get(0).content === '+') { + mixinName = node.get(i).get(1).get(0).content; + } else { + mixinName = node.get(i).get(2).get(0).content; + } + + var includeMixinName = '$include ' + mixinName; + + if (order.hasOwnProperty(includeMixinName)) { + propertyName = includeMixinName; + } else { + propertyName = '$include'; + } + } else if (node.get(i).is('extend')) { + propertyName = '$extend'; } else { for (j = 0, nl = node.get(i).length; j < nl; j++) { currentNode = node.get(i).get(j); diff --git a/test/options/sort-order-less/extend.expected.less b/test/options/sort-order-less/extend.expected.less new file mode 100644 index 00000000..82f0e172 --- /dev/null +++ b/test/options/sort-order-less/extend.expected.less @@ -0,0 +1,7 @@ +.block { + &:extend(.foo); + color: black; +} +.a:extend(.b) { + color: pink; +} diff --git a/test/options/sort-order-less/extend.less b/test/options/sort-order-less/extend.less new file mode 100644 index 00000000..2d1fcff9 --- /dev/null +++ b/test/options/sort-order-less/extend.less @@ -0,0 +1,7 @@ +.block { + color: black; + &:extend(.foo); +} +.a:extend(.b) { + color: pink; +} diff --git a/test/options/sort-order-less/mixin-4.expected.less b/test/options/sort-order-less/mixin-4.expected.less new file mode 100644 index 00000000..94c24ed9 --- /dev/null +++ b/test/options/sort-order-less/mixin-4.expected.less @@ -0,0 +1,9 @@ +.block { + .last; + .hide-text; + + color: black; + + .media("lap"); + .media("palm"); +} diff --git a/test/options/sort-order-less/mixin-4.less b/test/options/sort-order-less/mixin-4.less new file mode 100644 index 00000000..b405880c --- /dev/null +++ b/test/options/sort-order-less/mixin-4.less @@ -0,0 +1,7 @@ +.block { + color: black; + .media("lap"); + .media("palm"); + .last; + .hide-text; +} diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order-less/test.js index 4c13db20..16b2f111 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order-less/test.js @@ -90,5 +90,19 @@ describe('options/sort-order (less)', function() { ] }); return this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); }); + + it('Should sort included mixins with specified name. Test 4', function() { + this.comb.configure({ 'sort-order': [ + ['$include'], ['color'], ['$include media'] + ] }); + this.shouldBeEqual('mixin-4.less', 'mixin-4.expected.less'); + }); + + it('Should sort @extend-s', function() { + this.comb.configure({ 'sort-order': [ + ['$extend', 'color'] + ] }); + this.shouldBeEqual('extend.less', 'extend.expected.less'); + }); }); }); diff --git a/test/options/sort-order-sass/include-specified-1.expected.sass b/test/options/sort-order-sass/include-specified-1.expected.sass new file mode 100644 index 00000000..ff3a056f --- /dev/null +++ b/test/options/sort-order-sass/include-specified-1.expected.sass @@ -0,0 +1,12 @@ +.block + +last + +hide-text + + color: black + + +media(lap) + color: green + + +media(palm) + color: red + diff --git a/test/options/sort-order-sass/include-specified-1.sass b/test/options/sort-order-sass/include-specified-1.sass new file mode 100644 index 00000000..5782d546 --- /dev/null +++ b/test/options/sort-order-sass/include-specified-1.sass @@ -0,0 +1,10 @@ +.block + color: black + +media(lap) + color: green + + +media(palm) + color: red + + +last + +hide-text diff --git a/test/options/sort-order-sass/include-specified-2.expected.sass b/test/options/sort-order-sass/include-specified-2.expected.sass new file mode 100644 index 00000000..d9a38e51 --- /dev/null +++ b/test/options/sort-order-sass/include-specified-2.expected.sass @@ -0,0 +1,12 @@ +.block + @include last + @include hide-text + + color: black + + @include media(lap) + color: green + + @include media(palm) + color: red + diff --git a/test/options/sort-order-sass/include-specified-2.sass b/test/options/sort-order-sass/include-specified-2.sass new file mode 100644 index 00000000..9ca4de9c --- /dev/null +++ b/test/options/sort-order-sass/include-specified-2.sass @@ -0,0 +1,10 @@ +.block + color: black + @include media(lap) + color: green + + @include media(palm) + color: red + + @include last + @include hide-text diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 57a27367..30d5433e 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -56,13 +56,27 @@ describe('options/sort-order (sass)', function() { return this.shouldBeEqual('include.sass', 'include.expected.sass'); }); - it('Should sort @extend-s', function() { + it.skip('Should sort @extend-s', function() { this.comb.configure({ 'sort-order': [ - ['$include', 'color'] + ['$extend', 'color'] ] }); return this.shouldBeEqual('extend.sass', 'extend.expected.sass'); }); + it.skip('Should sort @include-s with specified name. Test 1', function() { + this.comb.configure({ 'sort-order': [ + ['$include'], ['color'], ['$include media'] + ] }); + this.shouldBeEqual('include-specified-1.sass', 'include-specified-1.expected.sass'); + }); + + it.skip('Should sort @include-s with specified name. Test 2', function() { + this.comb.configure({ 'sort-order': [ + ['$include'], ['color'], ['$include media'] + ] }); + this.shouldBeEqual('include-specified-2.sass', 'include-specified-2.expected.sass'); + }); + it('Should sort properties inside blocks passed to mixins', function() { this.comb.configure({ 'sort-order': [ ['top', 'color'] diff --git a/test/options/sort-order-scss/include-specified.expected.scss b/test/options/sort-order-scss/include-specified.expected.scss new file mode 100644 index 00000000..412f47d2 --- /dev/null +++ b/test/options/sort-order-scss/include-specified.expected.scss @@ -0,0 +1,13 @@ +.block { + @include last; + @include hide-text; + + color: black; + + @include media("lap") { + color: green; + } + @include media("palm") { + color: red; + } +} diff --git a/test/options/sort-order-scss/include-specified.scss b/test/options/sort-order-scss/include-specified.scss new file mode 100644 index 00000000..40b8c98e --- /dev/null +++ b/test/options/sort-order-scss/include-specified.scss @@ -0,0 +1,11 @@ +.block { + color: black; + @include media("lap") { + color: green; + } + @include media("palm") { + color: red; + } + @include last; + @include hide-text; +} diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 313e098f..8cdb0f75 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -70,9 +70,16 @@ describe('options/sort-order (scss)', function() { return this.shouldBeEqual('include.scss', 'include.expected.scss'); }); + it('Should sort @include-s with specified name', function() { + this.comb.configure({ 'sort-order': [ + ['$include'], ['color'], ['$include media'] + ] }); + this.shouldBeEqual('include-specified.scss', 'include-specified.expected.scss'); + }); + it('Should sort @extend-s', function() { this.comb.configure({ 'sort-order': [ - ['$include', 'color'] + ['$extend', 'color'] ] }); return this.shouldBeEqual('extend.scss', 'extend.expected.scss'); }); From 1237bf2daa104cee1c284cd2407754f116750341 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 21 Jun 2015 01:48:02 +0300 Subject: [PATCH 093/184] [tools] Install core and GPE from GitHub --- package.json | 5 +++-- scripts/postinstall.sh | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 scripts/postinstall.sh diff --git a/package.json b/package.json index 124c5b50..5ce945fb 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "minimist": "1.1.x", - "csscomb-core": "3.0.0-8", - "gonzales-pe": "3.0.0-31", + "csscomb-core": "csscomb/core#build-dev", + "gonzales-pe": "tonyganch/gonzales-pe#build-dev", "vow": "0.4.4" }, "devDependencies": { @@ -63,6 +63,7 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", + "postinstall": "./scripts/postinstall.sh", "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh new file mode 100755 index 00000000..d4037980 --- /dev/null +++ b/scripts/postinstall.sh @@ -0,0 +1,2 @@ +cd ./node_modules/gonzales-pe && npm i && npm run build && cd - +cd ./node_modules/csscomb-core && npm i && npm run build && cd - From 44f2232499127d0a94d37b116178ddc45fac52e3 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 21 Jun 2015 10:21:44 +0300 Subject: [PATCH 094/184] [options] Add test for #332 --- test/options/sort-order-sass/issue-332.expected.sass | 9 +++++++++ test/options/sort-order-sass/issue-332.sass | 11 +++++++++++ test/options/sort-order-sass/test.js | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 test/options/sort-order-sass/issue-332.expected.sass create mode 100644 test/options/sort-order-sass/issue-332.sass diff --git a/test/options/sort-order-sass/issue-332.expected.sass b/test/options/sort-order-sass/issue-332.expected.sass new file mode 100644 index 00000000..390beee6 --- /dev/null +++ b/test/options/sort-order-sass/issue-332.expected.sass @@ -0,0 +1,9 @@ +.block + color: black + + +media(lap) + color: green + +media(palm) + color: red + +last + +hide-text diff --git a/test/options/sort-order-sass/issue-332.sass b/test/options/sort-order-sass/issue-332.sass new file mode 100644 index 00000000..3eee3b09 --- /dev/null +++ b/test/options/sort-order-sass/issue-332.sass @@ -0,0 +1,11 @@ +.block + +media(lap) + color: green + + +media(palm) + color: red + + color: black + + +last + +hide-text diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 30d5433e..867bf9ee 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -97,5 +97,12 @@ describe('options/sort-order (sass)', function() { ] }); return this.shouldBeEqual('condition.sass', 'condition.expected.sass'); }); + + it.skip('Issue 332', function() { + this.comb.configure({ 'sort-order': [ + ['color'], ['$include'] + ] }); + return this.shouldBeEqual('issue-332.sass', 'issue-332.expected.sass'); + }); }); }); From bd726d7bd5de6466da2d802886976ca5699912e9 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 21 Jun 2015 10:28:30 +0300 Subject: [PATCH 095/184] [options] Sort order: Rewrite plugin to be simpler --- src/options/sort-order.js | 707 ++++++++++++++++++-------------------- 1 file changed, 331 insertions(+), 376 deletions(-) diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 1442e4af..318fbcb4 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -1,25 +1,30 @@ var gonzales = require('gonzales-pe'); module.exports = { - name: 'sort-order', + get name() { + return 'sort-order'; + }, - runBefore: 'space-before-closing-brace', + get runBefore() { + return 'space-before-closing-brace'; + }, - syntax: ['css', 'less', 'sass', 'scss'], + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, /** - * Sets handler value. - * * @param {Array} value Option value * @returns {Array} */ - setValue: function(value) { + setValue(value) { if (!Array.isArray(value)) throw new Error('The option accepts only array of properties.'); var order = {}; if (typeof value[0] === 'string') { + // If there is only one group of properties. value.forEach(function(prop, propIndex) { order[prop] = {group: 0, prop: propIndex}; }); @@ -35,404 +40,354 @@ module.exports = { }, /** - * Processes tree node. * @param {node} ast * @param {object} config */ - process: function(ast, config) { - // Types of nodes that can be sorted: - var NODES = ['atruleb', 'atruler', 'atrules', 'multilineComment', - 'singlelineComment', 'declaration', 'space', 'include', 'extend']; - // Spaces and comments: - var SC = ['multilineComment', 'singlelineComment', 'space']; - - var node; - var currentNode; - // Sort order of properties: - var order = this.value; - // List of declarations that should be sorted: - var sorted = []; - // List of nodes that should be removed from parent node: - var deleted = []; - // List of spaces and comments that go before declaration/@-rule: - var sc0 = []; - // Value to search in sort order: either a declaration's property name - // (e.g. `color`), or @-rule's special keyword (e.g. `$import`): - var propertyName; - - // Index to place the nodes that shouldn't be sorted - var lastGroupIndex = order['...'] ? order['...'].group : Infinity; - var lastPropertyIndex = order['...'] ? order['...'].prop : Infinity; - - // Counters for loops: - var i; - var l; - var j; - var nl; - - /** - * Remove empty lines in space node. - * @param {node} node Space node. - */ - var removeEmptyLines = function(node) { - node.content = node.content.replace(/\n[\s\t\n\r]*\n/, '\n'); - }; - - /** - * Check if there are any comments or spaces before - * the declaration/@-rule. - * @returns {Array} List of nodes with spaces and comments - */ - var checkSC0 = function() { - // List of nodes with spaces and comments: - var sc = []; - // List of nodes that can be later deleted from parent node: - var d = []; - - for (; i < l; i++) { - currentNode = node.get(i); - // If there is no node left, - // stop and do nothing with previously found spaces/comments: - if (!currentNode) { - return false; - } - - // If the node is declaration or @-rule, stop and return all - // found nodes with spaces and comments (if there are any): - if (SC.indexOf(currentNode.type) === -1) break; + process(ast, config) { + this._config = config; + // Sort properties only inside blocks. + ast.traverseByType('block', this._processBlock.bind(this)); + }, - sc.push(currentNode); - d.push(i); + _extendNode(block, i, spacesBefore) { + let nodesToDelete = [i]; + let node = block.get(i); + let extendedNode = {i: i, node: node}; + + let propertyName = this._getSortableName(node); + if (!propertyName) return null; + + // Check if current node's property name is in sort order. + let propertyIndex = this.value[propertyName]; + // If the declaration's property is in order's list, save its + // group and property indices. Otherwise set them to 10000, so + // declaration appears at the bottom of a sorted list: + extendedNode.groupIndex = propertyIndex && propertyIndex.group > -1 ? + propertyIndex.group : this._getLastGroupIndex(); + extendedNode.propertyIndex = propertyIndex && propertyIndex.prop > -1 ? + propertyIndex.prop : this._getLastPropertyIndex(); + + // Spaces before node. + nodesToDelete = nodesToDelete.concat(spacesBefore); + extendedNode.spacesBeforeNode = + this._getNodesByIndex(block, spacesBefore); + + // Spaces after node. + let spacesBeforeDelimiter = + this._getSpacesAndCommentsAfterNode(block, i); + nodesToDelete = nodesToDelete.concat(spacesBeforeDelimiter); + extendedNode.spacesBeforeDelimiter = + this._getNodesByIndex(block, spacesBeforeDelimiter); + + i += spacesBeforeDelimiter.length + 1; + node = block.get(i); + + // Spaces after delimiter. + // If there is `;` right after the declaration, save it with the + // declaration and mark it for removing from parent node: + if (node && node.is('declarationDelimiter')) { + nodesToDelete.push(i); + extendedNode.delim = node; + + if (node.syntax !== 'sass') { + // Save spaces and comments which follow right after + // the declaration and mark them for removing from parent node: + let spacesAfterDelimiter = + this._getSpacesAndCommentsAfterNode(block, i); + i += spacesAfterDelimiter.length; + nodesToDelete = nodesToDelete.concat(spacesAfterDelimiter); + extendedNode.spacesAfterDelimiter = + this._getNodesByIndex(block, spacesAfterDelimiter); } + } - deleted = deleted.concat(d); - - return sc; - }; - - /** - * Check if there are any comments or spaces after - * the declaration/@-rule. - * @returns {Array} List of nodes with spaces and comments - * @private - */ - var checkSC1 = function() { - // List of nodes with spaces and comments: - var sc = []; - // List of nodes that can be later deleted from parent node: - var d = []; - // Position of `\n` symbol inside a node with spaces: - var lbIndex; - - // Check every next node: - for (; i < l; i++) { - currentNode = node.get(i + 1); - // If there is no node, or it is nor spaces neither comment, - // stop: - if (!currentNode || SC.indexOf(currentNode.type) === -1) break; - - if (currentNode.is('multilineComment') || - currentNode.is('singlelineComment')) { - sc.push(currentNode); - d.push(i + 1); - continue; - } + extendedNode.endIndex = i; + // Remove all nodes, that were moved to `sortables` list, + // from block node: + extendedNode.nodesToDelete = nodesToDelete; - lbIndex = currentNode.content.indexOf('\n'); - - // If there are any line breaks in a node with spaces, stop and - // split the node into two: one with spaces before line break - // and one with `\n` symbol and everything that goes after. - // Combine the first one with declaration/@-rule's node: - if (lbIndex > -1) { - // TODO: Don't push an empty array - var s = currentNode.content.substring(0, lbIndex); - var space = gonzales.createNode({type: 's', content: s}); - sc.push(space); - currentNode.content = currentNode.content - .substring(lbIndex); - break; - } + return extendedNode; + }, + + _getLastGroupIndex() { + return this.value && this.value['...'] ? + this.value['...'].group : Infinity; + }, + + _getLastPropertyIndex() { + return this.value && this.value['...'] ? + this.value['...'].prop : Infinity; + }, + + _getNodesByIndex(block, index) { + return index.map((i) => block.get(i)); + }, + + _getSortableIncludeName(node) { + // Divide `include` into mixins with specific name + // (e. g. `$include breakpoint`), and the rest — `$include`. + let mixinName; + + // TODO(tonyganch): explain `first.first`. + if (node.syntax === 'less') + mixinName = node.first().first().content; + else if (node.syntax === 'sass' && node.first().content === '+') + mixinName = node.get(1).first().content; + else + mixinName = node.get(2).first().content; + + let includeMixinName = '$include ' + mixinName; + return this.value.hasOwnProperty(includeMixinName) ? + includeMixinName : + '$include'; + }, - sc.push(currentNode); - d.push(i + 1); + _getSortableName(node) { + if (node.is('extend')) return '$extend'; + if (node.is('include')) return this._getSortableIncludeName(node); + else return this._getSortablePropertyName(node); + }, + + _getSortablePropertyName(node) { + if (node.is('declaration')) { + let property = node.first('property').first(); + return property.is('variable') ? '$variable' : property.content; + } + + let atkeyword = node.first('atkeyword'); + if (atkeyword && atkeyword.first().content === 'import') + return '$import'; + }, + + _getSpacesAndCommentsAfterNode(node, i) { + // List of start positions for nodes with spaces and comments: + let positions = []; + + // Skip node itself. + i++; + + for (let l = node.length; i < l; i++) { + let currentNode = node.get(i); + + // If node is nor spaces neither comment, stop. + if (!this._isSpaceOrComment(currentNode)) break; + + if (currentNode.is('multilineComment') || + currentNode.is('singlelineComment')) { + positions.push(i); + continue; } - deleted = deleted.concat(d); - - return sc; - }; - - /** - * Combine declaration/@-rule's node with other relevant information: - * property index, semicolon, spaces and comments. - * @returns {Object} Extended node - */ - var extendNode = function() { - currentNode = node.get(i); - var nextNode = node.get(i + 1); - // Object containing current node, all corresponding spaces, - // comments and other information: - var extendedNode; - // Check if current node's property name is in sort order. - // If it is, save information about its indices: - var orderProperty = order[propertyName]; - - extendedNode = { - i: i, - node: currentNode, - sc0: sc0, - sc1: [], - sc2: [], - delim: [] - }; - - // If the declaration's property is in order's list, save its - // group and property indices. Otherwise set them to 10000, so - // declaration appears at the bottom of a sorted list: - - let groupIndex = orderProperty && orderProperty.group > -1 ? - orderProperty.group : lastGroupIndex; - let propertyIndex = orderProperty && orderProperty.prop > -1 ? - orderProperty.prop : lastPropertyIndex; - extendedNode.groupIndex = groupIndex; - extendedNode.propertyIndex = propertyIndex; - - // Mark current node to remove it later from parent node: - deleted.push(i); - - extendedNode.sc1 = checkSC1(); - - if (extendedNode.sc1.length) { - currentNode = node.get(i); - nextNode = node.get(i + 1); + // If there are any line breaks in a node with spaces, stop and + // split the node into two: one with spaces before line break + // and one with `\n` symbol and everything that goes after. + // Combine the first one with declaration/@-rule's node: + let linebreakIndex = currentNode.content.indexOf('\n'); + if (linebreakIndex !== -1) { + var s = currentNode.content.substring(0, linebreakIndex); + if (s === '') break; + var space = gonzales.createNode({type: 'space', content: s}); + node.insert(i + 1, space); + positions.push(i + 1); + currentNode.content = currentNode.content + .substring(linebreakIndex); + break; } - // If there is `;` right after the declaration, save it with the - // declaration and mark it for removing from parent node: - if (currentNode && nextNode && - nextNode.is('declarationDelimiter')) { - extendedNode.delim.push(nextNode); - deleted.push(i + 1); - i++; + positions.push(i); + } - if (ast.syntax === 'sass') return extendedNode; + return positions; + }, - // Save spaces and comments which follow right after - // the declaration and mark them for removing from parent node: - extendedNode.sc2 = checkSC1(); + /** + * Check if there are any comments or spaces before + * the declaration/@-rule. + * @param {Node} node + * @param {Number} i + * @returns {Array} List of nodes with spaces and comments + */ + _getSpacesAndCommentsBeforeNode(node, i) { + // List of start positions for nodes with spaces and comments: + let positions = []; + let sendPositions = false; + + for (let l = node.length; i < l; i++) { + let currentNode = node.get(i); + + // If the node is declaration or @-rule, stop and return all + // found nodes with spaces and comments (if there are any): + if (!this._isSpaceOrComment(currentNode)) { + sendPositions = true; + break; } - return extendedNode; - }; - - /** - * Sorts properties alphabetically. - * - * @param {Object} a First extended node - * @param {Object} b Second extended node - * @returns {Number} `-1` if properties should go in order `a, b`. `1` - * if properties should go in order `b, a`. - */ - var sortLeftovers = function(a, b) { - var prefixes = ['-webkit-', '-moz-', '-ms-', '-o-', '']; - var prefixesRegExp = /^(-webkit-|-moz-|-ms-|-o-)(.*)$/; - - // Get property name (i.e. `color`, `-o-animation`): - a = a.node.get(0).get(0).content; - b = b.node.get(0).get(0).content; - - // Get prefix and unprefixed part. For example: - // ['-o-animation', '-o-', 'animation'] - // ['color', '', 'color'] - a = a.match(prefixesRegExp) || [a, '', a]; - b = b.match(prefixesRegExp) || [b, '', b]; - - if (a[2] !== b[2]) { - // If unprefixed parts are different (i.e. `border` and - // `color`), compare them: - return a[2] < b[2] ? -1 : 1; - } else { - // If unprefixed parts are identical (i.e. `border` in - // `-moz-border` and `-o-border`), compare prefixes. - // They should go in the same order they are set - // in `prefixes` array. - return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; - } - }; - - // TODO: Think it through! - // Sort properties only inside blocks: - ast.traverseByType('block', function(block) { - node = block; - sorted = []; - deleted = []; - sc0 = []; - - // Check every child node. - // If it is declaration (property-value pair, e.g. `color: tomato`), - // or @-rule (e.g. `@include nani`), - // combine it with spaces, semicolon and comments and move them from - // current node to a separate list for further sorting: - for (i = 0, l = node.length; i < l; i++) { - if (NODES.indexOf(node.get(i).type) === -1) continue; - - // Save preceding spaces and comments, if there are any, - // and mark them for removing from parent node: - sc0 = checkSC0(); - if (!sc0) continue; - - // If spaces/comments are the last nodes, stop and go to - // sorting: - if (!node.get(i)) { - deleted.splice(deleted.length - sc0.length, - deleted.length + 1); - break; - } + positions.push(i); + } - // Check if the node needs to be sorted: - // it should be a special @-rule (e.g. `@include`) or - // a declaration - // with a valid property (e.g. `color` or `$width`). - // If not, proceed with the next node: - propertyName = null; - // Look for includes: - if (node.get(i).is('include')) { - // Divide `include` into mixins with specific - // name (e. g. `$include breakpoint`), - // and the rest — `$include`. - var mixinName; - - // SASS and SCSS both supports `@include`, - // but SASS also supports `+mixin-name` - if (ast.syntax === 'less') { - mixinName = node.get(i).get(0).get(0).content; - } else if (ast.syntax === 'sass' && - node.get(i).get(0).content === '+') { - mixinName = node.get(i).get(1).get(0).content; - } else { - mixinName = node.get(i).get(2).get(0).content; - } - - var includeMixinName = '$include ' + mixinName; - - if (order.hasOwnProperty(includeMixinName)) { - propertyName = includeMixinName; - } else { - propertyName = '$include'; - } - } else if (node.get(i).is('extend')) { - propertyName = '$extend'; - } else { - for (j = 0, nl = node.get(i).length; j < nl; j++) { - currentNode = node.get(i).get(j); - if (!currentNode) continue; - - if (currentNode.is('property')) { - propertyName = currentNode.get(0).is('variable') ? - '$variable' : currentNode.get(0).content; - break; - } else if (currentNode.is('atkeyword') && - currentNode.get(0).content === 'import') { - // Look for imports - propertyName = '$import'; - break; - } - } - } + return sendPositions ? positions : null; + }, - // If current node is not property-value pair or import or - // include, skip it and continue with the next node: - if (!propertyName) { - deleted.splice(deleted.length - sc0.length, - deleted.length + 1); - continue; + _insertSortablesToBlock(nodesToSort, node) { + for (let i = nodesToSort.length - 1, l = -1; i > l; i--) { + let currentNode = nodesToSort[i]; + let prevNode = nodesToSort[i - 1]; + let spacesBeforeNode = currentNode.spacesBeforeNode || []; + let spacesBeforeDelimiter = currentNode.spacesBeforeDelimiter || []; + let spacesAfterDelimiter = currentNode.spacesAfterDelimiter || []; + + spacesBeforeNode.reverse().map(this._removeEmptyLines); + spacesBeforeDelimiter.reverse().map(this._removeEmptyLines); + spacesAfterDelimiter.reverse().map(this._removeEmptyLines); + + // Divide declarations from different groups with + // an empty line: + if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { + let space = spacesBeforeNode[0]; + if (space && space.is('space') && + (space.syntax === 'sass' || + space.content.match(/\n/g) && + space.content.match(/\n/g).length < 2)) { + space.content = '\n' + space.content; } + } - // Make an extended node and move it to a separate list for - // further sorting: - sorted.push(extendNode()); + for (let j = 0, nl = spacesAfterDelimiter.length; j < nl; j++) { + node.content.unshift(spacesAfterDelimiter[j]); } - // Remove all nodes, that were moved to a `sorted` list, - // from parent node: - for (i = deleted.length - 1; i > -1; i--) { - node.content.splice(deleted[i], 1); + if (currentNode.delim) + node.content.unshift(currentNode.delim); + + for (let j = 0, nl = spacesBeforeDelimiter.length; j < nl; j++) { + node.content.unshift(spacesBeforeDelimiter[j]); } - // Sort declarations saved for sorting: - sorted.sort(function(a, b) { - // If a's group index is higher than b's group index, in - // a sorted list a appears after b: - if (a.groupIndex !== b.groupIndex) - return a.groupIndex - b.groupIndex; - - // If a and b belong to leftovers and `sort-order-fallback` - // option is set to `abc`, sort properties alphabetically: - if (a.groupIndex === lastGroupIndex && - config['sort-order-fallback']) { - return sortLeftovers(a, b); - } + node.content.unshift(currentNode.node); - // If a and b have the same group index, and a's property index - // is higher than b's property index, in a sorted list - // a appears after b: - if (a.propertyIndex !== b.propertyIndex) - return a.propertyIndex - b.propertyIndex; + for (let j = 0, nl = spacesBeforeNode.length; j < nl; j++) { + node.content.unshift(spacesBeforeNode[j]); + } + } + }, - // If a and b have the same group index and the same property - // index, in a sorted list they appear in the same order - // they were in original array: - return a.i - b.i; - }); + // Types of nodes that can be sorted. + _isAcceptableNode(node) { + const NODES = ['atruleb', 'atruler', 'atrules', + 'declaration', 'extend', 'include', + 'multilineComment', 'singlelineComment', 'space']; + return NODES.indexOf(node.type) !== -1; + }, - // Build all nodes back together. First go sorted declarations, then - // everything else: - if (sorted.length > 0) { - for (i = sorted.length - 1, l = -1; i > l; i--) { - currentNode = sorted[i]; - var prevNode = sorted[i - 1]; - sc0 = currentNode.sc0; - var sc1 = currentNode.sc1; - var sc2 = currentNode.sc2; - - sc0.reverse().map(removeEmptyLines); - sc1.reverse().map(removeEmptyLines); - sc2.reverse().map(removeEmptyLines); - - // Divide declarations from different groups with - // an empty line: - if (prevNode && - currentNode.groupIndex > prevNode.groupIndex) { - if (sc0[0] && sc0[0].is('space') && - (ast.syntax === 'sass' || - sc0[0].content.match(/\n/g) && - sc0[0].content.match(/\n/g).length < 2)) { - sc0[0].content = '\n' + sc0[0].content; - } - } - - for (j = 0, nl = sc2.length; j < nl; j++) { - node.content.unshift(sc2[j]); - } - if (currentNode.delim.length > 0) { - var delim = ast.syntax === 'sass' ? '\n' : ';'; - var declDelim = gonzales.createNode({ - type: 'declarationDelimiter', - content: delim - }); - node.content.unshift(declDelim); - } - for (j = 0, nl = sc1.length; j < nl; j++) { - node.content.unshift(sc1[j]); - } - node.content.unshift(currentNode.node); - - for (j = 0, nl = sc0.length; j < nl; j++) { - node.content.unshift(sc0[j]); - } - } + // Spaces and comments. + _isSpaceOrComment(node) { + const SC = ['multilineComment', 'singlelineComment', 'space']; + return SC.indexOf(node.type) !== -1; + }, + + _processBlock(block) { + // Check every child node. + // If it is declaration (property-value pair, e.g. `color: tomato`), + // or @-rule (e.g. `@include nani`), + // combine it with spaces, semicolon and comments and move them from + // current node to a separate list for further sorting: + let nodesToSort = this._separateSortablesFromBlock(block); + this._sortNodes(nodesToSort); + this._insertSortablesToBlock(nodesToSort, block); + }, + + /** + * Remove empty lines in space node. + * @param {node} node Space node. + */ + _removeEmptyLines(node) { + node.content = node.content.replace(/\n[\s\t\n\r]*\n/, '\n'); + }, + + _separateSortablesFromBlock(block) { + let sortables = []; + let nodesToDelete = []; + + // Don't cache `block.length` since we may insert new nodes into it. + for (let i = 0; i < block.length; i++) { + let node = block.get(i); + if (!this._isAcceptableNode(node)) continue; + + // Save preceding spaces and comments, if there are any, + // and mark them for removing from parent node: + let spacesBeforeNode = + this._getSpacesAndCommentsBeforeNode(block, i); + if (!spacesBeforeNode) break; + + i += spacesBeforeNode.length; + node = block.get(i); + + let extendedNode = this._extendNode(block, i, spacesBeforeNode); + if (!extendedNode) continue; + + nodesToDelete = nodesToDelete.concat(extendedNode.nodesToDelete); + i = extendedNode.endIndex; + sortables.push(extendedNode); + } + + nodesToDelete.sort((a, b) => a - b); + for (let x = nodesToDelete.length - 1; x > -1; x--) + block.remove(nodesToDelete[x]); + + return sortables; + }, + + _sortLeftovers(a, b) { + let prefixes = ['-webkit-', '-moz-', '-ms-', '-o-', '']; + let prefixesRegExp = /^(-webkit-|-moz-|-ms-|-o-)(.*)$/; + + // Get property name (i.e. `color`, `-o-animation`): + a = a.node.first().first().content; + b = b.node.first().first().content; + + // Get prefix and unprefixed part. For example: + // ['-o-animation', '-o-', 'animation'] + // ['color', '', 'color'] + a = a.match(prefixesRegExp) || [a, '', a]; + b = b.match(prefixesRegExp) || [b, '', b]; + + if (a[2] !== b[2]) { + // If unprefixed parts are different (i.e. `border` and + // `color`), compare them: + return a[2] < b[2] ? -1 : 1; + } else { + // If unprefixed parts are identical (i.e. `border` in + // `-moz-border` and `-o-border`), compare prefixes. + // They should go in the same order they are set + // in `prefixes` array. + return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; + } + }, + + _sortNodes(nodes) { + nodes.sort((a, b) => { + // If a's group index is higher than b's group index, in + // a sorted list a appears after b: + if (a.groupIndex !== b.groupIndex) + return a.groupIndex - b.groupIndex; + + // If a and b belong to leftovers and `sort-order-fallback` + // option is set to `abc`, sort properties alphabetically: + if (a.groupIndex === this._getLastGroupIndex() && + this._config['sort-order-fallback']) { + return this._sortLeftovers(a, b); } + + // If a and b have the same group index, and a's property index + // is higher than b's property index, in a sorted list + // a appears after b: + if (a.propertyIndex !== b.propertyIndex) + return a.propertyIndex - b.propertyIndex; + + // If a and b have the same group index and the same property + // index, in a sorted list they appear in the same order + // they were in original array: + return a.i - b.i; }); } }; From f00b6f56f095c70f82e6f112e166b798fab12f73 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 23 Jun 2015 01:06:00 +0300 Subject: [PATCH 096/184] [tools] Share GPE module with core Use GPE module from core's dependency (`node_modules/csscomb-core/node_modules/gonzales-pe`). This fixes two issues: (1) GPE version is always synced; (2) `npm install` does not fail on Node 0.10 because of merged packages. --- package.json | 1 - src/csscomb.js | 2 +- src/gonzales.js | 2 ++ src/options/always-semicolon.js | 2 +- src/options/eof-newline.js | 2 +- src/options/sort-order.js | 2 +- src/options/space-after-colon.js | 2 +- src/options/space-after-combinator.js | 2 +- src/options/space-after-opening-brace.js | 2 +- src/options/space-after-selector-delimiter.js | 2 +- src/options/space-before-closing-brace.js | 2 +- src/options/space-before-colon.js | 2 +- src/options/space-before-combinator.js | 2 +- src/options/space-before-opening-brace.js | 2 +- src/options/space-before-selector-delimiter.js | 2 +- src/options/space-between-declarations.js | 2 +- src/options/vendor-prefix-align.js | 2 +- 17 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 src/gonzales.js diff --git a/package.json b/package.json index 5ce945fb..f7ed8238 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "dependencies": { "minimist": "1.1.x", "csscomb-core": "csscomb/core#build-dev", - "gonzales-pe": "tonyganch/gonzales-pe#build-dev", "vow": "0.4.4" }, "devDependencies": { diff --git a/src/csscomb.js b/src/csscomb.js index 8913b26d..0681fa2a 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -1,5 +1,5 @@ let Comb = require('csscomb-core'); -let gonzales = require('gonzales-pe'); +let gonzales = require('./gonzales'); let fs = require('fs'); let format = require('./format'); let path = require('path'); diff --git a/src/gonzales.js b/src/gonzales.js new file mode 100644 index 00000000..d046b0ba --- /dev/null +++ b/src/gonzales.js @@ -0,0 +1,2 @@ +// jscs:disable +module.exports = require('../node_modules/csscomb-core/node_modules/gonzales-pe'); diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index 327d4bf6..b0a7e1cc 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'always-semicolon', diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index 5aad6b00..3e6163b0 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'eof-newline', diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 318fbcb4..8f8f9701 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { get name() { diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 8aa711ea..1342ea97 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-after-colon', diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index a487cc6e..b4cf8332 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-after-combinator', diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index 5a3a44cf..91279433 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-after-opening-brace', diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index 25cc0c4d..e5bacd76 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-after-selector-delimiter', diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 65ddc658..4a41f54d 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = (function() { var valueFromSettings; diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 989ce8e1..9b8bc2b1 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-before-colon', diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 2797288f..4caedebe 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-before-combinator', diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index c9ac31dd..1fb123db 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = (function() { /** diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index cd36136d..24f9d0ce 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = { name: 'space-before-selector-delimiter', diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 14879726..a3222ae0 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = (function() { function getDeclarationEnd(node, i) { diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index afda08ff..d2c77d03 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -1,4 +1,4 @@ -var gonzales = require('gonzales-pe'); +var gonzales = require('../gonzales'); module.exports = (function() { // Vendor prefixes list: From f694c5495090b26a87cc579de52f3f359f0ca472 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 28 Jun 2015 09:45:05 +0300 Subject: [PATCH 097/184] [options] Sort order: add missing declaration delimiters --- src/options/sort-order.js | 10 +++++++++- test/options/sort-order/missing-delimiter.css | 4 ++++ test/options/sort-order/missing-delimiter.expected.css | 4 ++++ test/options/sort-order/test.js | 5 +++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/options/sort-order/missing-delimiter.css create mode 100644 test/options/sort-order/missing-delimiter.expected.css diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 8f8f9701..8d08b4f3 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -256,8 +256,16 @@ module.exports = { node.content.unshift(spacesAfterDelimiter[j]); } - if (currentNode.delim) + if (currentNode.delim) { node.content.unshift(currentNode.delim); + } else if (i !== nodesToSort.length - 1 && + currentNode.node.is('declaration')) { + let delimiter = gonzales.createNode({ + type: 'declarationDelimiter', + content: currentNode.node.syntax === 'sass' ? '\n' : ';' + }); + node.content.unshift(delimiter); + } for (let j = 0, nl = spacesBeforeDelimiter.length; j < nl; j++) { node.content.unshift(spacesBeforeDelimiter[j]); diff --git a/test/options/sort-order/missing-delimiter.css b/test/options/sort-order/missing-delimiter.css new file mode 100644 index 00000000..cdba2d46 --- /dev/null +++ b/test/options/sort-order/missing-delimiter.css @@ -0,0 +1,4 @@ +a { + z-index: 2; + position: absolute +} diff --git a/test/options/sort-order/missing-delimiter.expected.css b/test/options/sort-order/missing-delimiter.expected.css new file mode 100644 index 00000000..f619ac51 --- /dev/null +++ b/test/options/sort-order/missing-delimiter.expected.css @@ -0,0 +1,4 @@ +a { + position: absolute; + z-index: 2; +} diff --git a/test/options/sort-order/test.js b/test/options/sort-order/test.js index 43809aac..c638a238 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/test.js @@ -120,5 +120,10 @@ describe('options/sort-order', function() { config['sort-order'][1].splice(1, 1); }); }); + + it('Should add declaration delimiters if they are missing', function() { + this.comb.configure({ 'sort-order': ['position', 'z-index'] }); + return this.shouldBeEqual('missing-delimiter.css', 'missing-delimiter.expected.css'); + }); }); }); From 2a1cd21ed85c02dd42b526815fabd2946c1d8955 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 28 Jun 2015 10:17:15 +0300 Subject: [PATCH 098/184] [options, sass] Fix sort order for extends --- src/options/sort-order.js | 20 ++++++++++++++++++- .../sort-order-sass/extend.expected.sass | 6 +++--- test/options/sort-order-sass/extend.sass | 6 +++--- .../sort-order-sass/issue-332.expected.sass | 1 + test/options/sort-order-sass/test.js | 8 ++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 8d08b4f3..a48d10ca 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -49,6 +49,20 @@ module.exports = { ast.traverseByType('block', this._processBlock.bind(this)); }, + _cleanSassLinebreaks(node) { + let containsOnlyLinebreaks = true; + + node.forEach((space) => { + if (!space.is('space') || space.content !== '\n') { + containsOnlyLinebreaks = false; + return null; + } + }); + + if (containsOnlyLinebreaks) + node.content = []; + }, + _extendNode(block, i, spacesBefore) { let nodesToDelete = [i]; let node = block.get(i); @@ -229,6 +243,9 @@ module.exports = { }, _insertSortablesToBlock(nodesToSort, node) { + if (node.syntax === 'sass') + this._cleanSassLinebreaks(node); + for (let i = nodesToSort.length - 1, l = -1; i > l; i--) { let currentNode = nodesToSort[i]; let prevNode = nodesToSort[i - 1]; @@ -259,7 +276,8 @@ module.exports = { if (currentNode.delim) { node.content.unshift(currentNode.delim); } else if (i !== nodesToSort.length - 1 && - currentNode.node.is('declaration')) { + (currentNode.node.is('declaration') || + currentNode.node.is('extend'))) { let delimiter = gonzales.createNode({ type: 'declarationDelimiter', content: currentNode.node.syntax === 'sass' ? '\n' : ';' diff --git a/test/options/sort-order-sass/extend.expected.sass b/test/options/sort-order-sass/extend.expected.sass index a0ba2c9c..62ecc2e7 100644 --- a/test/options/sort-order-sass/extend.expected.sass +++ b/test/options/sort-order-sass/extend.expected.sass @@ -1,3 +1,3 @@ - div - @extend %nani - color: tomato +div + @extend %nani + color: tomato diff --git a/test/options/sort-order-sass/extend.sass b/test/options/sort-order-sass/extend.sass index fe9c177a..e4e3550d 100644 --- a/test/options/sort-order-sass/extend.sass +++ b/test/options/sort-order-sass/extend.sass @@ -1,3 +1,3 @@ - div - color: tomato - @extend %nani +div + color: tomato + @extend %nani diff --git a/test/options/sort-order-sass/issue-332.expected.sass b/test/options/sort-order-sass/issue-332.expected.sass index 390beee6..d16ef320 100644 --- a/test/options/sort-order-sass/issue-332.expected.sass +++ b/test/options/sort-order-sass/issue-332.expected.sass @@ -5,5 +5,6 @@ color: green +media(palm) color: red + +last +hide-text diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 867bf9ee..08007458 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -56,21 +56,21 @@ describe('options/sort-order (sass)', function() { return this.shouldBeEqual('include.sass', 'include.expected.sass'); }); - it.skip('Should sort @extend-s', function() { + it('Should sort @extend-s', function() { this.comb.configure({ 'sort-order': [ ['$extend', 'color'] ] }); return this.shouldBeEqual('extend.sass', 'extend.expected.sass'); }); - it.skip('Should sort @include-s with specified name. Test 1', function() { + it('Should sort @include-s with specified name. Test 1', function() { this.comb.configure({ 'sort-order': [ ['$include'], ['color'], ['$include media'] ] }); this.shouldBeEqual('include-specified-1.sass', 'include-specified-1.expected.sass'); }); - it.skip('Should sort @include-s with specified name. Test 2', function() { + it('Should sort @include-s with specified name. Test 2', function() { this.comb.configure({ 'sort-order': [ ['$include'], ['color'], ['$include media'] ] }); @@ -98,7 +98,7 @@ describe('options/sort-order (sass)', function() { return this.shouldBeEqual('condition.sass', 'condition.expected.sass'); }); - it.skip('Issue 332', function() { + it('Issue 332', function() { this.comb.configure({ 'sort-order': [ ['color'], ['$include'] ] }); From ce1c7ecc663641b0a7d3ed776092487b75e34c30 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 28 Jun 2015 10:50:29 +0300 Subject: [PATCH 099/184] [sass] Add one more test for #332 --- .../sort-order-sass/issue-332-2.expected.sass | 46 +++++++++++++++++++ test/options/sort-order-sass/issue-332-2.sass | 46 +++++++++++++++++++ test/options/sort-order-sass/test.js | 8 ++++ 3 files changed, 100 insertions(+) create mode 100644 test/options/sort-order-sass/issue-332-2.expected.sass create mode 100644 test/options/sort-order-sass/issue-332-2.sass diff --git a/test/options/sort-order-sass/issue-332-2.expected.sass b/test/options/sort-order-sass/issue-332-2.expected.sass new file mode 100644 index 00000000..2c86fb96 --- /dev/null +++ b/test/options/sort-order-sass/issue-332-2.expected.sass @@ -0,0 +1,46 @@ +$contest_color: #ffc33c + +.winners_images_button + display: none +.winners_images + height: 100px + padding-left: 0.6% + padding-right: 0.6% + width: 100% + .winner_cell + float: left + height: 100px + width: 85px + .winner_avatar + background-repeat: no-repeat + background-size: 100% + border: 1px solid lightgray + float: left + height: 75px + width: 85px + .winner_year + color: black + float: left + font-family: bold_mic_font + font-size: 17px + height: 20px + margin-bottom: 5px + text-align: center + width: 85px + span + display: none + .winner_info + display: none + .winner_cell:hover + .winner_year + span + display: block + .tooltip-inner + font-size: 10pt + text-align: justify + h6 + color: white + font-family: bold_mic_font + font-size: 12pt + margin: 0 + text-align: center diff --git a/test/options/sort-order-sass/issue-332-2.sass b/test/options/sort-order-sass/issue-332-2.sass new file mode 100644 index 00000000..d926fa86 --- /dev/null +++ b/test/options/sort-order-sass/issue-332-2.sass @@ -0,0 +1,46 @@ +$contest_color: #ffc33c + +.winners_images_button + display: none +.winners_images + width: 100% + padding-left: 0.6% + padding-right: 0.6% + height: 100px + .winner_cell + width: 85px + height: 100px + float: left + .winner_avatar + width: 85px + height: 75px + border: 1px solid lightgray + float: left + background-repeat: no-repeat + background-size: 100% + .winner_year + margin-bottom: 5px + text-align: center + float: left + width: 85px + height: 20px + font-size: 17px + color: black + font-family: bold_mic_font + span + display: none + .winner_info + display: none + .winner_cell:hover + .winner_year + span + display: block + .tooltip-inner + h6 + text-align: center + margin: 0 + font-family: bold_mic_font + color: white + font-size: 12pt + font-size: 10pt + text-align: justify diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order-sass/test.js index 08007458..6f593544 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order-sass/test.js @@ -104,5 +104,13 @@ describe('options/sort-order (sass)', function() { ] }); return this.shouldBeEqual('issue-332.sass', 'issue-332.expected.sass'); }); + + it('Issue 332, test 2', function() { + this.comb.configure({ + 'sort-order': [['...']], + 'sort-order-fallback': 'abc' + }); + return this.shouldBeEqual('issue-332-2.sass', 'issue-332-2.expected.sass'); + }); }); }); From d9c239bfd9bf706a2e4f36d9f8787e1f8bc87120 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 28 Jun 2015 20:35:01 +0300 Subject: [PATCH 100/184] [tests] Add helper for linter tests --- test/mocha.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/mocha.js b/test/mocha.js index 2744cb7d..54497980 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -31,6 +31,12 @@ function shouldBeEqual(input, expected) { }); } +function getErrors(filename) { + var syntax = filename.split('.').pop(); + var input = readFile.call(this, filename); + return this.comb.lintString(input, { syntax: syntax }); +} + function sortObject(o) { var sorted = {}; var key = []; @@ -72,6 +78,7 @@ mocha.suite.beforeEach(function() { this.readFile = readFile; this.shouldBeEqual = shouldBeEqual; this.shouldDetect = shouldDetect; + this.getErrors = getErrors; }); mocha.run(function(failures) { From f1e24eb2b2bd01c9a6a28dd4e014d28ccb1acea6 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 28 Jun 2015 20:35:57 +0300 Subject: [PATCH 101/184] [lint] Add tests to always-semicolon --- src/options/always-semicolon.js | 2 +- test/options/always-semicolon/lint-1.css | 1 + test/options/always-semicolon/lint-2.css | 1 + test/options/always-semicolon/lint-3.css | 9 ++++++ test/options/always-semicolon/test.js | 35 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/options/always-semicolon/lint-1.css create mode 100644 test/options/always-semicolon/lint-2.css create mode 100644 test/options/always-semicolon/lint-3.css diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index b0a7e1cc..e9c8cfed 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -38,7 +38,7 @@ module.exports = { errors.push({ message: 'Missing semicolon', line: nodeWithoutSemicolon.end.line, - column: nodeWithoutSemicolon.end.column + column: nodeWithoutSemicolon.end.column + 1 }); // Stop looping through block's children: diff --git a/test/options/always-semicolon/lint-1.css b/test/options/always-semicolon/lint-1.css new file mode 100644 index 00000000..0dbee0fe --- /dev/null +++ b/test/options/always-semicolon/lint-1.css @@ -0,0 +1 @@ +div { height: 0; } diff --git a/test/options/always-semicolon/lint-2.css b/test/options/always-semicolon/lint-2.css new file mode 100644 index 00000000..f36f0139 --- /dev/null +++ b/test/options/always-semicolon/lint-2.css @@ -0,0 +1 @@ +div { height: 0 } diff --git a/test/options/always-semicolon/lint-3.css b/test/options/always-semicolon/lint-3.css new file mode 100644 index 00000000..e47a2a9c --- /dev/null +++ b/test/options/always-semicolon/lint-3.css @@ -0,0 +1,9 @@ +div { + height: 0 +} + +@media screen { + .a { + color: tomato; + position: panda} +} diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js index 85046425..8a5e0e21 100644 --- a/test/options/always-semicolon/test.js +++ b/test/options/always-semicolon/test.js @@ -48,6 +48,41 @@ describe('options/always-semicolon', function() { }); }); + describe('lint', function() { + it('Should report no errors', function() { + return this.getErrors('lint-1.css').then(function(errors) { + assert.equal(errors.length, 0); + }); + }); + + it('Error mesage should be a string', function() { + return this.getErrors('lint-2.css').then(function(errors) { + var error = errors[0]; + assert.equal(typeof error.message, 'string'); + }); + }); + + it('Error should provide correct position info', function() { + return this.getErrors('lint-2.css').then(function(errors) { + var error = errors[0]; + assert.equal(error.line, 1); + assert.equal(error.column, 16); + }); + }); + + it('Should report multiple errors', function() { + return this.getErrors('lint-3.css').then(function(errors) { + assert.equal(errors.length, 2); + + assert.equal(errors[0].line, 2); + assert.equal(errors[0].column, 14); + + assert.equal(errors[1].line, 8); + assert.equal(errors[1].column, 24); + }); + }); + }); + describe('detect', function() { it('Should detect semicolon for last property. Test 1', function() { this.shouldDetect( From 30e4c9859d4f6e2f7c168e1115e58a0a6d87c0e7 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 5 Jul 2015 12:55:23 +0300 Subject: [PATCH 102/184] [tools] Do not build unexisting GPE --- scripts/postinstall.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index d4037980..3c932c0f 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -1,2 +1 @@ -cd ./node_modules/gonzales-pe && npm i && npm run build && cd - cd ./node_modules/csscomb-core && npm i && npm run build && cd - From 08e66099a4f3fdb951eeff667112c8a44afdf447 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 5 Jul 2015 13:12:51 +0300 Subject: [PATCH 103/184] [options] Add test for #399 --- .../sort-order-scss/issue-399.expected.scss | 14 ++++++++++++++ test/options/sort-order-scss/issue-399.scss | 15 +++++++++++++++ test/options/sort-order-scss/test.js | 5 +++++ 3 files changed, 34 insertions(+) create mode 100644 test/options/sort-order-scss/issue-399.expected.scss create mode 100644 test/options/sort-order-scss/issue-399.scss diff --git a/test/options/sort-order-scss/issue-399.expected.scss b/test/options/sort-order-scss/issue-399.expected.scss new file mode 100644 index 00000000..bf69f21b --- /dev/null +++ b/test/options/sort-order-scss/issue-399.expected.scss @@ -0,0 +1,14 @@ +.block { + @extend .hey; + @extend %ho; + color: black; + + @include media("lap") { + color: green; + } + @include media("palm") { + color: red; + } + @include last; + @include hide-text; +} diff --git a/test/options/sort-order-scss/issue-399.scss b/test/options/sort-order-scss/issue-399.scss new file mode 100644 index 00000000..7e090c81 --- /dev/null +++ b/test/options/sort-order-scss/issue-399.scss @@ -0,0 +1,15 @@ +.block { + color: black; + + @extend .hey; + @extend %ho; + + @include media("lap") { + color: green; + } + @include media("palm") { + color: red; + } + @include last; + @include hide-text; +} diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order-scss/test.js index 8cdb0f75..b5a31487 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order-scss/test.js @@ -127,5 +127,10 @@ describe('options/sort-order (scss)', function() { this.comb.configure({ 'sort-order': ['...'] }); return this.shouldBeEqual('issue-333.scss'); }); + + it.skip('Issue 399', function() { + this.comb.configure({ "sort-order": [["$extend", "color"]]}); + return this.shouldBeEqual('issue-399.expected.scss'); + }); }); }); From 564e3a9140f48420fdf86a54bec4b493f5d6c553 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 19 Aug 2015 18:56:06 +0300 Subject: [PATCH 104/184] [tests] Refactor tests --- package.json | 1 + scripts/test.sh | 2 +- test/core/configure/test.js | 97 +++++----- test/core/get-config/test.js | 2 +- test/core/less/test.js | 2 +- test/core/scss/test.js | 2 +- test/core/use/test.js | 2 +- test/mocha.js | 87 ++------- test/options/always-semicolon-less/test.js | 55 ------ test/options/always-semicolon-sass/test.js | 11 -- test/options/always-semicolon-scss/test.js | 63 ------- .../always-semicolon/detect/css/test-1.css | 0 .../detect/css/test-1.expected.css | 0 .../always-semicolon/detect/css/test-2.css | 0 .../detect/css/test-2.expected.css | 0 .../always-semicolon/detect/css/test-3.css | 0 .../detect/css/test-3.expected.css | 0 .../always-semicolon/detect/css/test-4.css | 0 .../detect/css/test-4.expected.css | 0 .../always-semicolon/detect/css/test-5.css | 0 .../detect/css/test-5.expected.css | 0 .../always-semicolon/detect/css/test-6.css | 0 .../detect/css/test-6.expected.css | 0 .../always-semicolon/detect/css/test-7.css | 0 .../detect/css/test-7.expected.css | 0 test/options/always-semicolon/detect/test.js | 63 +++++++ .../{ => lint/css}/lint-1.css | 0 .../{ => lint/css}/lint-2.css | 0 .../{ => lint/css}/lint-3.css | 0 test/options/always-semicolon/lint/test.js | 43 +++++ .../always-semicolon/process/css/test-1.css | 1 + .../process/css/test-1.expected.css | 1 + .../always-semicolon/process/css/test-2.css | 3 + .../process/css/test-2.expected.css | 3 + .../always-semicolon/process/css/test-3.css | 1 + .../process/css/test-3.expected.css | 1 + .../always-semicolon/process/css/test-4.css | 3 + .../process/css/test-4.expected.css | 3 + .../always-semicolon/process/css/test-5.css | 4 + .../process/css/test-5.expected.css | 4 + .../process/less}/condition-multiline.less | 0 .../process/less}/condition.less | 0 .../less}/include-1-multiline.expected.less | 0 .../process/less}/include-1-multiline.less | 0 .../process/less}/include-1.expected.less | 0 .../process/less}/include-1.less | 0 .../less}/include-2-multiline.expected.less | 0 .../process/less}/include-2-multiline.less | 0 .../process/less}/include-2.expected.less | 0 .../process/less}/include-2.less | 0 .../less}/include-3-multiline.expected.less | 0 .../process/less}/include-3-multiline.less | 0 .../process/less}/include-3.expected.less | 0 .../process/less}/include-3.less | 0 .../less}/include-4-multiline.expected.less | 0 .../process/less}/include-4-multiline.less | 0 .../process/less}/include-4.expected.less | 0 .../process/less}/include-4.less | 0 .../less}/include-5-multiline.expected.less | 0 .../process/less}/include-5-multiline.less | 0 .../process/less}/include-5.expected.less | 0 .../process/less}/include-5.less | 0 .../process/sass}/test.sass | 0 .../scss}/block-include-multiline.scss | 0 .../process/scss}/block-include.scss | 0 .../process/scss}/block-value-multiline.scss | 0 .../process/scss}/block-value.scss | 0 .../process/scss}/condition-multiline.scss | 0 .../process/scss}/condition.scss | 0 .../scss}/extend-multiline.expected.scss | 0 .../process/scss}/extend-multiline.scss | 0 .../process/scss}/extend.expected.scss | 0 .../process/scss}/extend.scss | 0 .../scss}/include-1-multiline.expected.scss | 0 .../process/scss}/include-1-multiline.scss | 0 .../process/scss}/include-1.expected.scss | 0 .../process/scss}/include-1.scss | 0 .../scss}/include-2-multiline.expected.scss | 0 .../process/scss}/include-2-multiline.scss | 0 .../process/scss}/include-2.expected.scss | 0 .../process/scss}/include-2.scss | 0 .../process/scss}/loop-multiline.scss | 0 .../process/scss}/loop.scss | 0 test/options/always-semicolon/process/test.js | 169 ++++++++++++++++++ test/options/always-semicolon/test.js | 158 ---------------- .../{ => process/css}/issue-379.css | 0 .../{ => process/css}/issue-379.expected.css | 0 .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../block-indent/{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../process/sass}/block.expected.sass | 0 .../process/sass}/block.sass | 0 .../process/sass}/mixin.expected.sass | 0 .../process/sass}/mixin.sass | 0 .../sass}/nested-ruleset.expected.sass | 0 .../process/sass}/nested-ruleset.sass | 0 .../process/sass}/test.js | 2 +- .../scss}/nested-include.expected.scss | 0 .../process/scss}/nested-include.scss | 0 .../process/scss}/test.js | 2 +- .../block-indent/{ => process}/test.js | 2 +- test/options/color-case/{ => process}/test.js | 2 +- .../color-shorthand/{ => process}/test.js | 2 +- .../process/scss}/mixin.expected.scss | 0 .../process/scss}/mixin.scss | 0 .../process/scss}/test.js | 2 +- .../element-case/{ => process}/test.js | 2 +- .../options/eof-newline/{ => process}/test.js | 2 +- .../integral/{ => process/css}/integral.css | 0 .../{ => process/css}/integral.expected.css | 0 .../{ => process/css}/issue-252.expected.sass | 0 .../integral/{ => process/css}/issue-252.sass | 0 .../integral/{ => process/css}/issue-374.css | 0 test/options/integral/{ => process}/test.js | 2 +- .../leading-zero/{ => process}/test.js | 2 +- test/options/quotes/{ => process}/test.js | 2 +- .../process/less}/1.expected.less | 0 .../process/less}/1.less | 0 .../process/less}/test.js | 2 +- .../scss}/empty-nested-rule.expected.scss | 0 .../process/scss}/empty-nested-rule.scss | 0 .../process/scss}/include.scss | 0 .../process/scss}/nested-rule-1.scss | 0 .../process/scss}/nested-rule-2.expected.scss | 0 .../process/scss}/nested-rule-2.scss | 0 .../process/scss}/test.js | 2 +- .../{ => process}/test.js | 2 +- test/options/sass/content.sass | 3 - test/options/sass/default.sass | 3 - test/options/sass/each.sass | 4 - test/options/sass/extend-1.sass | 3 - test/options/sass/extend-2.sass | 3 - test/options/sass/for.sass | 4 - test/options/sass/function.sass | 2 - test/options/sass/if-else-if.sass | 5 - test/options/sass/if-else.sass | 5 - test/options/sass/if.sass | 3 - test/options/sass/import.sass | 3 - test/options/sass/include.sass | 3 - .../options/sass/interpolated-variable-1.sass | 3 - .../options/sass/interpolated-variable-2.sass | 3 - test/options/sass/mixin-1.sass | 4 - test/options/sass/mixin-2.sass | 4 - test/options/sass/mixin-3.sass | 4 - test/options/sass/mixin-4.sass | 4 - test/options/sass/nested-media.sass | 4 - test/options/sass/nested-property.sass | 6 - test/options/sass/nested-rule.sass | 4 - test/options/sass/parent-selector.sass | 6 - test/options/sass/test.js | 109 ----------- test/options/sass/variable.sass | 3 - test/options/sass/warn.sass | 3 - test/options/sass/while.sass | 5 - .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../sort-order-fallback/{ => process}/test.js | 2 +- .../sort-order/{ => process/css}/data-uri.css | 0 .../{ => process/css}/data-uri.expected.css | 0 .../{ => process/css}/issue-94-1.css | 0 .../{ => process/css}/issue-94-1.expected.css | 0 .../{ => process/css}/issue-94-2.css | 0 .../{ => process/css}/issue-94-2.expected.css | 0 .../{ => process/css}/issue-94-3.css | 0 .../{ => process/css}/issue-94-3.expected.css | 0 .../{ => process/css}/leftovers-1.css | 0 .../css}/leftovers-1.expected.css | 0 .../{ => process/css}/leftovers-2.css | 0 .../css}/leftovers-2.expected.css | 0 .../{ => process/css}/leftovers-3.css | 0 .../css}/leftovers-3.expected.css | 0 .../{ => process/css}/leftovers-4.css | 0 .../css}/leftovers-4.expected.css | 0 .../{ => process/css}/missing-delimiter.css | 0 .../css}/missing-delimiter.expected.css | 0 .../{ => process/css}/multiple-groups-2.css | 0 .../css}/multiple-groups-2.expected.css | 0 .../css}/multiple-groups-comments.css | 0 .../multiple-groups-comments.expected.css | 0 .../{ => process/css}/multiple-groups.css | 0 .../css}/multiple-groups.expected.css | 0 .../css}/single-group-comments.css | 0 .../css}/single-group-comments.expected.css | 0 .../{ => process/css}/single-group.css | 0 .../css}/single-group.expected.css | 0 .../process/less}/comments-1.expected.less | 0 .../process/less}/comments-1.less | 0 .../process/less}/comments-2.expected.less | 0 .../process/less}/comments-2.less | 0 .../process/less}/comments-3.expected.less | 0 .../process/less}/comments-3.less | 0 .../process/less}/comments-4.expected.less | 0 .../process/less}/comments-4.less | 0 .../less}/different-groups.expected.less | 0 .../process/less}/different-groups.less | 0 .../process/less}/extend.expected.less | 0 .../process/less}/extend.less | 0 .../process/less}/import.expected.less | 0 .../process/less}/import.less | 0 .../process/less}/mixin-1.expected.less | 0 .../process/less}/mixin-1.less | 0 .../process/less}/mixin-2.expected.less | 0 .../process/less}/mixin-2.less | 0 .../process/less}/mixin-3.expected.less | 0 .../process/less}/mixin-3.less | 0 .../process/less}/mixin-4.expected.less | 0 .../process/less}/mixin-4.less | 0 .../process/less}/nested-rule-1.expected.less | 0 .../process/less}/nested-rule-1.less | 0 .../process/less}/nested-rule-2.expected.less | 0 .../process/less}/nested-rule-2.less | 0 .../process/less}/rule.expected.less | 0 .../process/less}/rule.less | 0 .../process/less}/test.js | 2 +- .../process/less}/variable.expected.less | 0 .../process/less}/variable.less | 0 .../process/sass}/comments.expected.sass | 0 .../process/sass}/comments.sass | 0 .../process/sass}/condition.expected.sass | 0 .../process/sass}/condition.sass | 0 .../sass}/different-groups.expected.sass | 0 .../process/sass}/different-groups.sass | 0 .../process/sass}/extend.expected.sass | 0 .../process/sass}/extend.sass | 0 .../process/sass}/import.expected.sass | 0 .../process/sass}/import.sass | 0 .../sass}/include-specified-1.expected.sass | 0 .../process/sass}/include-specified-1.sass | 0 .../sass}/include-specified-2.expected.sass | 0 .../process/sass}/include-specified-2.sass | 0 .../process/sass}/include.expected.sass | 0 .../process/sass}/include.sass | 0 .../process/sass}/issue-332-2.expected.sass | 0 .../process/sass}/issue-332-2.sass | 0 .../process/sass}/issue-332.expected.sass | 0 .../process/sass}/issue-332.sass | 0 .../process/sass}/mixin.expected.sass | 0 .../process/sass}/mixin.sass | 0 .../process/sass}/nested-rule-1.expected.sass | 0 .../process/sass}/nested-rule-1.sass | 0 .../process/sass}/nested-rule-2.expected.sass | 0 .../process/sass}/nested-rule-2.sass | 0 .../process/sass}/rule.expected.sass | 0 .../process/sass}/rule.sass | 0 .../process/sass}/ruleset.expected.sass | 0 .../process/sass}/ruleset.sass | 0 .../process/sass}/test.js | 2 +- .../process/sass}/variable.expected.sass | 0 .../process/sass}/variable.sass | 0 .../process/scss}/comments-1.expected.scss | 0 .../process/scss}/comments-1.scss | 0 .../process/scss}/comments-2.expected.scss | 0 .../process/scss}/comments-2.scss | 0 .../process/scss}/condition.expected.scss | 0 .../process/scss}/condition.scss | 0 .../scss}/different-groups.expected.scss | 0 .../process/scss}/different-groups.scss | 0 .../process/scss}/extend.expected.scss | 0 .../process/scss}/extend.scss | 0 .../process/scss}/import.expected.scss | 0 .../process/scss}/import.scss | 0 .../scss}/include-specified.expected.scss | 0 .../process/scss}/include-specified.scss | 0 .../process/scss}/include.expected.scss | 0 .../process/scss}/include.scss | 0 .../process/scss}/issue-317.scss | 0 .../process/scss}/issue-333.scss | 0 .../process/scss}/issue-399.expected.scss | 0 .../process/scss}/issue-399.scss | 0 .../process/scss}/leftovers.expected.scss | 0 .../process/scss}/leftovers.scss | 0 .../process/scss}/mixin.expected.scss | 0 .../process/scss}/mixin.scss | 0 .../process/scss}/nested-rule-1.expected.scss | 0 .../process/scss}/nested-rule-1.scss | 0 .../process/scss}/nested-rule-2.expected.scss | 0 .../process/scss}/nested-rule-2.scss | 0 .../scss}/rule-multiline.expected.scss | 0 .../process/scss}/rule-multiline.scss | 0 .../process/scss}/rule.expected.scss | 0 .../process/scss}/rule.scss | 0 .../process/scss}/ruleset.expected.scss | 0 .../process/scss}/ruleset.scss | 0 .../process/scss}/test.js | 2 +- .../process/scss}/variable.expected.scss | 0 .../process/scss}/variable.scss | 0 test/options/sort-order/{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../colon-after-property-name.expected.sass | 0 .../sass}/colon-after-property-name.sass | 0 .../colon-before-property-name.expected.sass | 0 .../sass}/colon-before-property-name.sass | 0 .../process/sass}/test.js | 2 +- .../scss}/pseudo-elements.expected.scss | 0 .../process/scss}/pseudo-elements.scss | 0 .../process/scss}/test.js | 2 +- .../space-after-colon/{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../{ => process}/test.js | 2 +- .../{ => process/css}/issue-387.css | 0 .../{ => process/css}/issue-387.expected.css | 0 .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../process/sass}/issue-238.expected.sass | 0 .../process/sass}/issue-238.sass | 0 .../process/sass}/test.js | 2 +- .../{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../process/sass}/test.expected.sass | 0 .../process/sass}/test.js | 0 .../process/sass}/test.sass | 0 .../process/sass}/test2.sass | 0 .../space-before-colon/{ => process}/test.js | 2 +- .../{ => process/css}/issue-381.css | 0 .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../{ => process}/test.js | 2 +- .../{ => process/css}/issue-232.css | 0 .../{ => process/css}/issue-232.expected.css | 0 .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../process/scss}/issue-231.expected.scss | 0 .../process/scss}/issue-231.scss | 0 .../process/scss}/issue-319.expected.scss | 0 .../process/scss}/issue-319.scss | 0 .../process/scss}/test.js | 2 +- .../{ => process}/test.js | 2 +- .../{ => process/css}/test-2.expected.css | 0 .../{ => process/css}/test-3.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 .../{ => process}/test.js | 2 +- .../{ => process/css}/comments.css | 0 .../{ => process/css}/comments.expected.css | 0 .../{ => process/css}/integer-value.css | 0 .../css}/integer-value.expected.css | 0 .../{ => process/css}/issue-239.css | 0 .../{ => process/css}/issue-239.expected.css | 0 .../{ => process/css}/issue-378.css | 0 .../{ => process/css}/space-newline-value.css | 0 .../css}/space-newline-value.expected.css | 0 .../{ => process/css}/space-value.css | 0 .../css}/space-value.expected.css | 0 .../{ => process/css}/test.css | 0 .../{ => process}/test.js | 2 +- .../strip-spaces/{ => process}/test.js | 2 +- .../tab-size/{ => process/css}/test.css | 0 .../{ => process/css}/test.expected.css | 0 test/options/tab-size/{ => process}/test.js | 2 +- .../unitless-zero/{ => process}/test.js | 2 +- .../{ => process/css}/already-aligned.css | 0 .../css}/already-aligned.expected.css | 0 .../{ => process/css}/both.css | 0 .../{ => process/css}/both.expected.css | 0 .../{ => process/css}/complex.css | 0 .../{ => process/css}/complex.expected.css | 0 .../{ => process/css}/issue-193.css | 0 .../{ => process/css}/issue-193.expected.css | 0 .../{ => process/css}/issue-241.css | 0 .../{ => process/css}/issue-241.expected.css | 0 .../{ => process/css}/multiline-comments.css | 0 .../css}/multiline-comments.expected.css | 0 .../{ => process/css}/one-line-2.css | 0 .../{ => process/css}/one-line-2.expected.css | 0 .../{ => process/css}/one-line.css | 0 .../{ => process/css}/one-line.expected.css | 0 .../{ => process/css}/property-align.css | 0 .../css}/property-align.expected.css | 0 .../{ => process/css}/same-name.css | 0 .../{ => process/css}/same-name.expected.css | 0 .../{ => process/css}/value-align.css | 0 .../css}/value-align.expected.css | 0 .../css}/with-comment-property-2.css | 0 .../css}/with-comment-property-2.expected.css | 0 .../css}/with-comment-property.css | 0 .../css}/with-comment-property.expected.css | 0 .../{ => process/css}/with-comment.css | 0 .../css}/with-comment.expected.css | 0 .../{ => process/css}/without-space.css | 0 .../css}/without-space.expected.css | 0 .../process/sass}/property.sass | 0 .../process/sass}/test.js | 2 +- .../process/sass}/value.expected.sass | 0 .../process/sass}/value.sass | 0 .../vendor-prefix-align/{ => process}/test.js | 2 +- test/test_helpers.js | 64 +++++++ 413 files changed, 469 insertions(+), 655 deletions(-) delete mode 100644 test/options/always-semicolon-less/test.js delete mode 100644 test/options/always-semicolon-sass/test.js delete mode 100644 test/options/always-semicolon-scss/test.js create mode 100644 test/options/always-semicolon/detect/css/test-1.css create mode 100644 test/options/always-semicolon/detect/css/test-1.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-2.css create mode 100644 test/options/always-semicolon/detect/css/test-2.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-3.css create mode 100644 test/options/always-semicolon/detect/css/test-3.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-4.css create mode 100644 test/options/always-semicolon/detect/css/test-4.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-5.css create mode 100644 test/options/always-semicolon/detect/css/test-5.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-6.css create mode 100644 test/options/always-semicolon/detect/css/test-6.expected.css create mode 100644 test/options/always-semicolon/detect/css/test-7.css create mode 100644 test/options/always-semicolon/detect/css/test-7.expected.css create mode 100644 test/options/always-semicolon/detect/test.js rename test/options/always-semicolon/{ => lint/css}/lint-1.css (100%) rename test/options/always-semicolon/{ => lint/css}/lint-2.css (100%) rename test/options/always-semicolon/{ => lint/css}/lint-3.css (100%) create mode 100644 test/options/always-semicolon/lint/test.js create mode 100644 test/options/always-semicolon/process/css/test-1.css create mode 100644 test/options/always-semicolon/process/css/test-1.expected.css create mode 100644 test/options/always-semicolon/process/css/test-2.css create mode 100644 test/options/always-semicolon/process/css/test-2.expected.css create mode 100644 test/options/always-semicolon/process/css/test-3.css create mode 100644 test/options/always-semicolon/process/css/test-3.expected.css create mode 100644 test/options/always-semicolon/process/css/test-4.css create mode 100644 test/options/always-semicolon/process/css/test-4.expected.css create mode 100644 test/options/always-semicolon/process/css/test-5.css create mode 100644 test/options/always-semicolon/process/css/test-5.expected.css rename test/options/{always-semicolon-less => always-semicolon/process/less}/condition-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/condition.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-1-multiline.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-1-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-1.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-1.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-2-multiline.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-2-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-2.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-2.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-3-multiline.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-3-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-3.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-3.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-4-multiline.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-4-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-4.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-4.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-5-multiline.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-5-multiline.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-5.expected.less (100%) rename test/options/{always-semicolon-less => always-semicolon/process/less}/include-5.less (100%) rename test/options/{always-semicolon-sass => always-semicolon/process/sass}/test.sass (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/block-include-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/block-include.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/block-value-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/block-value.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/condition-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/condition.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/extend-multiline.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/extend-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/extend.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/extend.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-1-multiline.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-1-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-1.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-1.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-2-multiline.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-2-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-2.expected.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/include-2.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/loop-multiline.scss (100%) rename test/options/{always-semicolon-scss => always-semicolon/process/scss}/loop.scss (100%) create mode 100644 test/options/always-semicolon/process/test.js delete mode 100644 test/options/always-semicolon/test.js rename test/options/block-indent/{ => process/css}/issue-379.css (100%) rename test/options/block-indent/{ => process/css}/issue-379.expected.css (100%) rename test/options/block-indent/{ => process/css}/test-2.expected.css (100%) rename test/options/block-indent/{ => process/css}/test-3.expected.css (100%) rename test/options/block-indent/{ => process/css}/test.css (100%) rename test/options/block-indent/{ => process/css}/test.expected.css (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/block.expected.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/block.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/mixin.expected.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/mixin.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/nested-ruleset.expected.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/nested-ruleset.sass (100%) rename test/options/{block-indent-sass => block-indent/process/sass}/test.js (91%) rename test/options/{block-indent-scss => block-indent/process/scss}/nested-include.expected.scss (100%) rename test/options/{block-indent-scss => block-indent/process/scss}/nested-include.scss (100%) rename test/options/{block-indent-scss => block-indent/process/scss}/test.js (80%) rename test/options/block-indent/{ => process}/test.js (97%) rename test/options/color-case/{ => process}/test.js (98%) rename test/options/color-shorthand/{ => process}/test.js (97%) rename test/options/{element-case-scss => element-case/process/scss}/mixin.expected.scss (100%) rename test/options/{element-case-scss => element-case/process/scss}/mixin.scss (100%) rename test/options/{element-case-scss => element-case/process/scss}/test.js (81%) rename test/options/element-case/{ => process}/test.js (98%) rename test/options/eof-newline/{ => process}/test.js (97%) rename test/options/integral/{ => process/css}/integral.css (100%) rename test/options/integral/{ => process/css}/integral.expected.css (100%) rename test/options/integral/{ => process/css}/issue-252.expected.sass (100%) rename test/options/integral/{ => process/css}/issue-252.sass (100%) rename test/options/integral/{ => process/css}/issue-374.css (100%) rename test/options/integral/{ => process}/test.js (96%) rename test/options/leading-zero/{ => process}/test.js (96%) rename test/options/quotes/{ => process}/test.js (98%) rename test/options/{remove-empty-rulesets-less => remove-empty-rulesets/process/less}/1.expected.less (100%) rename test/options/{remove-empty-rulesets-less => remove-empty-rulesets/process/less}/1.less (100%) rename test/options/{remove-empty-rulesets-less => remove-empty-rulesets/process/less}/test.js (93%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/empty-nested-rule.expected.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/empty-nested-rule.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/include.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/nested-rule-1.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/nested-rule-2.expected.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/nested-rule-2.scss (100%) rename test/options/{remove-empty-rulesets-scss => remove-empty-rulesets/process/scss}/test.js (92%) rename test/options/remove-empty-rulesets/{ => process}/test.js (98%) delete mode 100644 test/options/sass/content.sass delete mode 100644 test/options/sass/default.sass delete mode 100644 test/options/sass/each.sass delete mode 100644 test/options/sass/extend-1.sass delete mode 100644 test/options/sass/extend-2.sass delete mode 100644 test/options/sass/for.sass delete mode 100644 test/options/sass/function.sass delete mode 100644 test/options/sass/if-else-if.sass delete mode 100644 test/options/sass/if-else.sass delete mode 100644 test/options/sass/if.sass delete mode 100644 test/options/sass/import.sass delete mode 100644 test/options/sass/include.sass delete mode 100644 test/options/sass/interpolated-variable-1.sass delete mode 100644 test/options/sass/interpolated-variable-2.sass delete mode 100644 test/options/sass/mixin-1.sass delete mode 100644 test/options/sass/mixin-2.sass delete mode 100644 test/options/sass/mixin-3.sass delete mode 100644 test/options/sass/mixin-4.sass delete mode 100644 test/options/sass/nested-media.sass delete mode 100644 test/options/sass/nested-property.sass delete mode 100644 test/options/sass/nested-rule.sass delete mode 100644 test/options/sass/parent-selector.sass delete mode 100644 test/options/sass/test.js delete mode 100644 test/options/sass/variable.sass delete mode 100644 test/options/sass/warn.sass delete mode 100644 test/options/sass/while.sass rename test/options/sort-order-fallback/{ => process/css}/test-2.expected.css (100%) rename test/options/sort-order-fallback/{ => process/css}/test-3.expected.css (100%) rename test/options/sort-order-fallback/{ => process/css}/test.css (100%) rename test/options/sort-order-fallback/{ => process/css}/test.expected.css (100%) rename test/options/sort-order-fallback/{ => process}/test.js (95%) rename test/options/sort-order/{ => process/css}/data-uri.css (100%) rename test/options/sort-order/{ => process/css}/data-uri.expected.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-1.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-1.expected.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-2.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-2.expected.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-3.css (100%) rename test/options/sort-order/{ => process/css}/issue-94-3.expected.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-1.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-1.expected.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-2.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-2.expected.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-3.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-3.expected.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-4.css (100%) rename test/options/sort-order/{ => process/css}/leftovers-4.expected.css (100%) rename test/options/sort-order/{ => process/css}/missing-delimiter.css (100%) rename test/options/sort-order/{ => process/css}/missing-delimiter.expected.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups-2.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups-2.expected.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups-comments.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups-comments.expected.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups.css (100%) rename test/options/sort-order/{ => process/css}/multiple-groups.expected.css (100%) rename test/options/sort-order/{ => process/css}/single-group-comments.css (100%) rename test/options/sort-order/{ => process/css}/single-group-comments.expected.css (100%) rename test/options/sort-order/{ => process/css}/single-group.css (100%) rename test/options/sort-order/{ => process/css}/single-group.expected.css (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-1.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-1.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-2.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-2.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-3.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-3.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-4.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/comments-4.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/different-groups.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/different-groups.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/extend.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/extend.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/import.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/import.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-1.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-1.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-2.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-2.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-3.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-3.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-4.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/mixin-4.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/nested-rule-1.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/nested-rule-1.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/nested-rule-2.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/nested-rule-2.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/rule.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/rule.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/test.js (98%) rename test/options/{sort-order-less => sort-order/process/less}/variable.expected.less (100%) rename test/options/{sort-order-less => sort-order/process/less}/variable.less (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/comments.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/comments.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/condition.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/condition.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/different-groups.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/different-groups.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/extend.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/extend.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/import.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/import.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include-specified-1.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include-specified-1.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include-specified-2.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include-specified-2.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/include.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/issue-332-2.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/issue-332-2.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/issue-332.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/issue-332.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/mixin.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/mixin.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/nested-rule-1.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/nested-rule-1.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/nested-rule-2.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/nested-rule-2.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/rule.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/rule.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/ruleset.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/ruleset.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/test.js (98%) rename test/options/{sort-order-sass => sort-order/process/sass}/variable.expected.sass (100%) rename test/options/{sort-order-sass => sort-order/process/sass}/variable.sass (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/comments-1.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/comments-1.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/comments-2.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/comments-2.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/condition.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/condition.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/different-groups.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/different-groups.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/extend.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/extend.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/import.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/import.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/include-specified.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/include-specified.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/include.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/include.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/issue-317.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/issue-333.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/issue-399.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/issue-399.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/leftovers.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/leftovers.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/mixin.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/mixin.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/nested-rule-1.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/nested-rule-1.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/nested-rule-2.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/nested-rule-2.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/rule-multiline.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/rule-multiline.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/rule.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/rule.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/ruleset.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/ruleset.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/test.js (98%) rename test/options/{sort-order-scss => sort-order/process/scss}/variable.expected.scss (100%) rename test/options/{sort-order-scss => sort-order/process/scss}/variable.scss (100%) rename test/options/sort-order/{ => process}/test.js (99%) rename test/options/space-after-colon/{ => process/css}/test-2.expected.css (100%) rename test/options/space-after-colon/{ => process/css}/test-3.expected.css (100%) rename test/options/space-after-colon/{ => process/css}/test.css (100%) rename test/options/space-after-colon/{ => process/css}/test.expected.css (100%) rename test/options/{space-after-colon-sass => space-after-colon/process/sass}/colon-after-property-name.expected.sass (100%) rename test/options/{space-after-colon-sass => space-after-colon/process/sass}/colon-after-property-name.sass (100%) rename test/options/{space-after-colon-sass => space-after-colon/process/sass}/colon-before-property-name.expected.sass (100%) rename test/options/{space-after-colon-sass => space-after-colon/process/sass}/colon-before-property-name.sass (100%) rename test/options/{space-after-colon-sass => space-after-colon/process/sass}/test.js (90%) rename test/options/{space-after-colon-scss => space-after-colon/process/scss}/pseudo-elements.expected.scss (100%) rename test/options/{space-after-colon-scss => space-after-colon/process/scss}/pseudo-elements.scss (100%) rename test/options/{space-after-colon-scss => space-after-colon/process/scss}/test.js (82%) rename test/options/space-after-colon/{ => process}/test.js (97%) rename test/options/space-after-combinator/{ => process/css}/test-2.expected.css (100%) rename test/options/space-after-combinator/{ => process/css}/test-3.expected.css (100%) rename test/options/space-after-combinator/{ => process/css}/test.css (100%) rename test/options/space-after-combinator/{ => process/css}/test.expected.css (100%) rename test/options/space-after-combinator/{ => process}/test.js (98%) rename test/options/space-after-opening-brace/{ => process/css}/issue-387.css (100%) rename test/options/space-after-opening-brace/{ => process/css}/issue-387.expected.css (100%) rename test/options/space-after-opening-brace/{ => process/css}/test-2.expected.css (100%) rename test/options/space-after-opening-brace/{ => process/css}/test-3.expected.css (100%) rename test/options/space-after-opening-brace/{ => process/css}/test.css (100%) rename test/options/space-after-opening-brace/{ => process/css}/test.expected.css (100%) rename test/options/space-after-opening-brace/{ => process}/test.js (98%) rename test/options/space-after-selector-delimiter/{ => process/css}/test-2.expected.css (100%) rename test/options/space-after-selector-delimiter/{ => process/css}/test-3.expected.css (100%) rename test/options/space-after-selector-delimiter/{ => process/css}/test.css (100%) rename test/options/space-after-selector-delimiter/{ => process/css}/test.expected.css (100%) rename test/options/{space-after-selector-delimiter-sass => space-after-selector-delimiter/process/sass}/issue-238.expected.sass (100%) rename test/options/{space-after-selector-delimiter-sass => space-after-selector-delimiter/process/sass}/issue-238.sass (100%) rename test/options/{space-after-selector-delimiter-sass => space-after-selector-delimiter/process/sass}/test.js (77%) rename test/options/space-after-selector-delimiter/{ => process}/test.js (97%) rename test/options/space-before-closing-brace/{ => process/css}/test-2.expected.css (100%) rename test/options/space-before-closing-brace/{ => process/css}/test-3.expected.css (100%) rename test/options/space-before-closing-brace/{ => process/css}/test.css (100%) rename test/options/space-before-closing-brace/{ => process/css}/test.expected.css (100%) rename test/options/space-before-closing-brace/{ => process}/test.js (97%) rename test/options/space-before-colon/{ => process/css}/test-2.expected.css (100%) rename test/options/space-before-colon/{ => process/css}/test-3.expected.css (100%) rename test/options/space-before-colon/{ => process/css}/test.css (100%) rename test/options/space-before-colon/{ => process/css}/test.expected.css (100%) rename test/options/{space-before-colon-sass => space-before-colon/process/sass}/test.expected.sass (100%) rename test/options/{space-before-colon-sass => space-before-colon/process/sass}/test.js (100%) rename test/options/{space-before-colon-sass => space-before-colon/process/sass}/test.sass (100%) rename test/options/{space-before-colon-sass => space-before-colon/process/sass}/test2.sass (100%) rename test/options/space-before-colon/{ => process}/test.js (97%) rename test/options/space-before-combinator/{ => process/css}/issue-381.css (100%) rename test/options/space-before-combinator/{ => process/css}/test-2.expected.css (100%) rename test/options/space-before-combinator/{ => process/css}/test-3.expected.css (100%) rename test/options/space-before-combinator/{ => process/css}/test.css (100%) rename test/options/space-before-combinator/{ => process/css}/test.expected.css (100%) rename test/options/space-before-combinator/{ => process}/test.js (98%) rename test/options/space-before-opening-brace/{ => process/css}/issue-232.css (100%) rename test/options/space-before-opening-brace/{ => process/css}/issue-232.expected.css (100%) rename test/options/space-before-opening-brace/{ => process/css}/test-2.expected.css (100%) rename test/options/space-before-opening-brace/{ => process/css}/test-3.expected.css (100%) rename test/options/space-before-opening-brace/{ => process/css}/test.css (100%) rename test/options/space-before-opening-brace/{ => process/css}/test.expected.css (100%) rename test/options/{space-before-opening-brace-scss => space-before-opening-brace/process/scss}/issue-231.expected.scss (100%) rename test/options/{space-before-opening-brace-scss => space-before-opening-brace/process/scss}/issue-231.scss (100%) rename test/options/{space-before-opening-brace-scss => space-before-opening-brace/process/scss}/issue-319.expected.scss (100%) rename test/options/{space-before-opening-brace-scss => space-before-opening-brace/process/scss}/issue-319.scss (100%) rename test/options/{space-before-opening-brace-scss => space-before-opening-brace/process/scss}/test.js (86%) rename test/options/space-before-opening-brace/{ => process}/test.js (98%) rename test/options/space-before-selector-delimiter/{ => process/css}/test-2.expected.css (100%) rename test/options/space-before-selector-delimiter/{ => process/css}/test-3.expected.css (100%) rename test/options/space-before-selector-delimiter/{ => process/css}/test.css (100%) rename test/options/space-before-selector-delimiter/{ => process/css}/test.expected.css (100%) rename test/options/space-before-selector-delimiter/{ => process}/test.js (97%) rename test/options/space-between-declarations/{ => process/css}/comments.css (100%) rename test/options/space-between-declarations/{ => process/css}/comments.expected.css (100%) rename test/options/space-between-declarations/{ => process/css}/integer-value.css (100%) rename test/options/space-between-declarations/{ => process/css}/integer-value.expected.css (100%) rename test/options/space-between-declarations/{ => process/css}/issue-239.css (100%) rename test/options/space-between-declarations/{ => process/css}/issue-239.expected.css (100%) rename test/options/space-between-declarations/{ => process/css}/issue-378.css (100%) rename test/options/space-between-declarations/{ => process/css}/space-newline-value.css (100%) rename test/options/space-between-declarations/{ => process/css}/space-newline-value.expected.css (100%) rename test/options/space-between-declarations/{ => process/css}/space-value.css (100%) rename test/options/space-between-declarations/{ => process/css}/space-value.expected.css (100%) rename test/options/space-between-declarations/{ => process/css}/test.css (100%) rename test/options/space-between-declarations/{ => process}/test.js (97%) rename test/options/strip-spaces/{ => process}/test.js (98%) rename test/options/tab-size/{ => process/css}/test.css (100%) rename test/options/tab-size/{ => process/css}/test.expected.css (100%) rename test/options/tab-size/{ => process}/test.js (93%) rename test/options/unitless-zero/{ => process}/test.js (98%) rename test/options/vendor-prefix-align/{ => process/css}/already-aligned.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/already-aligned.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/both.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/both.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/complex.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/complex.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/issue-193.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/issue-193.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/issue-241.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/issue-241.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/multiline-comments.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/multiline-comments.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/one-line-2.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/one-line-2.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/one-line.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/one-line.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/property-align.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/property-align.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/same-name.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/same-name.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/value-align.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/value-align.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment-property-2.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment-property-2.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment-property.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment-property.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/with-comment.expected.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/without-space.css (100%) rename test/options/vendor-prefix-align/{ => process/css}/without-space.expected.css (100%) rename test/options/{vendor-prefix-align-sass => vendor-prefix-align/process/sass}/property.sass (100%) rename test/options/{vendor-prefix-align-sass => vendor-prefix-align/process/sass}/test.js (88%) rename test/options/{vendor-prefix-align-sass => vendor-prefix-align/process/sass}/value.expected.sass (100%) rename test/options/{vendor-prefix-align-sass => vendor-prefix-align/process/sass}/value.sass (100%) rename test/options/vendor-prefix-align/{ => process}/test.js (99%) create mode 100644 test/test_helpers.js diff --git a/package.json b/package.json index f7ed8238..42d92506 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "node": ">= 0.10.0" }, "dependencies": { + "glob": "latest", "minimist": "1.1.x", "csscomb-core": "csscomb/core#build-dev", "vow": "0.4.4" diff --git a/scripts/test.sh b/scripts/test.sh index c077edfa..5597cc23 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -27,7 +27,7 @@ printf "\n\ ---------------\n\ Running Mocha\n\ ---------------\n\n" -test node ./test/mocha +test ./node_modules/.bin/babel-node ./test/mocha if [ $EXIT_CODE -ne 0 ]; then printf "\n\ diff --git a/test/core/configure/test.js b/test/core/configure/test.js index 0ecf6383..d116c0c3 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -1,51 +1,48 @@ -var Comb = process.env.TEST_COV ? require('../../../lib-cov/csscomb') : require('../../../lib/csscomb'); -var assert = require('assert'); - -describe('csscomb methods', function() { - var comb; - var input; - var output; - var expected; - - it('Passing no config to constructor should not configure anything', function() { - comb = new Comb(); - assert.equal(undefined, comb._handlers); - }); - - it.skip('Passing valid config name to constructor should configure using correct config', function() { - comb = new Comb('zen'); - input = 'a { color: tomato; top: 0; }'; - expected = 'a {top: 0; color: tomato; }'; - output = comb.processString(input); - - assert.equal(expected, output); - }); - - it('Passing config object to constructor should configure using that object', function() { - comb = new Comb({ 'always-semicolon': true }); - input = 'a { color: tomato }'; - expected = 'a { color: tomato; }'; - return comb.processString(input) - .then(function(actual) { - assert.equal(actual, expected); - }); - }); - - it.skip('new Comb() should be chainable', function() { - input = 'a { color: tomato; top: 0; }'; - expected = 'a {top: 0; color: tomato; }'; - output = new Comb('zen').processString(input); - - assert.equal(expected, output); - }); - - it('configure() should be chainable', function() { - input = 'a { color: tomato }'; - expected = 'a { color: tomato; }'; - return new Comb().configure({ 'always-semicolon': true }) - .processString(input) - .then(function(actual) { - assert.equal(actual, expected); - }); - }); +let Comb = process.env.TEST_COV ? + require('../../../lib-cov/csscomb') : + require('../../../lib/csscomb'); +let assert = require('assert'); + +describe('CSScomb#configure', function() { + it.skip('Passing no config to constructor should not configure anything', function() { + let comb = new Comb(); + assert.equal(undefined, comb._handlers); + }); + + it.skip('Passing valid config name to constructor should configure using correct config', function() { + let comb = new Comb('zen'); + let input = 'a { color: tomato; top: 0; }'; + let expected = 'a {top: 0; color: tomato; }'; + let output = comb.processString(input); + + assert.equal(expected, output); + }); + + it.skip('Passing config object to constructor should configure using that object', function() { + comb = new Comb({ 'always-semicolon': true }); + input = 'a { color: tomato }'; + expected = 'a { color: tomato; }'; + return comb.processString(input) + .then(function(actual) { + assert.equal(actual, expected); + }); + }); + + it.skip('new Comb() should be chainable', function() { + input = 'a { color: tomato; top: 0; }'; + expected = 'a {top: 0; color: tomato; }'; + output = new Comb('zen').processString(input); + + assert.equal(expected, output); + }); + + it.skip('configure() should be chainable', function() { + input = 'a { color: tomato }'; + expected = 'a { color: tomato; }'; + return new Comb().configure({ 'always-semicolon': true }) + .processString(input) + .then(function(actual) { + assert.equal(actual, expected); + }); + }); }); diff --git a/test/core/get-config/test.js b/test/core/get-config/test.js index 8d69c294..23ec2377 100644 --- a/test/core/get-config/test.js +++ b/test/core/get-config/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('csscomb methods', function() { +describe.skip('csscomb methods', function() { it('getConfig()', function() { var config = require('../../../config/csscomb.json'); diff --git a/test/core/less/test.js b/test/core/less/test.js index defa5353..06688ab3 100644 --- a/test/core/less/test.js +++ b/test/core/less/test.js @@ -1,4 +1,4 @@ -describe('LESS', function() { +describe.skip('LESS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/scss/test.js b/test/core/scss/test.js index 3f2fb42a..eda05b50 100644 --- a/test/core/scss/test.js +++ b/test/core/scss/test.js @@ -1,4 +1,4 @@ -describe('SCSS', function() { +describe.skip('SCSS', function() { beforeEach(function() { this.comb.configure({}); }); diff --git a/test/core/use/test.js b/test/core/use/test.js index 9e41bb44..37ad23c2 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('.use()', function() { +describe.skip('.use()', function() { it('Should set predefined options in correct order', function() { var config = this.Comb.getConfig('csscomb'); this.comb.configure(config); diff --git a/test/mocha.js b/test/mocha.js index 54497980..4fbf3be8 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -1,88 +1,31 @@ -var Comb = process.env.TEST_COV ? +let glob = require('glob'); +let Mocha = require('mocha'); + +let Comb = process.env.TEST_COV ? require('../lib-cov/csscomb') : require('../lib/csscomb'); -var Mocha = require('mocha'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +let helpers = require('./test_helpers'); -var mocha = new Mocha(); +let mocha = new Mocha(); +//mocha.reporter('spec'); if (process.env.TEST_COV) mocha.reporter('html-cov'); // Tell mocha which tests to run: -fs.readdirSync('test/core').forEach(function(dir) { - mocha.addFile(path.join('test/core', dir, 'test.js')); -}); -fs.readdirSync('test/options').forEach(function(dir) { - mocha.addFile(path.join('test/options', dir, 'test.js')); +glob.sync('test/**/test.js').forEach(file => { + mocha.addFile(file); }); -function readFile(filename) { - var dirname = path.dirname(this.test.file); - return fs.readFileSync(dirname + '/' + filename, 'utf8'); -} - -function shouldBeEqual(input, expected) { - var syntax = input.split('.').pop(); - input = readFile.call(this, input); - expected = expected ? readFile.call(this, expected) : input; - return this.comb.processString(input, { syntax: syntax }) - .then(function(string) { - assert.equal(string, expected); - }); -} - -function getErrors(filename) { - var syntax = filename.split('.').pop(); - var input = readFile.call(this, filename); - return this.comb.lintString(input, { syntax: syntax }); -} - -function sortObject(o) { - var sorted = {}; - var key = []; - var a = []; - - for (key in o) { - if (o.hasOwnProperty(key)) { - a.push(key); - } - } - - a.sort(); - - for (key = 0; key < a.length; key++) { - sorted[a[key]] = o[a[key]]; - } - return sorted; -} - -/** - * Detect options in a file and compare result with expected. - * File names should be relative to test suite's folder. - * @param {Array} options List of options that should be detected - * @param {String} input Name of template file - * @param {Object} expected Expected config with detected options - */ -function shouldDetect(options, input, expected) { - // We need to “sort” the input and expected objects, as their order may vary - assert.equal( - JSON.stringify(sortObject(Comb.detectInString(input, options))), - JSON.stringify(sortObject(expected)) - ); -} - // Add helpers (see tests for usage examples): mocha.suite.beforeEach(function() { this.Comb = Comb; this.comb = new Comb(); - this.readFile = readFile; - this.shouldBeEqual = shouldBeEqual; - this.shouldDetect = shouldDetect; - this.getErrors = getErrors; + this.readFile = helpers.readFile; + this.shouldBeEqual = helpers.shouldBeEqual; + this.shouldDetect = helpers.shouldDetect; + this.getErrors = helpers.getErrors; }); -mocha.run(function(failures) { - process.on('exit', function() { +mocha.run(failures => { + process.on('exit', () => { process.exit(failures); }); }); diff --git a/test/options/always-semicolon-less/test.js b/test/options/always-semicolon-less/test.js deleted file mode 100644 index 7ee40da3..00000000 --- a/test/options/always-semicolon-less/test.js +++ /dev/null @@ -1,55 +0,0 @@ -describe('options/always-semicolon (less)', function() { - beforeEach(function() { - this.comb.configure({ 'always-semicolon': true }); - }); - - describe('process', function() { - it('Should not add semicolon to condition (single-line style)', function() { - return this.shouldBeEqual('condition.less'); - }); - - it('Should not add semicolon to condition (multi-line style)', function() { - return this.shouldBeEqual('condition-multiline.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - return this.shouldBeEqual('include-1.less', 'include-1.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - return this.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - return this.shouldBeEqual('include-2.less', 'include-2.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - return this.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { - return this.shouldBeEqual('include-3.less', 'include-3.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { - return this.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { - return this.shouldBeEqual('include-4.less', 'include-4.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { - return this.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { - return this.shouldBeEqual('include-5.less', 'include-5.expected.less'); - }); - - it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { - return this.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); - }); - }); -}); diff --git a/test/options/always-semicolon-sass/test.js b/test/options/always-semicolon-sass/test.js deleted file mode 100644 index 195a5e1d..00000000 --- a/test/options/always-semicolon-sass/test.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('options/always-semicolon (sass)', function() { - beforeEach(function() { - this.comb.configure({ 'always-semicolon': true }); - }); - - describe('process', function() { - it('Should not add semicolon', function() { - return this.shouldBeEqual('test.sass'); - }); - }); -}); diff --git a/test/options/always-semicolon-scss/test.js b/test/options/always-semicolon-scss/test.js deleted file mode 100644 index 1124ce94..00000000 --- a/test/options/always-semicolon-scss/test.js +++ /dev/null @@ -1,63 +0,0 @@ -describe('options/always-semicolon (scss)', function() { - beforeEach(function() { - this.comb.configure({ 'always-semicolon': true }); - }); - - describe('process', function() { - it('Should not add semicolon if last value is block (singl-line style)', function() { - return this.shouldBeEqual('block-value.scss'); - }); - - it('Should not add semicolon if last value is block (multi-line style)', function() { - return this.shouldBeEqual('block-value-multiline.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - return this.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - return this.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - return this.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); - }); - - it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - return this.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); - }); - - it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { - return this.shouldBeEqual('block-include.scss'); - }); - - it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { - return this.shouldBeEqual('block-include-multiline.scss'); - }); - - it('Should add semicolon to last extend if missing (single-line style)', function() { - return this.shouldBeEqual('extend.scss', 'extend.expected.scss'); - }); - - it('Should add semicolon to last extend if missing (multi-line style)', function() { - return this.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); - }); - - it('Should not add semicolon to condition (single-line style)', function() { - return this.shouldBeEqual('condition.scss'); - }); - - it('Should not add semicolon to condition (multi-line style)', function() { - return this.shouldBeEqual('condition-multiline.scss'); - }); - - it('Should not add semicolon to loop (single-line style)', function() { - return this.shouldBeEqual('loop.scss'); - }); - - it('Should not add semicolon to loop (multi-line style)', function() { - return this.shouldBeEqual('loop-multiline.scss'); - }); - }); -}); diff --git a/test/options/always-semicolon/detect/css/test-1.css b/test/options/always-semicolon/detect/css/test-1.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-1.expected.css b/test/options/always-semicolon/detect/css/test-1.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-2.css b/test/options/always-semicolon/detect/css/test-2.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-2.expected.css b/test/options/always-semicolon/detect/css/test-2.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-3.css b/test/options/always-semicolon/detect/css/test-3.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-3.expected.css b/test/options/always-semicolon/detect/css/test-3.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-4.css b/test/options/always-semicolon/detect/css/test-4.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-4.expected.css b/test/options/always-semicolon/detect/css/test-4.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-5.css b/test/options/always-semicolon/detect/css/test-5.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-5.expected.css b/test/options/always-semicolon/detect/css/test-5.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-6.css b/test/options/always-semicolon/detect/css/test-6.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-6.expected.css b/test/options/always-semicolon/detect/css/test-6.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-7.css b/test/options/always-semicolon/detect/css/test-7.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/css/test-7.expected.css b/test/options/always-semicolon/detect/css/test-7.expected.css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/always-semicolon/detect/test.js b/test/options/always-semicolon/detect/test.js new file mode 100644 index 00000000..a6e0c367 --- /dev/null +++ b/test/options/always-semicolon/detect/test.js @@ -0,0 +1,63 @@ +describe('Option `always-semicolon`, detect', function() { + describe('CSS', function() { + it('Should detect semicolon for last property. Test 1', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0 }', + {'always-semicolon': false} + ); + }); + + it('Should detect semicolon for last property. Test 2', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0; }', + {'always-semicolon': true} + ); + }); + + it('Should detect semicolon for last property. Test 3', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0; } div { height: 0 }', + {'always-semicolon': true} + ); + }); + + it('Should detect semicolon for last property. Test 4', function() { + this.shouldDetect( + ['always-semicolon'], + 'div { height: 0 } div { height: 0; } div { height: 0 }', + {'always-semicolon': false} + ); + }); + + it('Should detect semicolon for last property. Test 5', function() { + this.shouldDetect( + ['always-semicolon'], + 'div {\nheight: 0 /* Comment */\n} ' + + 'div { height: 0; }' + + 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}', + {'always-semicolon': false} + ); + }); + + + it('Should detect semicolon for last property. Test 6', function() { + this.shouldDetect( + ['always-semicolon'], + 'a{\n border:0;\n}', + {'always-semicolon': true} + ); + }); + + it('Should not detect semicolon for last property if there are no properties', function() { + this.shouldDetect( + ['always-semicolon'], + 'div {}', + {} + ); + }); + }); +}); + diff --git a/test/options/always-semicolon/lint-1.css b/test/options/always-semicolon/lint/css/lint-1.css similarity index 100% rename from test/options/always-semicolon/lint-1.css rename to test/options/always-semicolon/lint/css/lint-1.css diff --git a/test/options/always-semicolon/lint-2.css b/test/options/always-semicolon/lint/css/lint-2.css similarity index 100% rename from test/options/always-semicolon/lint-2.css rename to test/options/always-semicolon/lint/css/lint-2.css diff --git a/test/options/always-semicolon/lint-3.css b/test/options/always-semicolon/lint/css/lint-3.css similarity index 100% rename from test/options/always-semicolon/lint-3.css rename to test/options/always-semicolon/lint/css/lint-3.css diff --git a/test/options/always-semicolon/lint/test.js b/test/options/always-semicolon/lint/test.js new file mode 100644 index 00000000..b565152c --- /dev/null +++ b/test/options/always-semicolon/lint/test.js @@ -0,0 +1,43 @@ +let assert = require('assert'); + +describe('Option `always-semicolon`, lint', function() { + describe('CSS', function() { + it('Should report no errors', function() { + this.comb.configure({'always-semicolon': true}); + return this.getErrors('css/lint-1.css').then(errors => { + assert.equal(errors.length, 0); + }); + }); + + it('Error mesage should be a string', function() { + this.comb.configure({'always-semicolon': true}); + return this.getErrors('css/lint-2.css').then(errors => { + let error = errors[0]; + assert.equal(typeof error.message, 'string'); + }); + }); + + it('Error should provide correct position info', function() { + this.comb.configure({'always-semicolon': true}); + return this.getErrors('css/lint-2.css').then(errors => { + let error = errors[0]; + assert.equal(error.line, 1); + assert.equal(error.column, 16); + }); + }); + + it('Should report multiple errors', function() { + this.comb.configure({'always-semicolon': true}); + return this.getErrors('css/lint-3.css').then(errors => { + assert.equal(errors.length, 2); + + assert.equal(errors[0].line, 2); + assert.equal(errors[0].column, 14); + + assert.equal(errors[1].line, 8); + assert.equal(errors[1].column, 24); + }); + }); + }); +}); + diff --git a/test/options/always-semicolon/process/css/test-1.css b/test/options/always-semicolon/process/css/test-1.css new file mode 100644 index 00000000..f36f0139 --- /dev/null +++ b/test/options/always-semicolon/process/css/test-1.css @@ -0,0 +1 @@ +div { height: 0 } diff --git a/test/options/always-semicolon/process/css/test-1.expected.css b/test/options/always-semicolon/process/css/test-1.expected.css new file mode 100644 index 00000000..0dbee0fe --- /dev/null +++ b/test/options/always-semicolon/process/css/test-1.expected.css @@ -0,0 +1 @@ +div { height: 0; } diff --git a/test/options/always-semicolon/process/css/test-2.css b/test/options/always-semicolon/process/css/test-2.css new file mode 100644 index 00000000..c1888d9f --- /dev/null +++ b/test/options/always-semicolon/process/css/test-2.css @@ -0,0 +1,3 @@ +div { +height: 0 +} diff --git a/test/options/always-semicolon/process/css/test-2.expected.css b/test/options/always-semicolon/process/css/test-2.expected.css new file mode 100644 index 00000000..d5a75f33 --- /dev/null +++ b/test/options/always-semicolon/process/css/test-2.expected.css @@ -0,0 +1,3 @@ +div { +height: 0; +} diff --git a/test/options/always-semicolon/process/css/test-3.css b/test/options/always-semicolon/process/css/test-3.css new file mode 100644 index 00000000..8840e0e0 --- /dev/null +++ b/test/options/always-semicolon/process/css/test-3.css @@ -0,0 +1 @@ +div {height: 0} diff --git a/test/options/always-semicolon/process/css/test-3.expected.css b/test/options/always-semicolon/process/css/test-3.expected.css new file mode 100644 index 00000000..8fe52809 --- /dev/null +++ b/test/options/always-semicolon/process/css/test-3.expected.css @@ -0,0 +1 @@ +div {height: 0;} diff --git a/test/options/always-semicolon/process/css/test-4.css b/test/options/always-semicolon/process/css/test-4.css new file mode 100644 index 00000000..d72a31ce --- /dev/null +++ b/test/options/always-semicolon/process/css/test-4.css @@ -0,0 +1,3 @@ +div { +height: 0 /* Comment */ +} diff --git a/test/options/always-semicolon/process/css/test-4.expected.css b/test/options/always-semicolon/process/css/test-4.expected.css new file mode 100644 index 00000000..4710445d --- /dev/null +++ b/test/options/always-semicolon/process/css/test-4.expected.css @@ -0,0 +1,3 @@ +div { +height: 0; /* Comment */ +} diff --git a/test/options/always-semicolon/process/css/test-5.css b/test/options/always-semicolon/process/css/test-5.css new file mode 100644 index 00000000..578fd29c --- /dev/null +++ b/test/options/always-semicolon/process/css/test-5.css @@ -0,0 +1,4 @@ +div { +top: 1px; +height: 0 /* 1comment */ /* 2comment */ +} diff --git a/test/options/always-semicolon/process/css/test-5.expected.css b/test/options/always-semicolon/process/css/test-5.expected.css new file mode 100644 index 00000000..1869f051 --- /dev/null +++ b/test/options/always-semicolon/process/css/test-5.expected.css @@ -0,0 +1,4 @@ +div { +top: 1px; +height: 0; /* 1comment */ /* 2comment */ +} diff --git a/test/options/always-semicolon-less/condition-multiline.less b/test/options/always-semicolon/process/less/condition-multiline.less similarity index 100% rename from test/options/always-semicolon-less/condition-multiline.less rename to test/options/always-semicolon/process/less/condition-multiline.less diff --git a/test/options/always-semicolon-less/condition.less b/test/options/always-semicolon/process/less/condition.less similarity index 100% rename from test/options/always-semicolon-less/condition.less rename to test/options/always-semicolon/process/less/condition.less diff --git a/test/options/always-semicolon-less/include-1-multiline.expected.less b/test/options/always-semicolon/process/less/include-1-multiline.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-1-multiline.expected.less rename to test/options/always-semicolon/process/less/include-1-multiline.expected.less diff --git a/test/options/always-semicolon-less/include-1-multiline.less b/test/options/always-semicolon/process/less/include-1-multiline.less similarity index 100% rename from test/options/always-semicolon-less/include-1-multiline.less rename to test/options/always-semicolon/process/less/include-1-multiline.less diff --git a/test/options/always-semicolon-less/include-1.expected.less b/test/options/always-semicolon/process/less/include-1.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-1.expected.less rename to test/options/always-semicolon/process/less/include-1.expected.less diff --git a/test/options/always-semicolon-less/include-1.less b/test/options/always-semicolon/process/less/include-1.less similarity index 100% rename from test/options/always-semicolon-less/include-1.less rename to test/options/always-semicolon/process/less/include-1.less diff --git a/test/options/always-semicolon-less/include-2-multiline.expected.less b/test/options/always-semicolon/process/less/include-2-multiline.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-2-multiline.expected.less rename to test/options/always-semicolon/process/less/include-2-multiline.expected.less diff --git a/test/options/always-semicolon-less/include-2-multiline.less b/test/options/always-semicolon/process/less/include-2-multiline.less similarity index 100% rename from test/options/always-semicolon-less/include-2-multiline.less rename to test/options/always-semicolon/process/less/include-2-multiline.less diff --git a/test/options/always-semicolon-less/include-2.expected.less b/test/options/always-semicolon/process/less/include-2.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-2.expected.less rename to test/options/always-semicolon/process/less/include-2.expected.less diff --git a/test/options/always-semicolon-less/include-2.less b/test/options/always-semicolon/process/less/include-2.less similarity index 100% rename from test/options/always-semicolon-less/include-2.less rename to test/options/always-semicolon/process/less/include-2.less diff --git a/test/options/always-semicolon-less/include-3-multiline.expected.less b/test/options/always-semicolon/process/less/include-3-multiline.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-3-multiline.expected.less rename to test/options/always-semicolon/process/less/include-3-multiline.expected.less diff --git a/test/options/always-semicolon-less/include-3-multiline.less b/test/options/always-semicolon/process/less/include-3-multiline.less similarity index 100% rename from test/options/always-semicolon-less/include-3-multiline.less rename to test/options/always-semicolon/process/less/include-3-multiline.less diff --git a/test/options/always-semicolon-less/include-3.expected.less b/test/options/always-semicolon/process/less/include-3.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-3.expected.less rename to test/options/always-semicolon/process/less/include-3.expected.less diff --git a/test/options/always-semicolon-less/include-3.less b/test/options/always-semicolon/process/less/include-3.less similarity index 100% rename from test/options/always-semicolon-less/include-3.less rename to test/options/always-semicolon/process/less/include-3.less diff --git a/test/options/always-semicolon-less/include-4-multiline.expected.less b/test/options/always-semicolon/process/less/include-4-multiline.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-4-multiline.expected.less rename to test/options/always-semicolon/process/less/include-4-multiline.expected.less diff --git a/test/options/always-semicolon-less/include-4-multiline.less b/test/options/always-semicolon/process/less/include-4-multiline.less similarity index 100% rename from test/options/always-semicolon-less/include-4-multiline.less rename to test/options/always-semicolon/process/less/include-4-multiline.less diff --git a/test/options/always-semicolon-less/include-4.expected.less b/test/options/always-semicolon/process/less/include-4.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-4.expected.less rename to test/options/always-semicolon/process/less/include-4.expected.less diff --git a/test/options/always-semicolon-less/include-4.less b/test/options/always-semicolon/process/less/include-4.less similarity index 100% rename from test/options/always-semicolon-less/include-4.less rename to test/options/always-semicolon/process/less/include-4.less diff --git a/test/options/always-semicolon-less/include-5-multiline.expected.less b/test/options/always-semicolon/process/less/include-5-multiline.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-5-multiline.expected.less rename to test/options/always-semicolon/process/less/include-5-multiline.expected.less diff --git a/test/options/always-semicolon-less/include-5-multiline.less b/test/options/always-semicolon/process/less/include-5-multiline.less similarity index 100% rename from test/options/always-semicolon-less/include-5-multiline.less rename to test/options/always-semicolon/process/less/include-5-multiline.less diff --git a/test/options/always-semicolon-less/include-5.expected.less b/test/options/always-semicolon/process/less/include-5.expected.less similarity index 100% rename from test/options/always-semicolon-less/include-5.expected.less rename to test/options/always-semicolon/process/less/include-5.expected.less diff --git a/test/options/always-semicolon-less/include-5.less b/test/options/always-semicolon/process/less/include-5.less similarity index 100% rename from test/options/always-semicolon-less/include-5.less rename to test/options/always-semicolon/process/less/include-5.less diff --git a/test/options/always-semicolon-sass/test.sass b/test/options/always-semicolon/process/sass/test.sass similarity index 100% rename from test/options/always-semicolon-sass/test.sass rename to test/options/always-semicolon/process/sass/test.sass diff --git a/test/options/always-semicolon-scss/block-include-multiline.scss b/test/options/always-semicolon/process/scss/block-include-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/block-include-multiline.scss rename to test/options/always-semicolon/process/scss/block-include-multiline.scss diff --git a/test/options/always-semicolon-scss/block-include.scss b/test/options/always-semicolon/process/scss/block-include.scss similarity index 100% rename from test/options/always-semicolon-scss/block-include.scss rename to test/options/always-semicolon/process/scss/block-include.scss diff --git a/test/options/always-semicolon-scss/block-value-multiline.scss b/test/options/always-semicolon/process/scss/block-value-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/block-value-multiline.scss rename to test/options/always-semicolon/process/scss/block-value-multiline.scss diff --git a/test/options/always-semicolon-scss/block-value.scss b/test/options/always-semicolon/process/scss/block-value.scss similarity index 100% rename from test/options/always-semicolon-scss/block-value.scss rename to test/options/always-semicolon/process/scss/block-value.scss diff --git a/test/options/always-semicolon-scss/condition-multiline.scss b/test/options/always-semicolon/process/scss/condition-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/condition-multiline.scss rename to test/options/always-semicolon/process/scss/condition-multiline.scss diff --git a/test/options/always-semicolon-scss/condition.scss b/test/options/always-semicolon/process/scss/condition.scss similarity index 100% rename from test/options/always-semicolon-scss/condition.scss rename to test/options/always-semicolon/process/scss/condition.scss diff --git a/test/options/always-semicolon-scss/extend-multiline.expected.scss b/test/options/always-semicolon/process/scss/extend-multiline.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/extend-multiline.expected.scss rename to test/options/always-semicolon/process/scss/extend-multiline.expected.scss diff --git a/test/options/always-semicolon-scss/extend-multiline.scss b/test/options/always-semicolon/process/scss/extend-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/extend-multiline.scss rename to test/options/always-semicolon/process/scss/extend-multiline.scss diff --git a/test/options/always-semicolon-scss/extend.expected.scss b/test/options/always-semicolon/process/scss/extend.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/extend.expected.scss rename to test/options/always-semicolon/process/scss/extend.expected.scss diff --git a/test/options/always-semicolon-scss/extend.scss b/test/options/always-semicolon/process/scss/extend.scss similarity index 100% rename from test/options/always-semicolon-scss/extend.scss rename to test/options/always-semicolon/process/scss/extend.scss diff --git a/test/options/always-semicolon-scss/include-1-multiline.expected.scss b/test/options/always-semicolon/process/scss/include-1-multiline.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/include-1-multiline.expected.scss rename to test/options/always-semicolon/process/scss/include-1-multiline.expected.scss diff --git a/test/options/always-semicolon-scss/include-1-multiline.scss b/test/options/always-semicolon/process/scss/include-1-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/include-1-multiline.scss rename to test/options/always-semicolon/process/scss/include-1-multiline.scss diff --git a/test/options/always-semicolon-scss/include-1.expected.scss b/test/options/always-semicolon/process/scss/include-1.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/include-1.expected.scss rename to test/options/always-semicolon/process/scss/include-1.expected.scss diff --git a/test/options/always-semicolon-scss/include-1.scss b/test/options/always-semicolon/process/scss/include-1.scss similarity index 100% rename from test/options/always-semicolon-scss/include-1.scss rename to test/options/always-semicolon/process/scss/include-1.scss diff --git a/test/options/always-semicolon-scss/include-2-multiline.expected.scss b/test/options/always-semicolon/process/scss/include-2-multiline.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/include-2-multiline.expected.scss rename to test/options/always-semicolon/process/scss/include-2-multiline.expected.scss diff --git a/test/options/always-semicolon-scss/include-2-multiline.scss b/test/options/always-semicolon/process/scss/include-2-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/include-2-multiline.scss rename to test/options/always-semicolon/process/scss/include-2-multiline.scss diff --git a/test/options/always-semicolon-scss/include-2.expected.scss b/test/options/always-semicolon/process/scss/include-2.expected.scss similarity index 100% rename from test/options/always-semicolon-scss/include-2.expected.scss rename to test/options/always-semicolon/process/scss/include-2.expected.scss diff --git a/test/options/always-semicolon-scss/include-2.scss b/test/options/always-semicolon/process/scss/include-2.scss similarity index 100% rename from test/options/always-semicolon-scss/include-2.scss rename to test/options/always-semicolon/process/scss/include-2.scss diff --git a/test/options/always-semicolon-scss/loop-multiline.scss b/test/options/always-semicolon/process/scss/loop-multiline.scss similarity index 100% rename from test/options/always-semicolon-scss/loop-multiline.scss rename to test/options/always-semicolon/process/scss/loop-multiline.scss diff --git a/test/options/always-semicolon-scss/loop.scss b/test/options/always-semicolon/process/scss/loop.scss similarity index 100% rename from test/options/always-semicolon-scss/loop.scss rename to test/options/always-semicolon/process/scss/loop.scss diff --git a/test/options/always-semicolon/process/test.js b/test/options/always-semicolon/process/test.js new file mode 100644 index 00000000..ceb4b994 --- /dev/null +++ b/test/options/always-semicolon/process/test.js @@ -0,0 +1,169 @@ +describe('Option `always-semicolon`, process', function() { + describe('CSS', function() { + it('Should add semicolon for last property if missing. Test 1', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('css/test-1.css', 'css/test-1.expected.css'); + }); + + it('Should add semicolon for last property if missing. Test 2', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('css/test-2.css', 'css/test-2.expected.css'); + }); + + it('Should add semicolon for last property if missing. Test 3', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('css/test-3.css', 'css/test-3.expected.css'); + }); + + it('Should add semicolon for last property if missing. Test 4', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('css/test-4.css', 'css/test-4.expected.css'); + }); + + it('Should add semicolon for last property if missing. Test 5', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('css/test-5.css', 'css/test-5.expected.css'); + }); + }); + + describe('LESS', function() { + it('Should not add semicolon to condition (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/condition.less'); + }); + + it('Should not add semicolon to condition (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/condition-multiline.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-1.less', 'less/include-1.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-1-multiline.less', 'less/include-1-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-2.less', 'less/include-2.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-2-multiline.less', 'less/include-2-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-3.less', 'less/include-3.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-3-multiline.less', 'less/include-3-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-4.less', 'less/include-4.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-4-multiline.less', 'less/include-4-multiline.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-5.less', 'less/include-5.expected.less'); + }); + + it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { + this.comb.configure({'always-semicolon':true}); + return this.shouldBeEqual('less/include-5-multiline.less', 'less/include-5-multiline.expected.less'); + }); + }); + + describe('Sass', function() { + it('Should not add semicolon', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('sass/test.sass'); + }); + }); + + describe('SCSS', function() { + it('Should not add semicolon if last value is block (singl-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/block-value.scss'); + }); + + it('Should not add semicolon if last value is block (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/block-value-multiline.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/include-1.scss', 'scss/include-1.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/include-1-multiline.scss', 'scss/include-1-multiline.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/include-2.scss', 'scss/include-2.expected.scss'); + }); + + it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/include-2-multiline.scss', 'scss/include-2-multiline.expected.scss'); + }); + + it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/block-include.scss'); + }); + + it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/block-include-multiline.scss'); + }); + + it('Should add semicolon to last extend if missing (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/extend.scss', 'scss/extend.expected.scss'); + }); + + it('Should add semicolon to last extend if missing (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/extend-multiline.scss', 'scss/extend-multiline.expected.scss'); + }); + + it('Should not add semicolon to condition (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/condition.scss'); + }); + + it('Should not add semicolon to condition (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/condition-multiline.scss'); + }); + + it('Should not add semicolon to loop (single-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/loop.scss'); + }); + + it('Should not add semicolon to loop (multi-line style)', function() { + this.comb.configure({'always-semicolon': true}); + return this.shouldBeEqual('scss/loop-multiline.scss'); + }); + }); +}); diff --git a/test/options/always-semicolon/test.js b/test/options/always-semicolon/test.js deleted file mode 100644 index 8a5e0e21..00000000 --- a/test/options/always-semicolon/test.js +++ /dev/null @@ -1,158 +0,0 @@ -var assert = require('assert'); - -describe('options/always-semicolon', function() { - describe('process', function() { - it('Should add semicolon for last property if missing. Test 1', function() { - this.comb.configure({ 'always-semicolon': true }); - return this.comb.processString( - 'div { height: 0 }' - ).then(function(actual) { - assert.equal(actual, 'div { height: 0; }'); - }); - }); - - it('Should add semicolon for last property if missing. Test 2', function() { - this.comb.configure({ 'always-semicolon': true }); - return this.comb.processString( - 'div {\nheight: 0\n}' - ).then(function(actual) { - assert.equal(actual, 'div {\nheight: 0;\n}'); - }); - }); - - it('Should add semicolon for last property if missing. Test 3', function() { - this.comb.configure({ 'always-semicolon': true }); - return this.comb.processString( - 'div {height: 0}' - ).then(function(actual) { - assert.equal(actual, 'div {height: 0;}'); - }); - }); - - it('Should add semicolon for last property if missing. Test 4', function() { - this.comb.configure({ 'always-semicolon': true }); - return this.comb.processString( - 'div {\nheight: 0 /* Comment */\n}' - ).then(function(actual) { - assert.equal(actual, 'div {\nheight: 0; /* Comment */\n}'); - }); - }); - - it('Should add semicolon for last property if missing. Test 5', function() { - this.comb.configure({ 'always-semicolon': true }); - return this.comb.processString( - 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}' - ).then(function(actual) { - assert.equal(actual, 'div {\ntop: 1px;\nheight: 0; /* 1comment */ /* 2comment */\n}'); - }); - }); - }); - - describe('lint', function() { - it('Should report no errors', function() { - return this.getErrors('lint-1.css').then(function(errors) { - assert.equal(errors.length, 0); - }); - }); - - it('Error mesage should be a string', function() { - return this.getErrors('lint-2.css').then(function(errors) { - var error = errors[0]; - assert.equal(typeof error.message, 'string'); - }); - }); - - it('Error should provide correct position info', function() { - return this.getErrors('lint-2.css').then(function(errors) { - var error = errors[0]; - assert.equal(error.line, 1); - assert.equal(error.column, 16); - }); - }); - - it('Should report multiple errors', function() { - return this.getErrors('lint-3.css').then(function(errors) { - assert.equal(errors.length, 2); - - assert.equal(errors[0].line, 2); - assert.equal(errors[0].column, 14); - - assert.equal(errors[1].line, 8); - assert.equal(errors[1].column, 24); - }); - }); - }); - - describe('detect', function() { - it('Should detect semicolon for last property. Test 1', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0 }', - { - 'always-semicolon': false - } - ); - }); - - it('Should detect semicolon for last property. Test 2', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0; }', - { - 'always-semicolon': true - } - ); - }); - - it('Should detect semicolon for last property. Test 3', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0; } div { height: 0 }', - { - 'always-semicolon': true - } - ); - }); - - it('Should detect semicolon for last property. Test 4', function() { - this.shouldDetect( - ['always-semicolon'], - 'div { height: 0 } div { height: 0; } div { height: 0 }', - { - 'always-semicolon': false - } - ); - }); - - it('Should detect semicolon for last property. Test 5', function() { - this.shouldDetect( - ['always-semicolon'], - 'div {\nheight: 0 /* Comment */\n} ' + - 'div { height: 0; }' + - 'div {\ntop: 1px;\nheight: 0 /* 1comment */ /* 2comment */\n}', - { - 'always-semicolon': false - } - ); - }); - - - it('Should detect semicolon for last property. Test 6', function() { - this.shouldDetect( - ['always-semicolon'], - 'a{\n border:0;\n}', - { - 'always-semicolon': true - } - ); - }); - - it('Should not detect semicolon for last property if there are no properties', function() { - this.shouldDetect( - ['always-semicolon'], - 'div {}', - {} - ); - }); - }); -}); diff --git a/test/options/block-indent/issue-379.css b/test/options/block-indent/process/css/issue-379.css similarity index 100% rename from test/options/block-indent/issue-379.css rename to test/options/block-indent/process/css/issue-379.css diff --git a/test/options/block-indent/issue-379.expected.css b/test/options/block-indent/process/css/issue-379.expected.css similarity index 100% rename from test/options/block-indent/issue-379.expected.css rename to test/options/block-indent/process/css/issue-379.expected.css diff --git a/test/options/block-indent/test-2.expected.css b/test/options/block-indent/process/css/test-2.expected.css similarity index 100% rename from test/options/block-indent/test-2.expected.css rename to test/options/block-indent/process/css/test-2.expected.css diff --git a/test/options/block-indent/test-3.expected.css b/test/options/block-indent/process/css/test-3.expected.css similarity index 100% rename from test/options/block-indent/test-3.expected.css rename to test/options/block-indent/process/css/test-3.expected.css diff --git a/test/options/block-indent/test.css b/test/options/block-indent/process/css/test.css similarity index 100% rename from test/options/block-indent/test.css rename to test/options/block-indent/process/css/test.css diff --git a/test/options/block-indent/test.expected.css b/test/options/block-indent/process/css/test.expected.css similarity index 100% rename from test/options/block-indent/test.expected.css rename to test/options/block-indent/process/css/test.expected.css diff --git a/test/options/block-indent-sass/block.expected.sass b/test/options/block-indent/process/sass/block.expected.sass similarity index 100% rename from test/options/block-indent-sass/block.expected.sass rename to test/options/block-indent/process/sass/block.expected.sass diff --git a/test/options/block-indent-sass/block.sass b/test/options/block-indent/process/sass/block.sass similarity index 100% rename from test/options/block-indent-sass/block.sass rename to test/options/block-indent/process/sass/block.sass diff --git a/test/options/block-indent-sass/mixin.expected.sass b/test/options/block-indent/process/sass/mixin.expected.sass similarity index 100% rename from test/options/block-indent-sass/mixin.expected.sass rename to test/options/block-indent/process/sass/mixin.expected.sass diff --git a/test/options/block-indent-sass/mixin.sass b/test/options/block-indent/process/sass/mixin.sass similarity index 100% rename from test/options/block-indent-sass/mixin.sass rename to test/options/block-indent/process/sass/mixin.sass diff --git a/test/options/block-indent-sass/nested-ruleset.expected.sass b/test/options/block-indent/process/sass/nested-ruleset.expected.sass similarity index 100% rename from test/options/block-indent-sass/nested-ruleset.expected.sass rename to test/options/block-indent/process/sass/nested-ruleset.expected.sass diff --git a/test/options/block-indent-sass/nested-ruleset.sass b/test/options/block-indent/process/sass/nested-ruleset.sass similarity index 100% rename from test/options/block-indent-sass/nested-ruleset.sass rename to test/options/block-indent/process/sass/nested-ruleset.sass diff --git a/test/options/block-indent-sass/test.js b/test/options/block-indent/process/sass/test.js similarity index 91% rename from test/options/block-indent-sass/test.js rename to test/options/block-indent/process/sass/test.js index c7b56edc..17a74581 100644 --- a/test/options/block-indent-sass/test.js +++ b/test/options/block-indent/process/sass/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent (sass):', function() { +describe.skip('options/block-indent (sass):', function() { describe('process', function() { it('First level ruleset\'s block', function() { this.comb.configure({ 'block-indent': 2 }); diff --git a/test/options/block-indent-scss/nested-include.expected.scss b/test/options/block-indent/process/scss/nested-include.expected.scss similarity index 100% rename from test/options/block-indent-scss/nested-include.expected.scss rename to test/options/block-indent/process/scss/nested-include.expected.scss diff --git a/test/options/block-indent-scss/nested-include.scss b/test/options/block-indent/process/scss/nested-include.scss similarity index 100% rename from test/options/block-indent-scss/nested-include.scss rename to test/options/block-indent/process/scss/nested-include.scss diff --git a/test/options/block-indent-scss/test.js b/test/options/block-indent/process/scss/test.js similarity index 80% rename from test/options/block-indent-scss/test.js rename to test/options/block-indent/process/scss/test.js index 325c331e..64e23760 100644 --- a/test/options/block-indent-scss/test.js +++ b/test/options/block-indent/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent (scss):', function() { +describe.skip('options/block-indent (scss):', function() { describe('process', function() { it('Issue 213', function() { this.comb.configure({ 'block-indent': 2 }); diff --git a/test/options/block-indent/test.js b/test/options/block-indent/process/test.js similarity index 97% rename from test/options/block-indent/test.js rename to test/options/block-indent/process/test.js index 2cfb6d4b..2aed90e8 100644 --- a/test/options/block-indent/test.js +++ b/test/options/block-indent/process/test.js @@ -1,4 +1,4 @@ -describe('options/block-indent:', function() { +describe.skip('options/block-indent:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'block-indent': ['', ' '] }); diff --git a/test/options/color-case/test.js b/test/options/color-case/process/test.js similarity index 98% rename from test/options/color-case/test.js rename to test/options/color-case/process/test.js index 248036e4..790736b4 100644 --- a/test/options/color-case/test.js +++ b/test/options/color-case/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/color-case', function() { +describe.skip('options/color-case', function() { describe('process', function() { it('Should switch colors to upper case', function() { this.comb.configure({ 'color-case': 'upper' }); diff --git a/test/options/color-shorthand/test.js b/test/options/color-shorthand/process/test.js similarity index 97% rename from test/options/color-shorthand/test.js rename to test/options/color-shorthand/process/test.js index 9cf35df4..fd2bd3e3 100644 --- a/test/options/color-shorthand/test.js +++ b/test/options/color-shorthand/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/color-shorthand', function() { +describe.skip('options/color-shorthand', function() { describe('process', function() { it('Should shrink hexadecimal colors to 3 symbols', function() { this.comb.configure({ 'color-shorthand': true }); diff --git a/test/options/element-case-scss/mixin.expected.scss b/test/options/element-case/process/scss/mixin.expected.scss similarity index 100% rename from test/options/element-case-scss/mixin.expected.scss rename to test/options/element-case/process/scss/mixin.expected.scss diff --git a/test/options/element-case-scss/mixin.scss b/test/options/element-case/process/scss/mixin.scss similarity index 100% rename from test/options/element-case-scss/mixin.scss rename to test/options/element-case/process/scss/mixin.scss diff --git a/test/options/element-case-scss/test.js b/test/options/element-case/process/scss/test.js similarity index 81% rename from test/options/element-case-scss/test.js rename to test/options/element-case/process/scss/test.js index f06a08b0..293d269b 100644 --- a/test/options/element-case-scss/test.js +++ b/test/options/element-case/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/element-case (scss):', function() { +describe.skip('options/element-case (scss):', function() { describe('process', function() { it('Should not touch mixin names', function() { this.comb.configure({ 'element-case': 'lower' }); diff --git a/test/options/element-case/test.js b/test/options/element-case/process/test.js similarity index 98% rename from test/options/element-case/test.js rename to test/options/element-case/process/test.js index af67e36c..bf4d99b9 100644 --- a/test/options/element-case/test.js +++ b/test/options/element-case/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/element-case', function() { +describe.skip('options/element-case', function() { describe('process', function() { it('Invalid String should not change case of elements', function() { this.comb.configure({ 'element-case': 'foobar' }); diff --git a/test/options/eof-newline/test.js b/test/options/eof-newline/process/test.js similarity index 97% rename from test/options/eof-newline/test.js rename to test/options/eof-newline/process/test.js index ebf6c207..f26b47f0 100644 --- a/test/options/eof-newline/test.js +++ b/test/options/eof-newline/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/eof-newline', function() { +describe.skip('options/eof-newline', function() { describe('process', function() { it('Invalid value should not change trim trailing brac', function() { this.comb.configure({ 'eof-newline': 'foobar' }); diff --git a/test/options/integral/integral.css b/test/options/integral/process/css/integral.css similarity index 100% rename from test/options/integral/integral.css rename to test/options/integral/process/css/integral.css diff --git a/test/options/integral/integral.expected.css b/test/options/integral/process/css/integral.expected.css similarity index 100% rename from test/options/integral/integral.expected.css rename to test/options/integral/process/css/integral.expected.css diff --git a/test/options/integral/issue-252.expected.sass b/test/options/integral/process/css/issue-252.expected.sass similarity index 100% rename from test/options/integral/issue-252.expected.sass rename to test/options/integral/process/css/issue-252.expected.sass diff --git a/test/options/integral/issue-252.sass b/test/options/integral/process/css/issue-252.sass similarity index 100% rename from test/options/integral/issue-252.sass rename to test/options/integral/process/css/issue-252.sass diff --git a/test/options/integral/issue-374.css b/test/options/integral/process/css/issue-374.css similarity index 100% rename from test/options/integral/issue-374.css rename to test/options/integral/process/css/issue-374.css diff --git a/test/options/integral/test.js b/test/options/integral/process/test.js similarity index 96% rename from test/options/integral/test.js rename to test/options/integral/process/test.js index ebd95b2b..16e1c28d 100644 --- a/test/options/integral/test.js +++ b/test/options/integral/process/test.js @@ -1,4 +1,4 @@ -describe('integral test', function() { +describe.skip('integral test', function() { describe('process', function() { it('Process result must be equal to expected.css', function() { var config = this.Comb.getConfig('csscomb'); diff --git a/test/options/leading-zero/test.js b/test/options/leading-zero/process/test.js similarity index 96% rename from test/options/leading-zero/test.js rename to test/options/leading-zero/process/test.js index 84fb0a8c..74348907 100644 --- a/test/options/leading-zero/test.js +++ b/test/options/leading-zero/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/leading-zero', function() { +describe.skip('options/leading-zero', function() { describe('process', function() { it('Should add leading zero in dimensions', function() { this.comb.configure({ 'leading-zero': true }); diff --git a/test/options/quotes/test.js b/test/options/quotes/process/test.js similarity index 98% rename from test/options/quotes/test.js rename to test/options/quotes/process/test.js index 00b1fde9..e79bfcd1 100644 --- a/test/options/quotes/test.js +++ b/test/options/quotes/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/quotes', function() { +describe.skip('options/quotes', function() { describe('process', function() { it('Invalid String should not change quotes', function() { this.comb.configure({ quotes: 3 }); diff --git a/test/options/remove-empty-rulesets-less/1.expected.less b/test/options/remove-empty-rulesets/process/less/1.expected.less similarity index 100% rename from test/options/remove-empty-rulesets-less/1.expected.less rename to test/options/remove-empty-rulesets/process/less/1.expected.less diff --git a/test/options/remove-empty-rulesets-less/1.less b/test/options/remove-empty-rulesets/process/less/1.less similarity index 100% rename from test/options/remove-empty-rulesets-less/1.less rename to test/options/remove-empty-rulesets/process/less/1.less diff --git a/test/options/remove-empty-rulesets-less/test.js b/test/options/remove-empty-rulesets/process/less/test.js similarity index 93% rename from test/options/remove-empty-rulesets-less/test.js rename to test/options/remove-empty-rulesets/process/less/test.js index b4e52071..28001e80 100644 --- a/test/options/remove-empty-rulesets-less/test.js +++ b/test/options/remove-empty-rulesets/process/less/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/remove-empty-rulesets (less):', function() { +describe.skip('options/remove-empty-rulesets (less):', function() { describe('process', function() { it('Issue 201. Test 1', function() { this.comb.configure({ 'remove-empty-rulesets': true }); diff --git a/test/options/remove-empty-rulesets-scss/empty-nested-rule.expected.scss b/test/options/remove-empty-rulesets/process/scss/empty-nested-rule.expected.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/empty-nested-rule.expected.scss rename to test/options/remove-empty-rulesets/process/scss/empty-nested-rule.expected.scss diff --git a/test/options/remove-empty-rulesets-scss/empty-nested-rule.scss b/test/options/remove-empty-rulesets/process/scss/empty-nested-rule.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/empty-nested-rule.scss rename to test/options/remove-empty-rulesets/process/scss/empty-nested-rule.scss diff --git a/test/options/remove-empty-rulesets-scss/include.scss b/test/options/remove-empty-rulesets/process/scss/include.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/include.scss rename to test/options/remove-empty-rulesets/process/scss/include.scss diff --git a/test/options/remove-empty-rulesets-scss/nested-rule-1.scss b/test/options/remove-empty-rulesets/process/scss/nested-rule-1.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/nested-rule-1.scss rename to test/options/remove-empty-rulesets/process/scss/nested-rule-1.scss diff --git a/test/options/remove-empty-rulesets-scss/nested-rule-2.expected.scss b/test/options/remove-empty-rulesets/process/scss/nested-rule-2.expected.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/nested-rule-2.expected.scss rename to test/options/remove-empty-rulesets/process/scss/nested-rule-2.expected.scss diff --git a/test/options/remove-empty-rulesets-scss/nested-rule-2.scss b/test/options/remove-empty-rulesets/process/scss/nested-rule-2.scss similarity index 100% rename from test/options/remove-empty-rulesets-scss/nested-rule-2.scss rename to test/options/remove-empty-rulesets/process/scss/nested-rule-2.scss diff --git a/test/options/remove-empty-rulesets-scss/test.js b/test/options/remove-empty-rulesets/process/scss/test.js similarity index 92% rename from test/options/remove-empty-rulesets-scss/test.js rename to test/options/remove-empty-rulesets/process/scss/test.js index dae5e8ff..ae74b099 100644 --- a/test/options/remove-empty-rulesets-scss/test.js +++ b/test/options/remove-empty-rulesets/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/remove-empty-rulesets (scss)', function() { +describe.skip('options/remove-empty-rulesets (scss)', function() { beforeEach(function() { this.comb.configure({ 'remove-empty-rulesets': true }); }); diff --git a/test/options/remove-empty-rulesets/test.js b/test/options/remove-empty-rulesets/process/test.js similarity index 98% rename from test/options/remove-empty-rulesets/test.js rename to test/options/remove-empty-rulesets/process/test.js index ba5598a8..bcaf073d 100644 --- a/test/options/remove-empty-rulesets/test.js +++ b/test/options/remove-empty-rulesets/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/remove-empty-rulesets', function() { +describe.skip('options/remove-empty-rulesets', function() { describe('process', function() { it('Configured with invalid value, should not remove empty ruleset', function() { this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); diff --git a/test/options/sass/content.sass b/test/options/sass/content.sass deleted file mode 100644 index e1bb2b99..00000000 --- a/test/options/sass/content.sass +++ /dev/null @@ -1,3 +0,0 @@ -@mixin nani - a - @content diff --git a/test/options/sass/default.sass b/test/options/sass/default.sass deleted file mode 100644 index 3c10834e..00000000 --- a/test/options/sass/default.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - $color: tomato !default - top: 0 diff --git a/test/options/sass/each.sass b/test/options/sass/each.sass deleted file mode 100644 index 477c5de0..00000000 --- a/test/options/sass/each.sass +++ /dev/null @@ -1,4 +0,0 @@ -div - @each $animal in puma, sea-slug, erget - .#{$animal}-icon - background-image: url("/images/#{$animal}.png") diff --git a/test/options/sass/extend-1.sass b/test/options/sass/extend-1.sass deleted file mode 100644 index ef4beac5..00000000 --- a/test/options/sass/extend-1.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @extend .nani - top: 0 diff --git a/test/options/sass/extend-2.sass b/test/options/sass/extend-2.sass deleted file mode 100644 index 8da2b0d2..00000000 --- a/test/options/sass/extend-2.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @extend %nani - top: 0 diff --git a/test/options/sass/for.sass b/test/options/sass/for.sass deleted file mode 100644 index 9449c473..00000000 --- a/test/options/sass/for.sass +++ /dev/null @@ -1,4 +0,0 @@ -div - @for $i from 1 through 3 - .item-#{$i} - width: 2em * 1 diff --git a/test/options/sass/function.sass b/test/options/sass/function.sass deleted file mode 100644 index 33901cb6..00000000 --- a/test/options/sass/function.sass +++ /dev/null @@ -1,2 +0,0 @@ -@function nani($n) - @return $n * 2 diff --git a/test/options/sass/if-else-if.sass b/test/options/sass/if-else-if.sass deleted file mode 100644 index 91648b8f..00000000 --- a/test/options/sass/if-else-if.sass +++ /dev/null @@ -1,5 +0,0 @@ -div - @if $type == ocean - top: 0 - @else if $type == monster - left: 0 diff --git a/test/options/sass/if-else.sass b/test/options/sass/if-else.sass deleted file mode 100644 index 2863d4d3..00000000 --- a/test/options/sass/if-else.sass +++ /dev/null @@ -1,5 +0,0 @@ -div - @if $type == ocean - top: 0 - @else - left: 0 diff --git a/test/options/sass/if.sass b/test/options/sass/if.sass deleted file mode 100644 index ab29f15a..00000000 --- a/test/options/sass/if.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @if $type == ocean - top: 0 diff --git a/test/options/sass/import.sass b/test/options/sass/import.sass deleted file mode 100644 index ed472085..00000000 --- a/test/options/sass/import.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @import "foo.css" - top: 0 diff --git a/test/options/sass/include.sass b/test/options/sass/include.sass deleted file mode 100644 index 3b753a71..00000000 --- a/test/options/sass/include.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @include nani($panda) - top: 0 diff --git a/test/options/sass/interpolated-variable-1.sass b/test/options/sass/interpolated-variable-1.sass deleted file mode 100644 index 3ba50e54..00000000 --- a/test/options/sass/interpolated-variable-1.sass +++ /dev/null @@ -1,3 +0,0 @@ -div.#{$nani} - color: tomato - top:0 diff --git a/test/options/sass/interpolated-variable-2.sass b/test/options/sass/interpolated-variable-2.sass deleted file mode 100644 index 3f134b4d..00000000 --- a/test/options/sass/interpolated-variable-2.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - color: #{$tomato} - top: 0 diff --git a/test/options/sass/mixin-1.sass b/test/options/sass/mixin-1.sass deleted file mode 100644 index f633d80c..00000000 --- a/test/options/sass/mixin-1.sass +++ /dev/null @@ -1,4 +0,0 @@ -@mixin nani - color: tomato -.foo - @include nani diff --git a/test/options/sass/mixin-2.sass b/test/options/sass/mixin-2.sass deleted file mode 100644 index 0e3513ef..00000000 --- a/test/options/sass/mixin-2.sass +++ /dev/null @@ -1,4 +0,0 @@ -@mixin nani($tomato) - color: $tomato -.foo - @include nani(red) diff --git a/test/options/sass/mixin-3.sass b/test/options/sass/mixin-3.sass deleted file mode 100644 index cf20ed5a..00000000 --- a/test/options/sass/mixin-3.sass +++ /dev/null @@ -1,4 +0,0 @@ -@mixin nani($shadows...) - box-shadow: $shadows -.foo - @include nani(0px 4px 5px #666, 2px 6px 10px #999) diff --git a/test/options/sass/mixin-4.sass b/test/options/sass/mixin-4.sass deleted file mode 100644 index d22987c8..00000000 --- a/test/options/sass/mixin-4.sass +++ /dev/null @@ -1,4 +0,0 @@ -.foo - @include nani - color: tomato - top: 0 diff --git a/test/options/sass/nested-media.sass b/test/options/sass/nested-media.sass deleted file mode 100644 index 244755fa..00000000 --- a/test/options/sass/nested-media.sass +++ /dev/null @@ -1,4 +0,0 @@ -div - @media screen and (orientation: landscape) - color: tomato - top: 0 diff --git a/test/options/sass/nested-property.sass b/test/options/sass/nested-property.sass deleted file mode 100644 index 84af6547..00000000 --- a/test/options/sass/nested-property.sass +++ /dev/null @@ -1,6 +0,0 @@ -div - color: tomato - font: 2px/3px - family: fantasy - size: 30em - left: 0 diff --git a/test/options/sass/nested-rule.sass b/test/options/sass/nested-rule.sass deleted file mode 100644 index 8e909137..00000000 --- a/test/options/sass/nested-rule.sass +++ /dev/null @@ -1,4 +0,0 @@ -div - color: tomato - a - top: 0 diff --git a/test/options/sass/parent-selector.sass b/test/options/sass/parent-selector.sass deleted file mode 100644 index 388fecdf..00000000 --- a/test/options/sass/parent-selector.sass +++ /dev/null @@ -1,6 +0,0 @@ -div - color: tomato - &.top - color: nani - top: 0 - left: 0 diff --git a/test/options/sass/test.js b/test/options/sass/test.js deleted file mode 100644 index 49654e3c..00000000 --- a/test/options/sass/test.js +++ /dev/null @@ -1,109 +0,0 @@ -describe('Sass', function() { - beforeEach(function() { - this.comb.configure({}); - }); - - describe('process', function() { - it('Should parse nested rules', function() { - return this.shouldBeEqual('nested-rule.sass'); - }); - - it('Should parse parent selector &', function() { - return this.shouldBeEqual('parent-selector.sass'); - }); - - it('Should parse nested properties', function() { - return this.shouldBeEqual('nested-property.sass'); - }); - - it('Should parse variables', function() { - return this.shouldBeEqual('variable.sass'); - }); - - it('Should parse interpolated variables inside selectors', function() { - return this.shouldBeEqual('interpolated-variable-1.sass'); - }); - - it('Should parse interpolated variables inside values', function() { - return this.shouldBeEqual('interpolated-variable-2.sass'); - }); - - it('Should parse defaults', function() { - return this.shouldBeEqual('default.sass'); - }); - - it('Should parse @import', function() { - return this.shouldBeEqual('import.sass'); - }); - - it('Should parse @include', function() { - return this.shouldBeEqual('include.sass'); - }); - - it('Should parse nested @media', function() { - return this.shouldBeEqual('nested-media.sass'); - }); - - it('Should parse @extend with classes', function() { - return this.shouldBeEqual('extend-1.sass'); - }); - - it('Should parse @extend with placeholders', function() { - return this.shouldBeEqual('extend-2.sass'); - }); - - it('Should parse @warn', function() { - return this.shouldBeEqual('warn.sass'); - }); - - it('Should parse @if', function() { - return this.shouldBeEqual('if.sass'); - }); - - it('Should parse @if and @else', function() { - return this.shouldBeEqual('if-else.sass'); - }); - - it('Should parse @if and @else if', function() { - return this.shouldBeEqual('if-else-if.sass'); - }); - - it('Should parse @for', function() { - return this.shouldBeEqual('for.sass'); - }); - - it('Should parse @each', function() { - return this.shouldBeEqual('each.sass'); - }); - - it('Should parse @while', function() { - return this.shouldBeEqual('while.sass'); - }); - - it('Should parse mixins', function() { - return this.shouldBeEqual('mixin-1.sass'); - }); - - it('Should parse passing several variables to a mixin', function() { - return this.shouldBeEqual('mixin-2.sass'); - }); - - it('Should parse passing a list of variables to a mixin', function() { - return this.shouldBeEqual('mixin-3.sass'); - }); - - it('Should parse passing a content block to a mixin', function() { - return this.shouldBeEqual('mixin-4.sass'); - }); - - it('Should parse @content', function() { - return this.shouldBeEqual('content.sass'); - }); - - it('Should parse functions', function() { - return this.shouldBeEqual('function.sass'); - }); - }); -}); - - diff --git a/test/options/sass/variable.sass b/test/options/sass/variable.sass deleted file mode 100644 index 24f437d2..00000000 --- a/test/options/sass/variable.sass +++ /dev/null @@ -1,3 +0,0 @@ -$red: tomato -div - color: $tomato diff --git a/test/options/sass/warn.sass b/test/options/sass/warn.sass deleted file mode 100644 index ebf821b2..00000000 --- a/test/options/sass/warn.sass +++ /dev/null @@ -1,3 +0,0 @@ -div - @warn "nani" - top: 0 diff --git a/test/options/sass/while.sass b/test/options/sass/while.sass deleted file mode 100644 index 8b07b31f..00000000 --- a/test/options/sass/while.sass +++ /dev/null @@ -1,5 +0,0 @@ -div - @while $i > 6 - .item - width: 2em * $i - $i: $i - 2 diff --git a/test/options/sort-order-fallback/test-2.expected.css b/test/options/sort-order-fallback/process/css/test-2.expected.css similarity index 100% rename from test/options/sort-order-fallback/test-2.expected.css rename to test/options/sort-order-fallback/process/css/test-2.expected.css diff --git a/test/options/sort-order-fallback/test-3.expected.css b/test/options/sort-order-fallback/process/css/test-3.expected.css similarity index 100% rename from test/options/sort-order-fallback/test-3.expected.css rename to test/options/sort-order-fallback/process/css/test-3.expected.css diff --git a/test/options/sort-order-fallback/test.css b/test/options/sort-order-fallback/process/css/test.css similarity index 100% rename from test/options/sort-order-fallback/test.css rename to test/options/sort-order-fallback/process/css/test.css diff --git a/test/options/sort-order-fallback/test.expected.css b/test/options/sort-order-fallback/process/css/test.expected.css similarity index 100% rename from test/options/sort-order-fallback/test.expected.css rename to test/options/sort-order-fallback/process/css/test.expected.css diff --git a/test/options/sort-order-fallback/test.js b/test/options/sort-order-fallback/process/test.js similarity index 95% rename from test/options/sort-order-fallback/test.js rename to test/options/sort-order-fallback/process/test.js index 4f9ef128..a869e42a 100644 --- a/test/options/sort-order-fallback/test.js +++ b/test/options/sort-order-fallback/process/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order-fallback', function() { +describe.skip('options/sort-order-fallback', function() { describe('process', function() { it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { var config = { diff --git a/test/options/sort-order/data-uri.css b/test/options/sort-order/process/css/data-uri.css similarity index 100% rename from test/options/sort-order/data-uri.css rename to test/options/sort-order/process/css/data-uri.css diff --git a/test/options/sort-order/data-uri.expected.css b/test/options/sort-order/process/css/data-uri.expected.css similarity index 100% rename from test/options/sort-order/data-uri.expected.css rename to test/options/sort-order/process/css/data-uri.expected.css diff --git a/test/options/sort-order/issue-94-1.css b/test/options/sort-order/process/css/issue-94-1.css similarity index 100% rename from test/options/sort-order/issue-94-1.css rename to test/options/sort-order/process/css/issue-94-1.css diff --git a/test/options/sort-order/issue-94-1.expected.css b/test/options/sort-order/process/css/issue-94-1.expected.css similarity index 100% rename from test/options/sort-order/issue-94-1.expected.css rename to test/options/sort-order/process/css/issue-94-1.expected.css diff --git a/test/options/sort-order/issue-94-2.css b/test/options/sort-order/process/css/issue-94-2.css similarity index 100% rename from test/options/sort-order/issue-94-2.css rename to test/options/sort-order/process/css/issue-94-2.css diff --git a/test/options/sort-order/issue-94-2.expected.css b/test/options/sort-order/process/css/issue-94-2.expected.css similarity index 100% rename from test/options/sort-order/issue-94-2.expected.css rename to test/options/sort-order/process/css/issue-94-2.expected.css diff --git a/test/options/sort-order/issue-94-3.css b/test/options/sort-order/process/css/issue-94-3.css similarity index 100% rename from test/options/sort-order/issue-94-3.css rename to test/options/sort-order/process/css/issue-94-3.css diff --git a/test/options/sort-order/issue-94-3.expected.css b/test/options/sort-order/process/css/issue-94-3.expected.css similarity index 100% rename from test/options/sort-order/issue-94-3.expected.css rename to test/options/sort-order/process/css/issue-94-3.expected.css diff --git a/test/options/sort-order/leftovers-1.css b/test/options/sort-order/process/css/leftovers-1.css similarity index 100% rename from test/options/sort-order/leftovers-1.css rename to test/options/sort-order/process/css/leftovers-1.css diff --git a/test/options/sort-order/leftovers-1.expected.css b/test/options/sort-order/process/css/leftovers-1.expected.css similarity index 100% rename from test/options/sort-order/leftovers-1.expected.css rename to test/options/sort-order/process/css/leftovers-1.expected.css diff --git a/test/options/sort-order/leftovers-2.css b/test/options/sort-order/process/css/leftovers-2.css similarity index 100% rename from test/options/sort-order/leftovers-2.css rename to test/options/sort-order/process/css/leftovers-2.css diff --git a/test/options/sort-order/leftovers-2.expected.css b/test/options/sort-order/process/css/leftovers-2.expected.css similarity index 100% rename from test/options/sort-order/leftovers-2.expected.css rename to test/options/sort-order/process/css/leftovers-2.expected.css diff --git a/test/options/sort-order/leftovers-3.css b/test/options/sort-order/process/css/leftovers-3.css similarity index 100% rename from test/options/sort-order/leftovers-3.css rename to test/options/sort-order/process/css/leftovers-3.css diff --git a/test/options/sort-order/leftovers-3.expected.css b/test/options/sort-order/process/css/leftovers-3.expected.css similarity index 100% rename from test/options/sort-order/leftovers-3.expected.css rename to test/options/sort-order/process/css/leftovers-3.expected.css diff --git a/test/options/sort-order/leftovers-4.css b/test/options/sort-order/process/css/leftovers-4.css similarity index 100% rename from test/options/sort-order/leftovers-4.css rename to test/options/sort-order/process/css/leftovers-4.css diff --git a/test/options/sort-order/leftovers-4.expected.css b/test/options/sort-order/process/css/leftovers-4.expected.css similarity index 100% rename from test/options/sort-order/leftovers-4.expected.css rename to test/options/sort-order/process/css/leftovers-4.expected.css diff --git a/test/options/sort-order/missing-delimiter.css b/test/options/sort-order/process/css/missing-delimiter.css similarity index 100% rename from test/options/sort-order/missing-delimiter.css rename to test/options/sort-order/process/css/missing-delimiter.css diff --git a/test/options/sort-order/missing-delimiter.expected.css b/test/options/sort-order/process/css/missing-delimiter.expected.css similarity index 100% rename from test/options/sort-order/missing-delimiter.expected.css rename to test/options/sort-order/process/css/missing-delimiter.expected.css diff --git a/test/options/sort-order/multiple-groups-2.css b/test/options/sort-order/process/css/multiple-groups-2.css similarity index 100% rename from test/options/sort-order/multiple-groups-2.css rename to test/options/sort-order/process/css/multiple-groups-2.css diff --git a/test/options/sort-order/multiple-groups-2.expected.css b/test/options/sort-order/process/css/multiple-groups-2.expected.css similarity index 100% rename from test/options/sort-order/multiple-groups-2.expected.css rename to test/options/sort-order/process/css/multiple-groups-2.expected.css diff --git a/test/options/sort-order/multiple-groups-comments.css b/test/options/sort-order/process/css/multiple-groups-comments.css similarity index 100% rename from test/options/sort-order/multiple-groups-comments.css rename to test/options/sort-order/process/css/multiple-groups-comments.css diff --git a/test/options/sort-order/multiple-groups-comments.expected.css b/test/options/sort-order/process/css/multiple-groups-comments.expected.css similarity index 100% rename from test/options/sort-order/multiple-groups-comments.expected.css rename to test/options/sort-order/process/css/multiple-groups-comments.expected.css diff --git a/test/options/sort-order/multiple-groups.css b/test/options/sort-order/process/css/multiple-groups.css similarity index 100% rename from test/options/sort-order/multiple-groups.css rename to test/options/sort-order/process/css/multiple-groups.css diff --git a/test/options/sort-order/multiple-groups.expected.css b/test/options/sort-order/process/css/multiple-groups.expected.css similarity index 100% rename from test/options/sort-order/multiple-groups.expected.css rename to test/options/sort-order/process/css/multiple-groups.expected.css diff --git a/test/options/sort-order/single-group-comments.css b/test/options/sort-order/process/css/single-group-comments.css similarity index 100% rename from test/options/sort-order/single-group-comments.css rename to test/options/sort-order/process/css/single-group-comments.css diff --git a/test/options/sort-order/single-group-comments.expected.css b/test/options/sort-order/process/css/single-group-comments.expected.css similarity index 100% rename from test/options/sort-order/single-group-comments.expected.css rename to test/options/sort-order/process/css/single-group-comments.expected.css diff --git a/test/options/sort-order/single-group.css b/test/options/sort-order/process/css/single-group.css similarity index 100% rename from test/options/sort-order/single-group.css rename to test/options/sort-order/process/css/single-group.css diff --git a/test/options/sort-order/single-group.expected.css b/test/options/sort-order/process/css/single-group.expected.css similarity index 100% rename from test/options/sort-order/single-group.expected.css rename to test/options/sort-order/process/css/single-group.expected.css diff --git a/test/options/sort-order-less/comments-1.expected.less b/test/options/sort-order/process/less/comments-1.expected.less similarity index 100% rename from test/options/sort-order-less/comments-1.expected.less rename to test/options/sort-order/process/less/comments-1.expected.less diff --git a/test/options/sort-order-less/comments-1.less b/test/options/sort-order/process/less/comments-1.less similarity index 100% rename from test/options/sort-order-less/comments-1.less rename to test/options/sort-order/process/less/comments-1.less diff --git a/test/options/sort-order-less/comments-2.expected.less b/test/options/sort-order/process/less/comments-2.expected.less similarity index 100% rename from test/options/sort-order-less/comments-2.expected.less rename to test/options/sort-order/process/less/comments-2.expected.less diff --git a/test/options/sort-order-less/comments-2.less b/test/options/sort-order/process/less/comments-2.less similarity index 100% rename from test/options/sort-order-less/comments-2.less rename to test/options/sort-order/process/less/comments-2.less diff --git a/test/options/sort-order-less/comments-3.expected.less b/test/options/sort-order/process/less/comments-3.expected.less similarity index 100% rename from test/options/sort-order-less/comments-3.expected.less rename to test/options/sort-order/process/less/comments-3.expected.less diff --git a/test/options/sort-order-less/comments-3.less b/test/options/sort-order/process/less/comments-3.less similarity index 100% rename from test/options/sort-order-less/comments-3.less rename to test/options/sort-order/process/less/comments-3.less diff --git a/test/options/sort-order-less/comments-4.expected.less b/test/options/sort-order/process/less/comments-4.expected.less similarity index 100% rename from test/options/sort-order-less/comments-4.expected.less rename to test/options/sort-order/process/less/comments-4.expected.less diff --git a/test/options/sort-order-less/comments-4.less b/test/options/sort-order/process/less/comments-4.less similarity index 100% rename from test/options/sort-order-less/comments-4.less rename to test/options/sort-order/process/less/comments-4.less diff --git a/test/options/sort-order-less/different-groups.expected.less b/test/options/sort-order/process/less/different-groups.expected.less similarity index 100% rename from test/options/sort-order-less/different-groups.expected.less rename to test/options/sort-order/process/less/different-groups.expected.less diff --git a/test/options/sort-order-less/different-groups.less b/test/options/sort-order/process/less/different-groups.less similarity index 100% rename from test/options/sort-order-less/different-groups.less rename to test/options/sort-order/process/less/different-groups.less diff --git a/test/options/sort-order-less/extend.expected.less b/test/options/sort-order/process/less/extend.expected.less similarity index 100% rename from test/options/sort-order-less/extend.expected.less rename to test/options/sort-order/process/less/extend.expected.less diff --git a/test/options/sort-order-less/extend.less b/test/options/sort-order/process/less/extend.less similarity index 100% rename from test/options/sort-order-less/extend.less rename to test/options/sort-order/process/less/extend.less diff --git a/test/options/sort-order-less/import.expected.less b/test/options/sort-order/process/less/import.expected.less similarity index 100% rename from test/options/sort-order-less/import.expected.less rename to test/options/sort-order/process/less/import.expected.less diff --git a/test/options/sort-order-less/import.less b/test/options/sort-order/process/less/import.less similarity index 100% rename from test/options/sort-order-less/import.less rename to test/options/sort-order/process/less/import.less diff --git a/test/options/sort-order-less/mixin-1.expected.less b/test/options/sort-order/process/less/mixin-1.expected.less similarity index 100% rename from test/options/sort-order-less/mixin-1.expected.less rename to test/options/sort-order/process/less/mixin-1.expected.less diff --git a/test/options/sort-order-less/mixin-1.less b/test/options/sort-order/process/less/mixin-1.less similarity index 100% rename from test/options/sort-order-less/mixin-1.less rename to test/options/sort-order/process/less/mixin-1.less diff --git a/test/options/sort-order-less/mixin-2.expected.less b/test/options/sort-order/process/less/mixin-2.expected.less similarity index 100% rename from test/options/sort-order-less/mixin-2.expected.less rename to test/options/sort-order/process/less/mixin-2.expected.less diff --git a/test/options/sort-order-less/mixin-2.less b/test/options/sort-order/process/less/mixin-2.less similarity index 100% rename from test/options/sort-order-less/mixin-2.less rename to test/options/sort-order/process/less/mixin-2.less diff --git a/test/options/sort-order-less/mixin-3.expected.less b/test/options/sort-order/process/less/mixin-3.expected.less similarity index 100% rename from test/options/sort-order-less/mixin-3.expected.less rename to test/options/sort-order/process/less/mixin-3.expected.less diff --git a/test/options/sort-order-less/mixin-3.less b/test/options/sort-order/process/less/mixin-3.less similarity index 100% rename from test/options/sort-order-less/mixin-3.less rename to test/options/sort-order/process/less/mixin-3.less diff --git a/test/options/sort-order-less/mixin-4.expected.less b/test/options/sort-order/process/less/mixin-4.expected.less similarity index 100% rename from test/options/sort-order-less/mixin-4.expected.less rename to test/options/sort-order/process/less/mixin-4.expected.less diff --git a/test/options/sort-order-less/mixin-4.less b/test/options/sort-order/process/less/mixin-4.less similarity index 100% rename from test/options/sort-order-less/mixin-4.less rename to test/options/sort-order/process/less/mixin-4.less diff --git a/test/options/sort-order-less/nested-rule-1.expected.less b/test/options/sort-order/process/less/nested-rule-1.expected.less similarity index 100% rename from test/options/sort-order-less/nested-rule-1.expected.less rename to test/options/sort-order/process/less/nested-rule-1.expected.less diff --git a/test/options/sort-order-less/nested-rule-1.less b/test/options/sort-order/process/less/nested-rule-1.less similarity index 100% rename from test/options/sort-order-less/nested-rule-1.less rename to test/options/sort-order/process/less/nested-rule-1.less diff --git a/test/options/sort-order-less/nested-rule-2.expected.less b/test/options/sort-order/process/less/nested-rule-2.expected.less similarity index 100% rename from test/options/sort-order-less/nested-rule-2.expected.less rename to test/options/sort-order/process/less/nested-rule-2.expected.less diff --git a/test/options/sort-order-less/nested-rule-2.less b/test/options/sort-order/process/less/nested-rule-2.less similarity index 100% rename from test/options/sort-order-less/nested-rule-2.less rename to test/options/sort-order/process/less/nested-rule-2.less diff --git a/test/options/sort-order-less/rule.expected.less b/test/options/sort-order/process/less/rule.expected.less similarity index 100% rename from test/options/sort-order-less/rule.expected.less rename to test/options/sort-order/process/less/rule.expected.less diff --git a/test/options/sort-order-less/rule.less b/test/options/sort-order/process/less/rule.less similarity index 100% rename from test/options/sort-order-less/rule.less rename to test/options/sort-order/process/less/rule.less diff --git a/test/options/sort-order-less/test.js b/test/options/sort-order/process/less/test.js similarity index 98% rename from test/options/sort-order-less/test.js rename to test/options/sort-order/process/less/test.js index 16b2f111..7c201127 100644 --- a/test/options/sort-order-less/test.js +++ b/test/options/sort-order/process/less/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (less)', function() { +describe.skip('options/sort-order (less)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-less/variable.expected.less b/test/options/sort-order/process/less/variable.expected.less similarity index 100% rename from test/options/sort-order-less/variable.expected.less rename to test/options/sort-order/process/less/variable.expected.less diff --git a/test/options/sort-order-less/variable.less b/test/options/sort-order/process/less/variable.less similarity index 100% rename from test/options/sort-order-less/variable.less rename to test/options/sort-order/process/less/variable.less diff --git a/test/options/sort-order-sass/comments.expected.sass b/test/options/sort-order/process/sass/comments.expected.sass similarity index 100% rename from test/options/sort-order-sass/comments.expected.sass rename to test/options/sort-order/process/sass/comments.expected.sass diff --git a/test/options/sort-order-sass/comments.sass b/test/options/sort-order/process/sass/comments.sass similarity index 100% rename from test/options/sort-order-sass/comments.sass rename to test/options/sort-order/process/sass/comments.sass diff --git a/test/options/sort-order-sass/condition.expected.sass b/test/options/sort-order/process/sass/condition.expected.sass similarity index 100% rename from test/options/sort-order-sass/condition.expected.sass rename to test/options/sort-order/process/sass/condition.expected.sass diff --git a/test/options/sort-order-sass/condition.sass b/test/options/sort-order/process/sass/condition.sass similarity index 100% rename from test/options/sort-order-sass/condition.sass rename to test/options/sort-order/process/sass/condition.sass diff --git a/test/options/sort-order-sass/different-groups.expected.sass b/test/options/sort-order/process/sass/different-groups.expected.sass similarity index 100% rename from test/options/sort-order-sass/different-groups.expected.sass rename to test/options/sort-order/process/sass/different-groups.expected.sass diff --git a/test/options/sort-order-sass/different-groups.sass b/test/options/sort-order/process/sass/different-groups.sass similarity index 100% rename from test/options/sort-order-sass/different-groups.sass rename to test/options/sort-order/process/sass/different-groups.sass diff --git a/test/options/sort-order-sass/extend.expected.sass b/test/options/sort-order/process/sass/extend.expected.sass similarity index 100% rename from test/options/sort-order-sass/extend.expected.sass rename to test/options/sort-order/process/sass/extend.expected.sass diff --git a/test/options/sort-order-sass/extend.sass b/test/options/sort-order/process/sass/extend.sass similarity index 100% rename from test/options/sort-order-sass/extend.sass rename to test/options/sort-order/process/sass/extend.sass diff --git a/test/options/sort-order-sass/import.expected.sass b/test/options/sort-order/process/sass/import.expected.sass similarity index 100% rename from test/options/sort-order-sass/import.expected.sass rename to test/options/sort-order/process/sass/import.expected.sass diff --git a/test/options/sort-order-sass/import.sass b/test/options/sort-order/process/sass/import.sass similarity index 100% rename from test/options/sort-order-sass/import.sass rename to test/options/sort-order/process/sass/import.sass diff --git a/test/options/sort-order-sass/include-specified-1.expected.sass b/test/options/sort-order/process/sass/include-specified-1.expected.sass similarity index 100% rename from test/options/sort-order-sass/include-specified-1.expected.sass rename to test/options/sort-order/process/sass/include-specified-1.expected.sass diff --git a/test/options/sort-order-sass/include-specified-1.sass b/test/options/sort-order/process/sass/include-specified-1.sass similarity index 100% rename from test/options/sort-order-sass/include-specified-1.sass rename to test/options/sort-order/process/sass/include-specified-1.sass diff --git a/test/options/sort-order-sass/include-specified-2.expected.sass b/test/options/sort-order/process/sass/include-specified-2.expected.sass similarity index 100% rename from test/options/sort-order-sass/include-specified-2.expected.sass rename to test/options/sort-order/process/sass/include-specified-2.expected.sass diff --git a/test/options/sort-order-sass/include-specified-2.sass b/test/options/sort-order/process/sass/include-specified-2.sass similarity index 100% rename from test/options/sort-order-sass/include-specified-2.sass rename to test/options/sort-order/process/sass/include-specified-2.sass diff --git a/test/options/sort-order-sass/include.expected.sass b/test/options/sort-order/process/sass/include.expected.sass similarity index 100% rename from test/options/sort-order-sass/include.expected.sass rename to test/options/sort-order/process/sass/include.expected.sass diff --git a/test/options/sort-order-sass/include.sass b/test/options/sort-order/process/sass/include.sass similarity index 100% rename from test/options/sort-order-sass/include.sass rename to test/options/sort-order/process/sass/include.sass diff --git a/test/options/sort-order-sass/issue-332-2.expected.sass b/test/options/sort-order/process/sass/issue-332-2.expected.sass similarity index 100% rename from test/options/sort-order-sass/issue-332-2.expected.sass rename to test/options/sort-order/process/sass/issue-332-2.expected.sass diff --git a/test/options/sort-order-sass/issue-332-2.sass b/test/options/sort-order/process/sass/issue-332-2.sass similarity index 100% rename from test/options/sort-order-sass/issue-332-2.sass rename to test/options/sort-order/process/sass/issue-332-2.sass diff --git a/test/options/sort-order-sass/issue-332.expected.sass b/test/options/sort-order/process/sass/issue-332.expected.sass similarity index 100% rename from test/options/sort-order-sass/issue-332.expected.sass rename to test/options/sort-order/process/sass/issue-332.expected.sass diff --git a/test/options/sort-order-sass/issue-332.sass b/test/options/sort-order/process/sass/issue-332.sass similarity index 100% rename from test/options/sort-order-sass/issue-332.sass rename to test/options/sort-order/process/sass/issue-332.sass diff --git a/test/options/sort-order-sass/mixin.expected.sass b/test/options/sort-order/process/sass/mixin.expected.sass similarity index 100% rename from test/options/sort-order-sass/mixin.expected.sass rename to test/options/sort-order/process/sass/mixin.expected.sass diff --git a/test/options/sort-order-sass/mixin.sass b/test/options/sort-order/process/sass/mixin.sass similarity index 100% rename from test/options/sort-order-sass/mixin.sass rename to test/options/sort-order/process/sass/mixin.sass diff --git a/test/options/sort-order-sass/nested-rule-1.expected.sass b/test/options/sort-order/process/sass/nested-rule-1.expected.sass similarity index 100% rename from test/options/sort-order-sass/nested-rule-1.expected.sass rename to test/options/sort-order/process/sass/nested-rule-1.expected.sass diff --git a/test/options/sort-order-sass/nested-rule-1.sass b/test/options/sort-order/process/sass/nested-rule-1.sass similarity index 100% rename from test/options/sort-order-sass/nested-rule-1.sass rename to test/options/sort-order/process/sass/nested-rule-1.sass diff --git a/test/options/sort-order-sass/nested-rule-2.expected.sass b/test/options/sort-order/process/sass/nested-rule-2.expected.sass similarity index 100% rename from test/options/sort-order-sass/nested-rule-2.expected.sass rename to test/options/sort-order/process/sass/nested-rule-2.expected.sass diff --git a/test/options/sort-order-sass/nested-rule-2.sass b/test/options/sort-order/process/sass/nested-rule-2.sass similarity index 100% rename from test/options/sort-order-sass/nested-rule-2.sass rename to test/options/sort-order/process/sass/nested-rule-2.sass diff --git a/test/options/sort-order-sass/rule.expected.sass b/test/options/sort-order/process/sass/rule.expected.sass similarity index 100% rename from test/options/sort-order-sass/rule.expected.sass rename to test/options/sort-order/process/sass/rule.expected.sass diff --git a/test/options/sort-order-sass/rule.sass b/test/options/sort-order/process/sass/rule.sass similarity index 100% rename from test/options/sort-order-sass/rule.sass rename to test/options/sort-order/process/sass/rule.sass diff --git a/test/options/sort-order-sass/ruleset.expected.sass b/test/options/sort-order/process/sass/ruleset.expected.sass similarity index 100% rename from test/options/sort-order-sass/ruleset.expected.sass rename to test/options/sort-order/process/sass/ruleset.expected.sass diff --git a/test/options/sort-order-sass/ruleset.sass b/test/options/sort-order/process/sass/ruleset.sass similarity index 100% rename from test/options/sort-order-sass/ruleset.sass rename to test/options/sort-order/process/sass/ruleset.sass diff --git a/test/options/sort-order-sass/test.js b/test/options/sort-order/process/sass/test.js similarity index 98% rename from test/options/sort-order-sass/test.js rename to test/options/sort-order/process/sass/test.js index 6f593544..230f4bf7 100644 --- a/test/options/sort-order-sass/test.js +++ b/test/options/sort-order/process/sass/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (sass)', function() { +describe.skip('options/sort-order (sass)', function() { describe('process', function() { it('Should sort properties inside rules', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-sass/variable.expected.sass b/test/options/sort-order/process/sass/variable.expected.sass similarity index 100% rename from test/options/sort-order-sass/variable.expected.sass rename to test/options/sort-order/process/sass/variable.expected.sass diff --git a/test/options/sort-order-sass/variable.sass b/test/options/sort-order/process/sass/variable.sass similarity index 100% rename from test/options/sort-order-sass/variable.sass rename to test/options/sort-order/process/sass/variable.sass diff --git a/test/options/sort-order-scss/comments-1.expected.scss b/test/options/sort-order/process/scss/comments-1.expected.scss similarity index 100% rename from test/options/sort-order-scss/comments-1.expected.scss rename to test/options/sort-order/process/scss/comments-1.expected.scss diff --git a/test/options/sort-order-scss/comments-1.scss b/test/options/sort-order/process/scss/comments-1.scss similarity index 100% rename from test/options/sort-order-scss/comments-1.scss rename to test/options/sort-order/process/scss/comments-1.scss diff --git a/test/options/sort-order-scss/comments-2.expected.scss b/test/options/sort-order/process/scss/comments-2.expected.scss similarity index 100% rename from test/options/sort-order-scss/comments-2.expected.scss rename to test/options/sort-order/process/scss/comments-2.expected.scss diff --git a/test/options/sort-order-scss/comments-2.scss b/test/options/sort-order/process/scss/comments-2.scss similarity index 100% rename from test/options/sort-order-scss/comments-2.scss rename to test/options/sort-order/process/scss/comments-2.scss diff --git a/test/options/sort-order-scss/condition.expected.scss b/test/options/sort-order/process/scss/condition.expected.scss similarity index 100% rename from test/options/sort-order-scss/condition.expected.scss rename to test/options/sort-order/process/scss/condition.expected.scss diff --git a/test/options/sort-order-scss/condition.scss b/test/options/sort-order/process/scss/condition.scss similarity index 100% rename from test/options/sort-order-scss/condition.scss rename to test/options/sort-order/process/scss/condition.scss diff --git a/test/options/sort-order-scss/different-groups.expected.scss b/test/options/sort-order/process/scss/different-groups.expected.scss similarity index 100% rename from test/options/sort-order-scss/different-groups.expected.scss rename to test/options/sort-order/process/scss/different-groups.expected.scss diff --git a/test/options/sort-order-scss/different-groups.scss b/test/options/sort-order/process/scss/different-groups.scss similarity index 100% rename from test/options/sort-order-scss/different-groups.scss rename to test/options/sort-order/process/scss/different-groups.scss diff --git a/test/options/sort-order-scss/extend.expected.scss b/test/options/sort-order/process/scss/extend.expected.scss similarity index 100% rename from test/options/sort-order-scss/extend.expected.scss rename to test/options/sort-order/process/scss/extend.expected.scss diff --git a/test/options/sort-order-scss/extend.scss b/test/options/sort-order/process/scss/extend.scss similarity index 100% rename from test/options/sort-order-scss/extend.scss rename to test/options/sort-order/process/scss/extend.scss diff --git a/test/options/sort-order-scss/import.expected.scss b/test/options/sort-order/process/scss/import.expected.scss similarity index 100% rename from test/options/sort-order-scss/import.expected.scss rename to test/options/sort-order/process/scss/import.expected.scss diff --git a/test/options/sort-order-scss/import.scss b/test/options/sort-order/process/scss/import.scss similarity index 100% rename from test/options/sort-order-scss/import.scss rename to test/options/sort-order/process/scss/import.scss diff --git a/test/options/sort-order-scss/include-specified.expected.scss b/test/options/sort-order/process/scss/include-specified.expected.scss similarity index 100% rename from test/options/sort-order-scss/include-specified.expected.scss rename to test/options/sort-order/process/scss/include-specified.expected.scss diff --git a/test/options/sort-order-scss/include-specified.scss b/test/options/sort-order/process/scss/include-specified.scss similarity index 100% rename from test/options/sort-order-scss/include-specified.scss rename to test/options/sort-order/process/scss/include-specified.scss diff --git a/test/options/sort-order-scss/include.expected.scss b/test/options/sort-order/process/scss/include.expected.scss similarity index 100% rename from test/options/sort-order-scss/include.expected.scss rename to test/options/sort-order/process/scss/include.expected.scss diff --git a/test/options/sort-order-scss/include.scss b/test/options/sort-order/process/scss/include.scss similarity index 100% rename from test/options/sort-order-scss/include.scss rename to test/options/sort-order/process/scss/include.scss diff --git a/test/options/sort-order-scss/issue-317.scss b/test/options/sort-order/process/scss/issue-317.scss similarity index 100% rename from test/options/sort-order-scss/issue-317.scss rename to test/options/sort-order/process/scss/issue-317.scss diff --git a/test/options/sort-order-scss/issue-333.scss b/test/options/sort-order/process/scss/issue-333.scss similarity index 100% rename from test/options/sort-order-scss/issue-333.scss rename to test/options/sort-order/process/scss/issue-333.scss diff --git a/test/options/sort-order-scss/issue-399.expected.scss b/test/options/sort-order/process/scss/issue-399.expected.scss similarity index 100% rename from test/options/sort-order-scss/issue-399.expected.scss rename to test/options/sort-order/process/scss/issue-399.expected.scss diff --git a/test/options/sort-order-scss/issue-399.scss b/test/options/sort-order/process/scss/issue-399.scss similarity index 100% rename from test/options/sort-order-scss/issue-399.scss rename to test/options/sort-order/process/scss/issue-399.scss diff --git a/test/options/sort-order-scss/leftovers.expected.scss b/test/options/sort-order/process/scss/leftovers.expected.scss similarity index 100% rename from test/options/sort-order-scss/leftovers.expected.scss rename to test/options/sort-order/process/scss/leftovers.expected.scss diff --git a/test/options/sort-order-scss/leftovers.scss b/test/options/sort-order/process/scss/leftovers.scss similarity index 100% rename from test/options/sort-order-scss/leftovers.scss rename to test/options/sort-order/process/scss/leftovers.scss diff --git a/test/options/sort-order-scss/mixin.expected.scss b/test/options/sort-order/process/scss/mixin.expected.scss similarity index 100% rename from test/options/sort-order-scss/mixin.expected.scss rename to test/options/sort-order/process/scss/mixin.expected.scss diff --git a/test/options/sort-order-scss/mixin.scss b/test/options/sort-order/process/scss/mixin.scss similarity index 100% rename from test/options/sort-order-scss/mixin.scss rename to test/options/sort-order/process/scss/mixin.scss diff --git a/test/options/sort-order-scss/nested-rule-1.expected.scss b/test/options/sort-order/process/scss/nested-rule-1.expected.scss similarity index 100% rename from test/options/sort-order-scss/nested-rule-1.expected.scss rename to test/options/sort-order/process/scss/nested-rule-1.expected.scss diff --git a/test/options/sort-order-scss/nested-rule-1.scss b/test/options/sort-order/process/scss/nested-rule-1.scss similarity index 100% rename from test/options/sort-order-scss/nested-rule-1.scss rename to test/options/sort-order/process/scss/nested-rule-1.scss diff --git a/test/options/sort-order-scss/nested-rule-2.expected.scss b/test/options/sort-order/process/scss/nested-rule-2.expected.scss similarity index 100% rename from test/options/sort-order-scss/nested-rule-2.expected.scss rename to test/options/sort-order/process/scss/nested-rule-2.expected.scss diff --git a/test/options/sort-order-scss/nested-rule-2.scss b/test/options/sort-order/process/scss/nested-rule-2.scss similarity index 100% rename from test/options/sort-order-scss/nested-rule-2.scss rename to test/options/sort-order/process/scss/nested-rule-2.scss diff --git a/test/options/sort-order-scss/rule-multiline.expected.scss b/test/options/sort-order/process/scss/rule-multiline.expected.scss similarity index 100% rename from test/options/sort-order-scss/rule-multiline.expected.scss rename to test/options/sort-order/process/scss/rule-multiline.expected.scss diff --git a/test/options/sort-order-scss/rule-multiline.scss b/test/options/sort-order/process/scss/rule-multiline.scss similarity index 100% rename from test/options/sort-order-scss/rule-multiline.scss rename to test/options/sort-order/process/scss/rule-multiline.scss diff --git a/test/options/sort-order-scss/rule.expected.scss b/test/options/sort-order/process/scss/rule.expected.scss similarity index 100% rename from test/options/sort-order-scss/rule.expected.scss rename to test/options/sort-order/process/scss/rule.expected.scss diff --git a/test/options/sort-order-scss/rule.scss b/test/options/sort-order/process/scss/rule.scss similarity index 100% rename from test/options/sort-order-scss/rule.scss rename to test/options/sort-order/process/scss/rule.scss diff --git a/test/options/sort-order-scss/ruleset.expected.scss b/test/options/sort-order/process/scss/ruleset.expected.scss similarity index 100% rename from test/options/sort-order-scss/ruleset.expected.scss rename to test/options/sort-order/process/scss/ruleset.expected.scss diff --git a/test/options/sort-order-scss/ruleset.scss b/test/options/sort-order/process/scss/ruleset.scss similarity index 100% rename from test/options/sort-order-scss/ruleset.scss rename to test/options/sort-order/process/scss/ruleset.scss diff --git a/test/options/sort-order-scss/test.js b/test/options/sort-order/process/scss/test.js similarity index 98% rename from test/options/sort-order-scss/test.js rename to test/options/sort-order/process/scss/test.js index b5a31487..8613d400 100644 --- a/test/options/sort-order-scss/test.js +++ b/test/options/sort-order/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/sort-order (scss)', function() { +describe.skip('options/sort-order (scss)', function() { describe('process', function() { it('Should sort properties inside rules (single line)', function() { this.comb.configure({ 'sort-order': [ diff --git a/test/options/sort-order-scss/variable.expected.scss b/test/options/sort-order/process/scss/variable.expected.scss similarity index 100% rename from test/options/sort-order-scss/variable.expected.scss rename to test/options/sort-order/process/scss/variable.expected.scss diff --git a/test/options/sort-order-scss/variable.scss b/test/options/sort-order/process/scss/variable.scss similarity index 100% rename from test/options/sort-order-scss/variable.scss rename to test/options/sort-order/process/scss/variable.scss diff --git a/test/options/sort-order/test.js b/test/options/sort-order/process/test.js similarity index 99% rename from test/options/sort-order/test.js rename to test/options/sort-order/process/test.js index c638a238..b650ae86 100644 --- a/test/options/sort-order/test.js +++ b/test/options/sort-order/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/sort-order', function() { +describe.skip('options/sort-order', function() { describe('process', function() { it('Should be in expected order in case properties are not grouped', function() { this.comb.configure({ 'sort-order': ['position', 'z-index'] }); diff --git a/test/options/space-after-colon/test-2.expected.css b/test/options/space-after-colon/process/css/test-2.expected.css similarity index 100% rename from test/options/space-after-colon/test-2.expected.css rename to test/options/space-after-colon/process/css/test-2.expected.css diff --git a/test/options/space-after-colon/test-3.expected.css b/test/options/space-after-colon/process/css/test-3.expected.css similarity index 100% rename from test/options/space-after-colon/test-3.expected.css rename to test/options/space-after-colon/process/css/test-3.expected.css diff --git a/test/options/space-after-colon/test.css b/test/options/space-after-colon/process/css/test.css similarity index 100% rename from test/options/space-after-colon/test.css rename to test/options/space-after-colon/process/css/test.css diff --git a/test/options/space-after-colon/test.expected.css b/test/options/space-after-colon/process/css/test.expected.css similarity index 100% rename from test/options/space-after-colon/test.expected.css rename to test/options/space-after-colon/process/css/test.expected.css diff --git a/test/options/space-after-colon-sass/colon-after-property-name.expected.sass b/test/options/space-after-colon/process/sass/colon-after-property-name.expected.sass similarity index 100% rename from test/options/space-after-colon-sass/colon-after-property-name.expected.sass rename to test/options/space-after-colon/process/sass/colon-after-property-name.expected.sass diff --git a/test/options/space-after-colon-sass/colon-after-property-name.sass b/test/options/space-after-colon/process/sass/colon-after-property-name.sass similarity index 100% rename from test/options/space-after-colon-sass/colon-after-property-name.sass rename to test/options/space-after-colon/process/sass/colon-after-property-name.sass diff --git a/test/options/space-after-colon-sass/colon-before-property-name.expected.sass b/test/options/space-after-colon/process/sass/colon-before-property-name.expected.sass similarity index 100% rename from test/options/space-after-colon-sass/colon-before-property-name.expected.sass rename to test/options/space-after-colon/process/sass/colon-before-property-name.expected.sass diff --git a/test/options/space-after-colon-sass/colon-before-property-name.sass b/test/options/space-after-colon/process/sass/colon-before-property-name.sass similarity index 100% rename from test/options/space-after-colon-sass/colon-before-property-name.sass rename to test/options/space-after-colon/process/sass/colon-before-property-name.sass diff --git a/test/options/space-after-colon-sass/test.js b/test/options/space-after-colon/process/sass/test.js similarity index 90% rename from test/options/space-after-colon-sass/test.js rename to test/options/space-after-colon/process/sass/test.js index 81052b7f..b0b5685c 100644 --- a/test/options/space-after-colon-sass/test.js +++ b/test/options/space-after-colon/process/sass/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon (sass):', function() { +describe.skip('options/space-after-colon (sass):', function() { describe('process', function() { it('Should set proper space if colon is after property name', function() { this.comb.configure({ 'space-after-colon': 2 }); diff --git a/test/options/space-after-colon-scss/pseudo-elements.expected.scss b/test/options/space-after-colon/process/scss/pseudo-elements.expected.scss similarity index 100% rename from test/options/space-after-colon-scss/pseudo-elements.expected.scss rename to test/options/space-after-colon/process/scss/pseudo-elements.expected.scss diff --git a/test/options/space-after-colon-scss/pseudo-elements.scss b/test/options/space-after-colon/process/scss/pseudo-elements.scss similarity index 100% rename from test/options/space-after-colon-scss/pseudo-elements.scss rename to test/options/space-after-colon/process/scss/pseudo-elements.scss diff --git a/test/options/space-after-colon-scss/test.js b/test/options/space-after-colon/process/scss/test.js similarity index 82% rename from test/options/space-after-colon-scss/test.js rename to test/options/space-after-colon/process/scss/test.js index 996eee00..2cb13b06 100644 --- a/test/options/space-after-colon-scss/test.js +++ b/test/options/space-after-colon/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon (scss):', function() { +describe.skip('options/space-after-colon (scss):', function() { describe('process', function() { it('Space after colon should not affect pseudo elements', function() { this.comb.configure({ 'space-after-colon': 1 }); diff --git a/test/options/space-after-colon/test.js b/test/options/space-after-colon/process/test.js similarity index 97% rename from test/options/space-after-colon/test.js rename to test/options/space-after-colon/process/test.js index 8de8b4c2..2e575849 100644 --- a/test/options/space-after-colon/test.js +++ b/test/options/space-after-colon/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-colon:', function() { +describe.skip('options/space-after-colon:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-colon': ['', ' '] }); diff --git a/test/options/space-after-combinator/test-2.expected.css b/test/options/space-after-combinator/process/css/test-2.expected.css similarity index 100% rename from test/options/space-after-combinator/test-2.expected.css rename to test/options/space-after-combinator/process/css/test-2.expected.css diff --git a/test/options/space-after-combinator/test-3.expected.css b/test/options/space-after-combinator/process/css/test-3.expected.css similarity index 100% rename from test/options/space-after-combinator/test-3.expected.css rename to test/options/space-after-combinator/process/css/test-3.expected.css diff --git a/test/options/space-after-combinator/test.css b/test/options/space-after-combinator/process/css/test.css similarity index 100% rename from test/options/space-after-combinator/test.css rename to test/options/space-after-combinator/process/css/test.css diff --git a/test/options/space-after-combinator/test.expected.css b/test/options/space-after-combinator/process/css/test.expected.css similarity index 100% rename from test/options/space-after-combinator/test.expected.css rename to test/options/space-after-combinator/process/css/test.expected.css diff --git a/test/options/space-after-combinator/test.js b/test/options/space-after-combinator/process/test.js similarity index 98% rename from test/options/space-after-combinator/test.js rename to test/options/space-after-combinator/process/test.js index b9efec9a..aab922e4 100644 --- a/test/options/space-after-combinator/test.js +++ b/test/options/space-after-combinator/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-combinator:', function() { +describe.skip('options/space-after-combinator:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-combinator': ['', ' '] }); diff --git a/test/options/space-after-opening-brace/issue-387.css b/test/options/space-after-opening-brace/process/css/issue-387.css similarity index 100% rename from test/options/space-after-opening-brace/issue-387.css rename to test/options/space-after-opening-brace/process/css/issue-387.css diff --git a/test/options/space-after-opening-brace/issue-387.expected.css b/test/options/space-after-opening-brace/process/css/issue-387.expected.css similarity index 100% rename from test/options/space-after-opening-brace/issue-387.expected.css rename to test/options/space-after-opening-brace/process/css/issue-387.expected.css diff --git a/test/options/space-after-opening-brace/test-2.expected.css b/test/options/space-after-opening-brace/process/css/test-2.expected.css similarity index 100% rename from test/options/space-after-opening-brace/test-2.expected.css rename to test/options/space-after-opening-brace/process/css/test-2.expected.css diff --git a/test/options/space-after-opening-brace/test-3.expected.css b/test/options/space-after-opening-brace/process/css/test-3.expected.css similarity index 100% rename from test/options/space-after-opening-brace/test-3.expected.css rename to test/options/space-after-opening-brace/process/css/test-3.expected.css diff --git a/test/options/space-after-opening-brace/test.css b/test/options/space-after-opening-brace/process/css/test.css similarity index 100% rename from test/options/space-after-opening-brace/test.css rename to test/options/space-after-opening-brace/process/css/test.css diff --git a/test/options/space-after-opening-brace/test.expected.css b/test/options/space-after-opening-brace/process/css/test.expected.css similarity index 100% rename from test/options/space-after-opening-brace/test.expected.css rename to test/options/space-after-opening-brace/process/css/test.expected.css diff --git a/test/options/space-after-opening-brace/test.js b/test/options/space-after-opening-brace/process/test.js similarity index 98% rename from test/options/space-after-opening-brace/test.js rename to test/options/space-after-opening-brace/process/test.js index ee4a8035..cb26106f 100644 --- a/test/options/space-after-opening-brace/test.js +++ b/test/options/space-after-opening-brace/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-opening-brace:', function() { +describe.skip('options/space-after-opening-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); diff --git a/test/options/space-after-selector-delimiter/test-2.expected.css b/test/options/space-after-selector-delimiter/process/css/test-2.expected.css similarity index 100% rename from test/options/space-after-selector-delimiter/test-2.expected.css rename to test/options/space-after-selector-delimiter/process/css/test-2.expected.css diff --git a/test/options/space-after-selector-delimiter/test-3.expected.css b/test/options/space-after-selector-delimiter/process/css/test-3.expected.css similarity index 100% rename from test/options/space-after-selector-delimiter/test-3.expected.css rename to test/options/space-after-selector-delimiter/process/css/test-3.expected.css diff --git a/test/options/space-after-selector-delimiter/test.css b/test/options/space-after-selector-delimiter/process/css/test.css similarity index 100% rename from test/options/space-after-selector-delimiter/test.css rename to test/options/space-after-selector-delimiter/process/css/test.css diff --git a/test/options/space-after-selector-delimiter/test.expected.css b/test/options/space-after-selector-delimiter/process/css/test.expected.css similarity index 100% rename from test/options/space-after-selector-delimiter/test.expected.css rename to test/options/space-after-selector-delimiter/process/css/test.expected.css diff --git a/test/options/space-after-selector-delimiter-sass/issue-238.expected.sass b/test/options/space-after-selector-delimiter/process/sass/issue-238.expected.sass similarity index 100% rename from test/options/space-after-selector-delimiter-sass/issue-238.expected.sass rename to test/options/space-after-selector-delimiter/process/sass/issue-238.expected.sass diff --git a/test/options/space-after-selector-delimiter-sass/issue-238.sass b/test/options/space-after-selector-delimiter/process/sass/issue-238.sass similarity index 100% rename from test/options/space-after-selector-delimiter-sass/issue-238.sass rename to test/options/space-after-selector-delimiter/process/sass/issue-238.sass diff --git a/test/options/space-after-selector-delimiter-sass/test.js b/test/options/space-after-selector-delimiter/process/sass/test.js similarity index 77% rename from test/options/space-after-selector-delimiter-sass/test.js rename to test/options/space-after-selector-delimiter/process/sass/test.js index a38ebacb..d7996311 100644 --- a/test/options/space-after-selector-delimiter-sass/test.js +++ b/test/options/space-after-selector-delimiter/process/sass/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-selector-delimiter (sass):', function() { +describe.skip('options/space-after-selector-delimiter (sass):', function() { describe('process', function() { it('Issue 238', function() { this.comb.configure({ 'space-after-selector-delimiter': '\n' }); diff --git a/test/options/space-after-selector-delimiter/test.js b/test/options/space-after-selector-delimiter/process/test.js similarity index 97% rename from test/options/space-after-selector-delimiter/test.js rename to test/options/space-after-selector-delimiter/process/test.js index b4957a19..eafe597c 100644 --- a/test/options/space-after-selector-delimiter/test.js +++ b/test/options/space-after-selector-delimiter/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-after-selector-delimiter:', function() { +describe.skip('options/space-after-selector-delimiter:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); diff --git a/test/options/space-before-closing-brace/test-2.expected.css b/test/options/space-before-closing-brace/process/css/test-2.expected.css similarity index 100% rename from test/options/space-before-closing-brace/test-2.expected.css rename to test/options/space-before-closing-brace/process/css/test-2.expected.css diff --git a/test/options/space-before-closing-brace/test-3.expected.css b/test/options/space-before-closing-brace/process/css/test-3.expected.css similarity index 100% rename from test/options/space-before-closing-brace/test-3.expected.css rename to test/options/space-before-closing-brace/process/css/test-3.expected.css diff --git a/test/options/space-before-closing-brace/test.css b/test/options/space-before-closing-brace/process/css/test.css similarity index 100% rename from test/options/space-before-closing-brace/test.css rename to test/options/space-before-closing-brace/process/css/test.css diff --git a/test/options/space-before-closing-brace/test.expected.css b/test/options/space-before-closing-brace/process/css/test.expected.css similarity index 100% rename from test/options/space-before-closing-brace/test.expected.css rename to test/options/space-before-closing-brace/process/css/test.expected.css diff --git a/test/options/space-before-closing-brace/test.js b/test/options/space-before-closing-brace/process/test.js similarity index 97% rename from test/options/space-before-closing-brace/test.js rename to test/options/space-before-closing-brace/process/test.js index 6e73205a..496de360 100644 --- a/test/options/space-before-closing-brace/test.js +++ b/test/options/space-before-closing-brace/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-closing-brace:', function() { +describe.skip('options/space-before-closing-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); diff --git a/test/options/space-before-colon/test-2.expected.css b/test/options/space-before-colon/process/css/test-2.expected.css similarity index 100% rename from test/options/space-before-colon/test-2.expected.css rename to test/options/space-before-colon/process/css/test-2.expected.css diff --git a/test/options/space-before-colon/test-3.expected.css b/test/options/space-before-colon/process/css/test-3.expected.css similarity index 100% rename from test/options/space-before-colon/test-3.expected.css rename to test/options/space-before-colon/process/css/test-3.expected.css diff --git a/test/options/space-before-colon/test.css b/test/options/space-before-colon/process/css/test.css similarity index 100% rename from test/options/space-before-colon/test.css rename to test/options/space-before-colon/process/css/test.css diff --git a/test/options/space-before-colon/test.expected.css b/test/options/space-before-colon/process/css/test.expected.css similarity index 100% rename from test/options/space-before-colon/test.expected.css rename to test/options/space-before-colon/process/css/test.expected.css diff --git a/test/options/space-before-colon-sass/test.expected.sass b/test/options/space-before-colon/process/sass/test.expected.sass similarity index 100% rename from test/options/space-before-colon-sass/test.expected.sass rename to test/options/space-before-colon/process/sass/test.expected.sass diff --git a/test/options/space-before-colon-sass/test.js b/test/options/space-before-colon/process/sass/test.js similarity index 100% rename from test/options/space-before-colon-sass/test.js rename to test/options/space-before-colon/process/sass/test.js diff --git a/test/options/space-before-colon-sass/test.sass b/test/options/space-before-colon/process/sass/test.sass similarity index 100% rename from test/options/space-before-colon-sass/test.sass rename to test/options/space-before-colon/process/sass/test.sass diff --git a/test/options/space-before-colon-sass/test2.sass b/test/options/space-before-colon/process/sass/test2.sass similarity index 100% rename from test/options/space-before-colon-sass/test2.sass rename to test/options/space-before-colon/process/sass/test2.sass diff --git a/test/options/space-before-colon/test.js b/test/options/space-before-colon/process/test.js similarity index 97% rename from test/options/space-before-colon/test.js rename to test/options/space-before-colon/process/test.js index 4db00ae8..b223d752 100644 --- a/test/options/space-before-colon/test.js +++ b/test/options/space-before-colon/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-colon:', function() { +describe.skip('options/space-before-colon:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-colon': ['', ' '] }); diff --git a/test/options/space-before-combinator/issue-381.css b/test/options/space-before-combinator/process/css/issue-381.css similarity index 100% rename from test/options/space-before-combinator/issue-381.css rename to test/options/space-before-combinator/process/css/issue-381.css diff --git a/test/options/space-before-combinator/test-2.expected.css b/test/options/space-before-combinator/process/css/test-2.expected.css similarity index 100% rename from test/options/space-before-combinator/test-2.expected.css rename to test/options/space-before-combinator/process/css/test-2.expected.css diff --git a/test/options/space-before-combinator/test-3.expected.css b/test/options/space-before-combinator/process/css/test-3.expected.css similarity index 100% rename from test/options/space-before-combinator/test-3.expected.css rename to test/options/space-before-combinator/process/css/test-3.expected.css diff --git a/test/options/space-before-combinator/test.css b/test/options/space-before-combinator/process/css/test.css similarity index 100% rename from test/options/space-before-combinator/test.css rename to test/options/space-before-combinator/process/css/test.css diff --git a/test/options/space-before-combinator/test.expected.css b/test/options/space-before-combinator/process/css/test.expected.css similarity index 100% rename from test/options/space-before-combinator/test.expected.css rename to test/options/space-before-combinator/process/css/test.expected.css diff --git a/test/options/space-before-combinator/test.js b/test/options/space-before-combinator/process/test.js similarity index 98% rename from test/options/space-before-combinator/test.js rename to test/options/space-before-combinator/process/test.js index 2d74a26a..ee401ddd 100644 --- a/test/options/space-before-combinator/test.js +++ b/test/options/space-before-combinator/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-combinator:', function() { +describe.skip('options/space-before-combinator:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-combinator': ['', ' '] }); diff --git a/test/options/space-before-opening-brace/issue-232.css b/test/options/space-before-opening-brace/process/css/issue-232.css similarity index 100% rename from test/options/space-before-opening-brace/issue-232.css rename to test/options/space-before-opening-brace/process/css/issue-232.css diff --git a/test/options/space-before-opening-brace/issue-232.expected.css b/test/options/space-before-opening-brace/process/css/issue-232.expected.css similarity index 100% rename from test/options/space-before-opening-brace/issue-232.expected.css rename to test/options/space-before-opening-brace/process/css/issue-232.expected.css diff --git a/test/options/space-before-opening-brace/test-2.expected.css b/test/options/space-before-opening-brace/process/css/test-2.expected.css similarity index 100% rename from test/options/space-before-opening-brace/test-2.expected.css rename to test/options/space-before-opening-brace/process/css/test-2.expected.css diff --git a/test/options/space-before-opening-brace/test-3.expected.css b/test/options/space-before-opening-brace/process/css/test-3.expected.css similarity index 100% rename from test/options/space-before-opening-brace/test-3.expected.css rename to test/options/space-before-opening-brace/process/css/test-3.expected.css diff --git a/test/options/space-before-opening-brace/test.css b/test/options/space-before-opening-brace/process/css/test.css similarity index 100% rename from test/options/space-before-opening-brace/test.css rename to test/options/space-before-opening-brace/process/css/test.css diff --git a/test/options/space-before-opening-brace/test.expected.css b/test/options/space-before-opening-brace/process/css/test.expected.css similarity index 100% rename from test/options/space-before-opening-brace/test.expected.css rename to test/options/space-before-opening-brace/process/css/test.expected.css diff --git a/test/options/space-before-opening-brace-scss/issue-231.expected.scss b/test/options/space-before-opening-brace/process/scss/issue-231.expected.scss similarity index 100% rename from test/options/space-before-opening-brace-scss/issue-231.expected.scss rename to test/options/space-before-opening-brace/process/scss/issue-231.expected.scss diff --git a/test/options/space-before-opening-brace-scss/issue-231.scss b/test/options/space-before-opening-brace/process/scss/issue-231.scss similarity index 100% rename from test/options/space-before-opening-brace-scss/issue-231.scss rename to test/options/space-before-opening-brace/process/scss/issue-231.scss diff --git a/test/options/space-before-opening-brace-scss/issue-319.expected.scss b/test/options/space-before-opening-brace/process/scss/issue-319.expected.scss similarity index 100% rename from test/options/space-before-opening-brace-scss/issue-319.expected.scss rename to test/options/space-before-opening-brace/process/scss/issue-319.expected.scss diff --git a/test/options/space-before-opening-brace-scss/issue-319.scss b/test/options/space-before-opening-brace/process/scss/issue-319.scss similarity index 100% rename from test/options/space-before-opening-brace-scss/issue-319.scss rename to test/options/space-before-opening-brace/process/scss/issue-319.scss diff --git a/test/options/space-before-opening-brace-scss/test.js b/test/options/space-before-opening-brace/process/scss/test.js similarity index 86% rename from test/options/space-before-opening-brace-scss/test.js rename to test/options/space-before-opening-brace/process/scss/test.js index 0abc84bb..a7e1f6ca 100644 --- a/test/options/space-before-opening-brace-scss/test.js +++ b/test/options/space-before-opening-brace/process/scss/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-opening-brace (scss):', function() { +describe.skip('options/space-before-opening-brace (scss):', function() { describe('process', function() { it('Issue 231', function() { this.comb.configure({ 'space-before-opening-brace': 1 }); diff --git a/test/options/space-before-opening-brace/test.js b/test/options/space-before-opening-brace/process/test.js similarity index 98% rename from test/options/space-before-opening-brace/test.js rename to test/options/space-before-opening-brace/process/test.js index de336baf..f7af132d 100644 --- a/test/options/space-before-opening-brace/test.js +++ b/test/options/space-before-opening-brace/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-opening-brace:', function() { +describe.skip('options/space-before-opening-brace:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); diff --git a/test/options/space-before-selector-delimiter/test-2.expected.css b/test/options/space-before-selector-delimiter/process/css/test-2.expected.css similarity index 100% rename from test/options/space-before-selector-delimiter/test-2.expected.css rename to test/options/space-before-selector-delimiter/process/css/test-2.expected.css diff --git a/test/options/space-before-selector-delimiter/test-3.expected.css b/test/options/space-before-selector-delimiter/process/css/test-3.expected.css similarity index 100% rename from test/options/space-before-selector-delimiter/test-3.expected.css rename to test/options/space-before-selector-delimiter/process/css/test-3.expected.css diff --git a/test/options/space-before-selector-delimiter/test.css b/test/options/space-before-selector-delimiter/process/css/test.css similarity index 100% rename from test/options/space-before-selector-delimiter/test.css rename to test/options/space-before-selector-delimiter/process/css/test.css diff --git a/test/options/space-before-selector-delimiter/test.expected.css b/test/options/space-before-selector-delimiter/process/css/test.expected.css similarity index 100% rename from test/options/space-before-selector-delimiter/test.expected.css rename to test/options/space-before-selector-delimiter/process/css/test.expected.css diff --git a/test/options/space-before-selector-delimiter/test.js b/test/options/space-before-selector-delimiter/process/test.js similarity index 97% rename from test/options/space-before-selector-delimiter/test.js rename to test/options/space-before-selector-delimiter/process/test.js index fd3c5827..b91d3140 100644 --- a/test/options/space-before-selector-delimiter/test.js +++ b/test/options/space-before-selector-delimiter/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-before-selector-delimiter:', function() { +describe.skip('options/space-before-selector-delimiter:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); diff --git a/test/options/space-between-declarations/comments.css b/test/options/space-between-declarations/process/css/comments.css similarity index 100% rename from test/options/space-between-declarations/comments.css rename to test/options/space-between-declarations/process/css/comments.css diff --git a/test/options/space-between-declarations/comments.expected.css b/test/options/space-between-declarations/process/css/comments.expected.css similarity index 100% rename from test/options/space-between-declarations/comments.expected.css rename to test/options/space-between-declarations/process/css/comments.expected.css diff --git a/test/options/space-between-declarations/integer-value.css b/test/options/space-between-declarations/process/css/integer-value.css similarity index 100% rename from test/options/space-between-declarations/integer-value.css rename to test/options/space-between-declarations/process/css/integer-value.css diff --git a/test/options/space-between-declarations/integer-value.expected.css b/test/options/space-between-declarations/process/css/integer-value.expected.css similarity index 100% rename from test/options/space-between-declarations/integer-value.expected.css rename to test/options/space-between-declarations/process/css/integer-value.expected.css diff --git a/test/options/space-between-declarations/issue-239.css b/test/options/space-between-declarations/process/css/issue-239.css similarity index 100% rename from test/options/space-between-declarations/issue-239.css rename to test/options/space-between-declarations/process/css/issue-239.css diff --git a/test/options/space-between-declarations/issue-239.expected.css b/test/options/space-between-declarations/process/css/issue-239.expected.css similarity index 100% rename from test/options/space-between-declarations/issue-239.expected.css rename to test/options/space-between-declarations/process/css/issue-239.expected.css diff --git a/test/options/space-between-declarations/issue-378.css b/test/options/space-between-declarations/process/css/issue-378.css similarity index 100% rename from test/options/space-between-declarations/issue-378.css rename to test/options/space-between-declarations/process/css/issue-378.css diff --git a/test/options/space-between-declarations/space-newline-value.css b/test/options/space-between-declarations/process/css/space-newline-value.css similarity index 100% rename from test/options/space-between-declarations/space-newline-value.css rename to test/options/space-between-declarations/process/css/space-newline-value.css diff --git a/test/options/space-between-declarations/space-newline-value.expected.css b/test/options/space-between-declarations/process/css/space-newline-value.expected.css similarity index 100% rename from test/options/space-between-declarations/space-newline-value.expected.css rename to test/options/space-between-declarations/process/css/space-newline-value.expected.css diff --git a/test/options/space-between-declarations/space-value.css b/test/options/space-between-declarations/process/css/space-value.css similarity index 100% rename from test/options/space-between-declarations/space-value.css rename to test/options/space-between-declarations/process/css/space-value.css diff --git a/test/options/space-between-declarations/space-value.expected.css b/test/options/space-between-declarations/process/css/space-value.expected.css similarity index 100% rename from test/options/space-between-declarations/space-value.expected.css rename to test/options/space-between-declarations/process/css/space-value.expected.css diff --git a/test/options/space-between-declarations/test.css b/test/options/space-between-declarations/process/css/test.css similarity index 100% rename from test/options/space-between-declarations/test.css rename to test/options/space-between-declarations/process/css/test.css diff --git a/test/options/space-between-declarations/test.js b/test/options/space-between-declarations/process/test.js similarity index 97% rename from test/options/space-between-declarations/test.js rename to test/options/space-between-declarations/process/test.js index 3324b2c9..a106cde9 100644 --- a/test/options/space-between-declarations/test.js +++ b/test/options/space-between-declarations/process/test.js @@ -1,4 +1,4 @@ -describe('options/space-between-declarations:', function() { +describe.skip('options/space-between-declarations:', function() { describe('process', function() { it('Array value => should not change anything', function() { this.comb.configure({ 'space-between-declarations': ['', ' '] }); diff --git a/test/options/strip-spaces/test.js b/test/options/strip-spaces/process/test.js similarity index 98% rename from test/options/strip-spaces/test.js rename to test/options/strip-spaces/process/test.js index f5d417fd..bb083149 100644 --- a/test/options/strip-spaces/test.js +++ b/test/options/strip-spaces/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/strip-spaces', function() { +describe.skip('options/strip-spaces', function() { describe('process', function() { it('Invalid value should not trim trailing spaces', function() { this.comb.configure({ 'strip-spaces': 'foobar' }); diff --git a/test/options/tab-size/test.css b/test/options/tab-size/process/css/test.css similarity index 100% rename from test/options/tab-size/test.css rename to test/options/tab-size/process/css/test.css diff --git a/test/options/tab-size/test.expected.css b/test/options/tab-size/process/css/test.expected.css similarity index 100% rename from test/options/tab-size/test.expected.css rename to test/options/tab-size/process/css/test.expected.css diff --git a/test/options/tab-size/test.js b/test/options/tab-size/process/test.js similarity index 93% rename from test/options/tab-size/test.js rename to test/options/tab-size/process/test.js index 83e7c9f7..05c1193f 100644 --- a/test/options/tab-size/test.js +++ b/test/options/tab-size/process/test.js @@ -1,4 +1,4 @@ -describe('options/tab-size:', function() { +describe.skip('options/tab-size:', function() { describe('process', function() { it('Test 1: String value => should not change anything', function() { this.comb.configure({ 'tab-size': ' ' }); diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/process/test.js similarity index 98% rename from test/options/unitless-zero/test.js rename to test/options/unitless-zero/process/test.js index 61fe2bba..c42d5205 100644 --- a/test/options/unitless-zero/test.js +++ b/test/options/unitless-zero/process/test.js @@ -1,6 +1,6 @@ var assert = require('assert'); -describe('options/unitless-zero', function() { +describe.skip('options/unitless-zero', function() { describe('process', function() { it('Should remove units in zero-valued dimensions', function() { this.comb.configure({ 'unitless-zero': true }); diff --git a/test/options/vendor-prefix-align/already-aligned.css b/test/options/vendor-prefix-align/process/css/already-aligned.css similarity index 100% rename from test/options/vendor-prefix-align/already-aligned.css rename to test/options/vendor-prefix-align/process/css/already-aligned.css diff --git a/test/options/vendor-prefix-align/already-aligned.expected.css b/test/options/vendor-prefix-align/process/css/already-aligned.expected.css similarity index 100% rename from test/options/vendor-prefix-align/already-aligned.expected.css rename to test/options/vendor-prefix-align/process/css/already-aligned.expected.css diff --git a/test/options/vendor-prefix-align/both.css b/test/options/vendor-prefix-align/process/css/both.css similarity index 100% rename from test/options/vendor-prefix-align/both.css rename to test/options/vendor-prefix-align/process/css/both.css diff --git a/test/options/vendor-prefix-align/both.expected.css b/test/options/vendor-prefix-align/process/css/both.expected.css similarity index 100% rename from test/options/vendor-prefix-align/both.expected.css rename to test/options/vendor-prefix-align/process/css/both.expected.css diff --git a/test/options/vendor-prefix-align/complex.css b/test/options/vendor-prefix-align/process/css/complex.css similarity index 100% rename from test/options/vendor-prefix-align/complex.css rename to test/options/vendor-prefix-align/process/css/complex.css diff --git a/test/options/vendor-prefix-align/complex.expected.css b/test/options/vendor-prefix-align/process/css/complex.expected.css similarity index 100% rename from test/options/vendor-prefix-align/complex.expected.css rename to test/options/vendor-prefix-align/process/css/complex.expected.css diff --git a/test/options/vendor-prefix-align/issue-193.css b/test/options/vendor-prefix-align/process/css/issue-193.css similarity index 100% rename from test/options/vendor-prefix-align/issue-193.css rename to test/options/vendor-prefix-align/process/css/issue-193.css diff --git a/test/options/vendor-prefix-align/issue-193.expected.css b/test/options/vendor-prefix-align/process/css/issue-193.expected.css similarity index 100% rename from test/options/vendor-prefix-align/issue-193.expected.css rename to test/options/vendor-prefix-align/process/css/issue-193.expected.css diff --git a/test/options/vendor-prefix-align/issue-241.css b/test/options/vendor-prefix-align/process/css/issue-241.css similarity index 100% rename from test/options/vendor-prefix-align/issue-241.css rename to test/options/vendor-prefix-align/process/css/issue-241.css diff --git a/test/options/vendor-prefix-align/issue-241.expected.css b/test/options/vendor-prefix-align/process/css/issue-241.expected.css similarity index 100% rename from test/options/vendor-prefix-align/issue-241.expected.css rename to test/options/vendor-prefix-align/process/css/issue-241.expected.css diff --git a/test/options/vendor-prefix-align/multiline-comments.css b/test/options/vendor-prefix-align/process/css/multiline-comments.css similarity index 100% rename from test/options/vendor-prefix-align/multiline-comments.css rename to test/options/vendor-prefix-align/process/css/multiline-comments.css diff --git a/test/options/vendor-prefix-align/multiline-comments.expected.css b/test/options/vendor-prefix-align/process/css/multiline-comments.expected.css similarity index 100% rename from test/options/vendor-prefix-align/multiline-comments.expected.css rename to test/options/vendor-prefix-align/process/css/multiline-comments.expected.css diff --git a/test/options/vendor-prefix-align/one-line-2.css b/test/options/vendor-prefix-align/process/css/one-line-2.css similarity index 100% rename from test/options/vendor-prefix-align/one-line-2.css rename to test/options/vendor-prefix-align/process/css/one-line-2.css diff --git a/test/options/vendor-prefix-align/one-line-2.expected.css b/test/options/vendor-prefix-align/process/css/one-line-2.expected.css similarity index 100% rename from test/options/vendor-prefix-align/one-line-2.expected.css rename to test/options/vendor-prefix-align/process/css/one-line-2.expected.css diff --git a/test/options/vendor-prefix-align/one-line.css b/test/options/vendor-prefix-align/process/css/one-line.css similarity index 100% rename from test/options/vendor-prefix-align/one-line.css rename to test/options/vendor-prefix-align/process/css/one-line.css diff --git a/test/options/vendor-prefix-align/one-line.expected.css b/test/options/vendor-prefix-align/process/css/one-line.expected.css similarity index 100% rename from test/options/vendor-prefix-align/one-line.expected.css rename to test/options/vendor-prefix-align/process/css/one-line.expected.css diff --git a/test/options/vendor-prefix-align/property-align.css b/test/options/vendor-prefix-align/process/css/property-align.css similarity index 100% rename from test/options/vendor-prefix-align/property-align.css rename to test/options/vendor-prefix-align/process/css/property-align.css diff --git a/test/options/vendor-prefix-align/property-align.expected.css b/test/options/vendor-prefix-align/process/css/property-align.expected.css similarity index 100% rename from test/options/vendor-prefix-align/property-align.expected.css rename to test/options/vendor-prefix-align/process/css/property-align.expected.css diff --git a/test/options/vendor-prefix-align/same-name.css b/test/options/vendor-prefix-align/process/css/same-name.css similarity index 100% rename from test/options/vendor-prefix-align/same-name.css rename to test/options/vendor-prefix-align/process/css/same-name.css diff --git a/test/options/vendor-prefix-align/same-name.expected.css b/test/options/vendor-prefix-align/process/css/same-name.expected.css similarity index 100% rename from test/options/vendor-prefix-align/same-name.expected.css rename to test/options/vendor-prefix-align/process/css/same-name.expected.css diff --git a/test/options/vendor-prefix-align/value-align.css b/test/options/vendor-prefix-align/process/css/value-align.css similarity index 100% rename from test/options/vendor-prefix-align/value-align.css rename to test/options/vendor-prefix-align/process/css/value-align.css diff --git a/test/options/vendor-prefix-align/value-align.expected.css b/test/options/vendor-prefix-align/process/css/value-align.expected.css similarity index 100% rename from test/options/vendor-prefix-align/value-align.expected.css rename to test/options/vendor-prefix-align/process/css/value-align.expected.css diff --git a/test/options/vendor-prefix-align/with-comment-property-2.css b/test/options/vendor-prefix-align/process/css/with-comment-property-2.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment-property-2.css rename to test/options/vendor-prefix-align/process/css/with-comment-property-2.css diff --git a/test/options/vendor-prefix-align/with-comment-property-2.expected.css b/test/options/vendor-prefix-align/process/css/with-comment-property-2.expected.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment-property-2.expected.css rename to test/options/vendor-prefix-align/process/css/with-comment-property-2.expected.css diff --git a/test/options/vendor-prefix-align/with-comment-property.css b/test/options/vendor-prefix-align/process/css/with-comment-property.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment-property.css rename to test/options/vendor-prefix-align/process/css/with-comment-property.css diff --git a/test/options/vendor-prefix-align/with-comment-property.expected.css b/test/options/vendor-prefix-align/process/css/with-comment-property.expected.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment-property.expected.css rename to test/options/vendor-prefix-align/process/css/with-comment-property.expected.css diff --git a/test/options/vendor-prefix-align/with-comment.css b/test/options/vendor-prefix-align/process/css/with-comment.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment.css rename to test/options/vendor-prefix-align/process/css/with-comment.css diff --git a/test/options/vendor-prefix-align/with-comment.expected.css b/test/options/vendor-prefix-align/process/css/with-comment.expected.css similarity index 100% rename from test/options/vendor-prefix-align/with-comment.expected.css rename to test/options/vendor-prefix-align/process/css/with-comment.expected.css diff --git a/test/options/vendor-prefix-align/without-space.css b/test/options/vendor-prefix-align/process/css/without-space.css similarity index 100% rename from test/options/vendor-prefix-align/without-space.css rename to test/options/vendor-prefix-align/process/css/without-space.css diff --git a/test/options/vendor-prefix-align/without-space.expected.css b/test/options/vendor-prefix-align/process/css/without-space.expected.css similarity index 100% rename from test/options/vendor-prefix-align/without-space.expected.css rename to test/options/vendor-prefix-align/process/css/without-space.expected.css diff --git a/test/options/vendor-prefix-align-sass/property.sass b/test/options/vendor-prefix-align/process/sass/property.sass similarity index 100% rename from test/options/vendor-prefix-align-sass/property.sass rename to test/options/vendor-prefix-align/process/sass/property.sass diff --git a/test/options/vendor-prefix-align-sass/test.js b/test/options/vendor-prefix-align/process/sass/test.js similarity index 88% rename from test/options/vendor-prefix-align-sass/test.js rename to test/options/vendor-prefix-align/process/sass/test.js index ffead985..80a2b7d6 100644 --- a/test/options/vendor-prefix-align-sass/test.js +++ b/test/options/vendor-prefix-align/process/sass/test.js @@ -1,4 +1,4 @@ -describe('options/vendor-prefix-align', function() { +describe.skip('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); diff --git a/test/options/vendor-prefix-align-sass/value.expected.sass b/test/options/vendor-prefix-align/process/sass/value.expected.sass similarity index 100% rename from test/options/vendor-prefix-align-sass/value.expected.sass rename to test/options/vendor-prefix-align/process/sass/value.expected.sass diff --git a/test/options/vendor-prefix-align-sass/value.sass b/test/options/vendor-prefix-align/process/sass/value.sass similarity index 100% rename from test/options/vendor-prefix-align-sass/value.sass rename to test/options/vendor-prefix-align/process/sass/value.sass diff --git a/test/options/vendor-prefix-align/test.js b/test/options/vendor-prefix-align/process/test.js similarity index 99% rename from test/options/vendor-prefix-align/test.js rename to test/options/vendor-prefix-align/process/test.js index ce4bf182..e4b4dd72 100644 --- a/test/options/vendor-prefix-align/test.js +++ b/test/options/vendor-prefix-align/process/test.js @@ -1,4 +1,4 @@ -describe('options/vendor-prefix-align', function() { +describe.skip('options/vendor-prefix-align', function() { beforeEach(function() { this.comb.configure({ 'vendor-prefix-align': true }); }); diff --git a/test/test_helpers.js b/test/test_helpers.js new file mode 100644 index 00000000..1742c686 --- /dev/null +++ b/test/test_helpers.js @@ -0,0 +1,64 @@ +let assert = require('assert'); +let fs = require('fs'); +let path = require('path'); + +let Comb = process.env.TEST_COV ? + require('../lib-cov/csscomb') : require('../lib/csscomb'); + +let helpers = { + getErrors(filename) { + let syntax = filename.split('.').pop(); + let input = helpers.readFile.call(this, filename); + return this.comb.lintString(input, {syntax: syntax}); + }, + + shouldBeEqual(input, expected) { + let syntax = input.split('.').pop(); + input = helpers.readFile.call(this, input); + expected = expected ? helpers.readFile.call(this, expected) : input; + return this.comb.processString(input, {syntax: syntax}) + .then(function(string) { + assert.equal(string, expected); + }); + }, + + /** + * Detect options in a file and compare result with expected. + * File names should be relative to test suite's folder. + * @param {Array} options List of options that should be detected + * @param {String} input Name of template file + * @param {Object} expected Expected config with detected options + */ + shouldDetect(options, input, expected) { + // We need to “sort” the input and expected objects, as their order + // may vary. + let actual = helpers.sortObject(Comb.detectInString(input, options)); + assert.equal( + JSON.stringify(helpers.sortObject(actual)), + JSON.stringify(helpers.sortObject(expected)) + ); + }, + + readFile(filename) { + let dirname = path.dirname(this.test.file); + return fs.readFileSync(dirname + '/' + filename, 'utf8'); + }, + + sortObject(o) { + let a = []; + for (let key in o) { + if (o.hasOwnProperty(key)) { + a.push(key); + } + } + a.sort(); + + let sorted = {}; + for (let key = 0; key < a.length; key++) { + sorted[a[key]] = o[a[key]]; + } + return sorted; + } +}; + +module.exports = helpers; From 26483abfa43b52af0ca8958f966f6c20cbbffe4c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 19 Aug 2015 18:56:30 +0300 Subject: [PATCH 105/184] [tools] Clean up linters --- .editorconfig | 6 ++++++ .jscs.json | 2 +- .jshint-groups.js | 9 +++++++-- .jshintrc | 13 +++++++++++++ package.json | 1 - 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 .jshintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..5b42e032 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +# EditorConfig is awesome: http://EditorConfig.org +root = true + +[*] +indent_style = space +indent_size = 2 diff --git a/.jscs.json b/.jscs.json index e0c60ef1..c78d27a0 100644 --- a/.jscs.json +++ b/.jscs.json @@ -47,7 +47,7 @@ ], "requireSpaceBetweenArguments": true, "requireSpacesInForStatement": true, - "validateIndentation": 4, + "validateIndentation": 2, "validateJSDoc": { "checkParamNames": true, "checkRedundantParams": true, diff --git a/.jshint-groups.js b/.jshint-groups.js index 7092a478..14e491ee 100644 --- a/.jshint-groups.js +++ b/.jshint-groups.js @@ -1,5 +1,11 @@ module.exports = { options: { + globals: { + afterEach: false, + beforeEach: false, + describe: false, + it: false + }, eqeqeq: true, esnext: true, expr: true, @@ -10,8 +16,7 @@ module.exports = { nonew: true, trailing: true, undef: true, - unused: true, - //varstmt: true + unused: true }, groups: { src: { diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..b8833b04 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,13 @@ +{ + "globals": { + "afterEach": false, + "beforeEach": false, + "describe": false, + "it": false + }, + "esnext": true, + "node": true, + "undef": true, + "unused": true, + "-W084": true +} diff --git a/package.json b/package.json index 42d92506..d0c2b3fe 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "babel": "^5.5.3", "jscs": "1.13.1", "jshint": "2.8.0", - "jshint-groups": "0.5.3", "mocha": "1.20.1" }, "main": "./lib/csscomb.js", From ba5bde4a820954fbe3574ee1f067e00eb0014df9 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 21 Aug 2015 12:26:16 +0300 Subject: [PATCH 106/184] [tests] Refactor tests --- test/mocha.js | 23 +- test/options/always-semicolon/detect/test.js | 25 +- test/options/always-semicolon/lint/test.js | 19 +- test/options/always-semicolon/process/test.js | 138 ++-- .../detect/css/test-3.expected.css | 36 + test/options/block-indent/detect/css/test.css | 30 + test/options/block-indent/detect/test.js | 49 ++ test/options/block-indent/lint/test.js | 4 + .../options/block-indent/process/sass/test.js | 19 - .../options/block-indent/process/scss/test.js | 8 - test/options/block-indent/process/test.js | 105 ++- test/options/color-case/detect/test.js | 59 ++ test/options/color-case/lint/test.js | 0 test/options/color-case/process/test.js | 128 +--- test/options/color-shorthand/detect/css | 0 test/options/color-shorthand/detect/test.js | 41 ++ test/options/color-shorthand/lint/css | 0 test/options/color-shorthand/lint/test.js | 0 test/options/color-shorthand/process/test.js | 89 +-- test/options/element-case/detect/test.js | 60 ++ test/options/element-case/lint/test.js | 0 .../options/element-case/process/scss/test.js | 8 - test/options/element-case/process/test.js | 132 ++-- test/options/eof-newline/detect/test.js | 42 ++ test/options/eof-newline/lint/test.js | 0 test/options/eof-newline/process/test.js | 93 +-- .../integral/detect/css/integral.expected.css | 151 +++++ test/options/integral/detect/test.js | 15 + test/options/integral/lint/test.js | 0 test/options/integral/process/test.js | 43 +- test/options/leading-zero/detect/test.js | 33 + test/options/leading-zero/lint/test.js | 0 test/options/leading-zero/process/test.js | 65 +- test/options/option_test.js | 54 ++ test/options/quotes/detect/test.js | 51 ++ test/options/quotes/lint/test.js | 0 test/options/quotes/process/test.js | 151 ++--- .../remove-empty-rulesets/detect/test.js | 78 +++ .../remove-empty-rulesets/lint/test.js | 0 .../process/less/test.js | 31 - .../process/scss/test.js | 23 - .../remove-empty-rulesets/process/test.js | 193 +++--- .../sort-order-fallback/detect/test.js | 0 test/options/sort-order-fallback/lint/test.js | 0 .../sort-order-fallback/process/test.js | 60 +- test/options/sort-order/detect/test.js | 0 test/options/sort-order/lint/test.js | 0 test/options/sort-order/process/less/test.js | 108 --- test/options/sort-order/process/sass/test.js | 116 ---- test/options/sort-order/process/scss/test.js | 136 ---- test/options/sort-order/process/test.js | 614 ++++++++++++++---- test/options/space-after-colon/detect/test.js | 43 ++ test/options/space-after-colon/lint/test.js | 0 .../space-after-colon/process/sass/test.js | 13 - .../space-after-colon/process/scss/test.js | 8 - .../options/space-after-colon/process/test.js | 97 ++- .../space-after-combinator/detect/test.js | 61 ++ .../space-after-combinator/lint/test.js | 0 .../space-after-combinator/process/test.js | 101 +-- .../space-after-opening-brace/detect/test.js | 59 ++ .../space-after-opening-brace/lint/test.js | 0 .../space-after-opening-brace/process/test.js | 108 +-- .../detect/test.js | 59 ++ .../lint/test.js | 0 .../process/sass/test.js | 8 - .../process/test.js | 105 +-- .../space-before-closing-brace/detect/test.js | 50 ++ .../space-before-closing-brace/lint/test.js | 0 .../process/test.js | 92 +-- .../options/space-before-colon/detect/test.js | 43 ++ test/options/space-before-colon/lint/test.js | 0 .../space-before-colon/process/sass/test.js | 14 - .../space-before-colon/process/test.js | 92 +-- .../space-before-combinator/detect/test.js | 61 ++ .../space-before-combinator/lint/test.js | 0 .../space-before-combinator/process/test.js | 109 +--- .../space-before-opening-brace/detect/test.js | 59 ++ .../space-before-opening-brace/lint/test.js | 0 .../process/scss/test.js | 13 - .../process/test.js | 117 ++-- .../detect/test.js | 59 ++ .../lint/test.js | 0 .../process/test.js | 100 +-- .../space-between-declarations/detect/test.js | 0 .../space-between-declarations/lint/test.js | 0 .../process/test.js | 94 +-- test/options/strip-spaces/detect/test.js | 77 +++ test/options/strip-spaces/lint/test.js | 0 test/options/strip-spaces/process/test.js | 143 +--- test/options/tab-size/detect/test.js | 0 test/options/tab-size/lint/test.js | 0 test/options/tab-size/process/test.js | 30 +- test/options/unitless-zero/detect/test.js | 69 ++ test/options/unitless-zero/lint/test.js | 0 test/options/unitless-zero/process/test.js | 137 +--- .../detect/css/already-aligned.css | 11 + .../detect/css/complex.css | 30 + .../detect/css/complex.expected.css | 30 + .../detect/css/property-align.css | 8 + .../detect/css/property-align.expected.css | 8 + .../detect/css/value-align.css | 10 + .../detect/css/value-align.expected.css | 10 + .../vendor-prefix-align/detect/test.js | 86 +++ test/options/vendor-prefix-align/lint/test.js | 0 .../vendor-prefix-align/process/sass/test.js | 15 - .../vendor-prefix-align/process/test.js | 250 +++---- test/test_helpers.js | 64 -- 107 files changed, 3007 insertions(+), 2566 deletions(-) create mode 100644 test/options/block-indent/detect/css/test-3.expected.css create mode 100644 test/options/block-indent/detect/css/test.css create mode 100644 test/options/block-indent/detect/test.js create mode 100644 test/options/block-indent/lint/test.js delete mode 100644 test/options/block-indent/process/sass/test.js delete mode 100644 test/options/block-indent/process/scss/test.js create mode 100644 test/options/color-case/detect/test.js create mode 100644 test/options/color-case/lint/test.js create mode 100644 test/options/color-shorthand/detect/css create mode 100644 test/options/color-shorthand/detect/test.js create mode 100644 test/options/color-shorthand/lint/css create mode 100644 test/options/color-shorthand/lint/test.js create mode 100644 test/options/element-case/detect/test.js create mode 100644 test/options/element-case/lint/test.js delete mode 100644 test/options/element-case/process/scss/test.js create mode 100644 test/options/eof-newline/detect/test.js create mode 100644 test/options/eof-newline/lint/test.js create mode 100644 test/options/integral/detect/css/integral.expected.css create mode 100644 test/options/integral/detect/test.js create mode 100644 test/options/integral/lint/test.js create mode 100644 test/options/leading-zero/detect/test.js create mode 100644 test/options/leading-zero/lint/test.js create mode 100644 test/options/option_test.js create mode 100644 test/options/quotes/detect/test.js create mode 100644 test/options/quotes/lint/test.js create mode 100644 test/options/remove-empty-rulesets/detect/test.js create mode 100644 test/options/remove-empty-rulesets/lint/test.js delete mode 100644 test/options/remove-empty-rulesets/process/less/test.js delete mode 100644 test/options/remove-empty-rulesets/process/scss/test.js create mode 100644 test/options/sort-order-fallback/detect/test.js create mode 100644 test/options/sort-order-fallback/lint/test.js create mode 100644 test/options/sort-order/detect/test.js create mode 100644 test/options/sort-order/lint/test.js delete mode 100644 test/options/sort-order/process/less/test.js delete mode 100644 test/options/sort-order/process/sass/test.js delete mode 100644 test/options/sort-order/process/scss/test.js create mode 100644 test/options/space-after-colon/detect/test.js create mode 100644 test/options/space-after-colon/lint/test.js delete mode 100644 test/options/space-after-colon/process/sass/test.js delete mode 100644 test/options/space-after-colon/process/scss/test.js create mode 100644 test/options/space-after-combinator/detect/test.js create mode 100644 test/options/space-after-combinator/lint/test.js create mode 100644 test/options/space-after-opening-brace/detect/test.js create mode 100644 test/options/space-after-opening-brace/lint/test.js create mode 100644 test/options/space-after-selector-delimiter/detect/test.js create mode 100644 test/options/space-after-selector-delimiter/lint/test.js delete mode 100644 test/options/space-after-selector-delimiter/process/sass/test.js create mode 100644 test/options/space-before-closing-brace/detect/test.js create mode 100644 test/options/space-before-closing-brace/lint/test.js create mode 100644 test/options/space-before-colon/detect/test.js create mode 100644 test/options/space-before-colon/lint/test.js delete mode 100644 test/options/space-before-colon/process/sass/test.js create mode 100644 test/options/space-before-combinator/detect/test.js create mode 100644 test/options/space-before-combinator/lint/test.js create mode 100644 test/options/space-before-opening-brace/detect/test.js create mode 100644 test/options/space-before-opening-brace/lint/test.js delete mode 100644 test/options/space-before-opening-brace/process/scss/test.js create mode 100644 test/options/space-before-selector-delimiter/detect/test.js create mode 100644 test/options/space-before-selector-delimiter/lint/test.js create mode 100644 test/options/space-between-declarations/detect/test.js create mode 100644 test/options/space-between-declarations/lint/test.js create mode 100644 test/options/strip-spaces/detect/test.js create mode 100644 test/options/strip-spaces/lint/test.js create mode 100644 test/options/tab-size/detect/test.js create mode 100644 test/options/tab-size/lint/test.js create mode 100644 test/options/unitless-zero/detect/test.js create mode 100644 test/options/unitless-zero/lint/test.js create mode 100644 test/options/vendor-prefix-align/detect/css/already-aligned.css create mode 100644 test/options/vendor-prefix-align/detect/css/complex.css create mode 100644 test/options/vendor-prefix-align/detect/css/complex.expected.css create mode 100644 test/options/vendor-prefix-align/detect/css/property-align.css create mode 100644 test/options/vendor-prefix-align/detect/css/property-align.expected.css create mode 100644 test/options/vendor-prefix-align/detect/css/value-align.css create mode 100644 test/options/vendor-prefix-align/detect/css/value-align.expected.css create mode 100644 test/options/vendor-prefix-align/detect/test.js create mode 100644 test/options/vendor-prefix-align/lint/test.js delete mode 100644 test/options/vendor-prefix-align/process/sass/test.js delete mode 100644 test/test_helpers.js diff --git a/test/mocha.js b/test/mocha.js index 4fbf3be8..98e0ee7b 100644 --- a/test/mocha.js +++ b/test/mocha.js @@ -1,32 +1,17 @@ let glob = require('glob'); let Mocha = require('mocha'); -let Comb = process.env.TEST_COV ? - require('../lib-cov/csscomb') : require('../lib/csscomb'); -let helpers = require('./test_helpers'); - let mocha = new Mocha(); -//mocha.reporter('spec'); if (process.env.TEST_COV) mocha.reporter('html-cov'); // Tell mocha which tests to run: glob.sync('test/**/test.js').forEach(file => { - mocha.addFile(file); -}); - -// Add helpers (see tests for usage examples): -mocha.suite.beforeEach(function() { - this.Comb = Comb; - this.comb = new Comb(); - this.readFile = helpers.readFile; - this.shouldBeEqual = helpers.shouldBeEqual; - this.shouldDetect = helpers.shouldDetect; - this.getErrors = helpers.getErrors; + mocha.addFile(file); }); mocha.run(failures => { - process.on('exit', () => { - process.exit(failures); - }); + process.on('exit', () => { + process.exit(failures); + }); }); diff --git a/test/options/always-semicolon/detect/test.js b/test/options/always-semicolon/detect/test.js index a6e0c367..6d22001a 100644 --- a/test/options/always-semicolon/detect/test.js +++ b/test/options/always-semicolon/detect/test.js @@ -1,7 +1,10 @@ +let Test = require('../../option_test'); + describe('Option `always-semicolon`, detect', function() { - describe('CSS', function() { + describe('css', function() { it('Should detect semicolon for last property. Test 1', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div { height: 0 }', {'always-semicolon': false} @@ -9,7 +12,8 @@ describe('Option `always-semicolon`, detect', function() { }); it('Should detect semicolon for last property. Test 2', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div { height: 0; }', {'always-semicolon': true} @@ -17,7 +21,8 @@ describe('Option `always-semicolon`, detect', function() { }); it('Should detect semicolon for last property. Test 3', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div { height: 0; } div { height: 0 }', {'always-semicolon': true} @@ -25,7 +30,8 @@ describe('Option `always-semicolon`, detect', function() { }); it('Should detect semicolon for last property. Test 4', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div { height: 0 } div { height: 0; } div { height: 0 }', {'always-semicolon': false} @@ -33,7 +39,8 @@ describe('Option `always-semicolon`, detect', function() { }); it('Should detect semicolon for last property. Test 5', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div {\nheight: 0 /* Comment */\n} ' + 'div { height: 0; }' + @@ -44,7 +51,8 @@ describe('Option `always-semicolon`, detect', function() { it('Should detect semicolon for last property. Test 6', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'a{\n border:0;\n}', {'always-semicolon': true} @@ -52,7 +60,8 @@ describe('Option `always-semicolon`, detect', function() { }); it('Should not detect semicolon for last property if there are no properties', function() { - this.shouldDetect( + let test = new Test(this); + test.shouldDetect( ['always-semicolon'], 'div {}', {} diff --git a/test/options/always-semicolon/lint/test.js b/test/options/always-semicolon/lint/test.js index b565152c..80cb27de 100644 --- a/test/options/always-semicolon/lint/test.js +++ b/test/options/always-semicolon/lint/test.js @@ -1,25 +1,26 @@ let assert = require('assert'); +let Test = require('../../option_test'); describe('Option `always-semicolon`, lint', function() { - describe('CSS', function() { + describe('css', function() { it('Should report no errors', function() { - this.comb.configure({'always-semicolon': true}); - return this.getErrors('css/lint-1.css').then(errors => { + let test = new Test(this, {'always-semicolon': true}); + return test.getErrors('lint-1.css').then(errors => { assert.equal(errors.length, 0); }); }); it('Error mesage should be a string', function() { - this.comb.configure({'always-semicolon': true}); - return this.getErrors('css/lint-2.css').then(errors => { + let test = new Test(this, {'always-semicolon': true}); + return test.getErrors('lint-2.css').then(errors => { let error = errors[0]; assert.equal(typeof error.message, 'string'); }); }); it('Error should provide correct position info', function() { - this.comb.configure({'always-semicolon': true}); - return this.getErrors('css/lint-2.css').then(errors => { + let test = new Test(this, {'always-semicolon': true}); + return test.getErrors('lint-2.css').then(errors => { let error = errors[0]; assert.equal(error.line, 1); assert.equal(error.column, 16); @@ -27,8 +28,8 @@ describe('Option `always-semicolon`, lint', function() { }); it('Should report multiple errors', function() { - this.comb.configure({'always-semicolon': true}); - return this.getErrors('css/lint-3.css').then(errors => { + let test = new Test(this, {'always-semicolon': true}); + return test.getErrors('lint-3.css').then(errors => { assert.equal(errors.length, 2); assert.equal(errors[0].line, 2); diff --git a/test/options/always-semicolon/process/test.js b/test/options/always-semicolon/process/test.js index ceb4b994..99415b36 100644 --- a/test/options/always-semicolon/process/test.js +++ b/test/options/always-semicolon/process/test.js @@ -1,169 +1,171 @@ +let Test = require('../../option_test'); + describe('Option `always-semicolon`, process', function() { - describe('CSS', function() { + describe('css', function() { it('Should add semicolon for last property if missing. Test 1', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('css/test-1.css', 'css/test-1.expected.css'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test-1.css', 'test-1.expected.css'); }); it('Should add semicolon for last property if missing. Test 2', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('css/test-2.css', 'css/test-2.expected.css'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test-2.css', 'test-2.expected.css'); }); it('Should add semicolon for last property if missing. Test 3', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('css/test-3.css', 'css/test-3.expected.css'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test-3.css', 'test-3.expected.css'); }); it('Should add semicolon for last property if missing. Test 4', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('css/test-4.css', 'css/test-4.expected.css'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test-4.css', 'test-4.expected.css'); }); it('Should add semicolon for last property if missing. Test 5', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('css/test-5.css', 'css/test-5.expected.css'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test-5.css', 'test-5.expected.css'); }); }); - describe('LESS', function() { + describe('less', function() { it('Should not add semicolon to condition (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/condition.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('condition.less'); }); it('Should not add semicolon to condition (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/condition-multiline.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('condition-multiline.less'); }); it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-1.less', 'less/include-1.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-1.less', 'include-1.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-1-multiline.less', 'less/include-1-multiline.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-1-multiline.less', 'include-1-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-2.less', 'less/include-2.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-2.less', 'include-2.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-2-multiline.less', 'less/include-2-multiline.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-2-multiline.less', 'include-2-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 3 (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-3.less', 'less/include-3.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-3.less', 'include-3.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 3 (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-3-multiline.less', 'less/include-3-multiline.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-3-multiline.less', 'include-3-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 4 (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-4.less', 'less/include-4.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-4.less', 'include-4.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 4 (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-4-multiline.less', 'less/include-4-multiline.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-4-multiline.less', 'include-4-multiline.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 5 (single-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-5.less', 'less/include-5.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-5.less', 'include-5.expected.less'); }); it('Should add semicolon to last included mixin if missing. Test 5 (multi-line style)', function() { - this.comb.configure({'always-semicolon':true}); - return this.shouldBeEqual('less/include-5-multiline.less', 'less/include-5-multiline.expected.less'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-5-multiline.less', 'include-5-multiline.expected.less'); }); }); - describe('Sass', function() { + describe('sass', function() { it('Should not add semicolon', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('sass/test.sass'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('test.sass'); }); }); - describe('SCSS', function() { + describe('scss', function() { it('Should not add semicolon if last value is block (singl-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/block-value.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('block-value.scss'); }); it('Should not add semicolon if last value is block (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/block-value-multiline.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('block-value-multiline.scss'); }); it('Should add semicolon to last included mixin if missing. Test 1 (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/include-1.scss', 'scss/include-1.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-1.scss', 'include-1.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 1 (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/include-1-multiline.scss', 'scss/include-1-multiline.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-1-multiline.scss', 'include-1-multiline.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 2 (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/include-2.scss', 'scss/include-2.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-2.scss', 'include-2.expected.scss'); }); it('Should add semicolon to last included mixin if missing. Test 2 (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/include-2-multiline.scss', 'scss/include-2-multiline.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('include-2-multiline.scss', 'include-2-multiline.expected.scss'); }); it('Should not add semicolon to last included mixin if there is a block (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/block-include.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('block-include.scss'); }); it('Should not add semicolon to last included mixin if there is a block (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/block-include-multiline.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('block-include-multiline.scss'); }); it('Should add semicolon to last extend if missing (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/extend.scss', 'scss/extend.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('extend.scss', 'extend.expected.scss'); }); it('Should add semicolon to last extend if missing (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/extend-multiline.scss', 'scss/extend-multiline.expected.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('extend-multiline.scss', 'extend-multiline.expected.scss'); }); it('Should not add semicolon to condition (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/condition.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('condition.scss'); }); it('Should not add semicolon to condition (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/condition-multiline.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('condition-multiline.scss'); }); it('Should not add semicolon to loop (single-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/loop.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('loop.scss'); }); it('Should not add semicolon to loop (multi-line style)', function() { - this.comb.configure({'always-semicolon': true}); - return this.shouldBeEqual('scss/loop-multiline.scss'); + let test = new Test(this, {'always-semicolon': true}); + return test.shouldBeEqual('loop-multiline.scss'); }); }); }); diff --git a/test/options/block-indent/detect/css/test-3.expected.css b/test/options/block-indent/detect/css/test-3.expected.css new file mode 100644 index 00000000..684ff987 --- /dev/null +++ b/test/options/block-indent/detect/css/test-3.expected.css @@ -0,0 +1,36 @@ +a {color: tomato; top: 0; +} + +a { color: tomato; + top: 0; +} + +a { color: tomato; + top: 0; +} + +a { + color: tomato; + top: 0; +} + +a { + color: tomato; + top: 0; +} + +a { + color: tomato; + top: 0; +} + +@media print { a {color: tomato; top: 0; + } +} + +@media print { + a { + color: tomato; + top: 0; + } +} diff --git a/test/options/block-indent/detect/css/test.css b/test/options/block-indent/detect/css/test.css new file mode 100644 index 00000000..b1b52eb3 --- /dev/null +++ b/test/options/block-indent/detect/css/test.css @@ -0,0 +1,30 @@ +a {color: tomato; top: 0;} + +a { color: tomato; +top: 0; } + +a { color: tomato; + top: 0; } + +a { +color: tomato; +top: 0; } + +a { +color: tomato; +top: 0; +} + + a { + color: tomato; + top: 0; + } + +@media print { a {color: tomato; top: 0; } } + + @media print { +a { + color: tomato; + top: 0; + } + } diff --git a/test/options/block-indent/detect/test.js b/test/options/block-indent/detect/test.js new file mode 100644 index 00000000..6035c3d8 --- /dev/null +++ b/test/options/block-indent/detect/test.js @@ -0,0 +1,49 @@ +let Test = require('../../option_test'); + +describe('Option `block-indent`, detect', function() { + describe('css', function() { + it('Should detect nothing with an empty block, test 1', function() { + let test = new Test(this); + test.shouldDetect( + ['block-indent'], + 'a{ }', + {} + ); + }); + + it('Should detect nothing with an empty block, test 2', function() { + let test = new Test(this); + test.shouldDetect( + ['block-indent'], + 'a{}', + {} + ); + }); + + it('Should detect correct number of spaces', function() { + let test = new Test(this); + test.shouldDetect( + ['block-indent'], + 'a{\n top: 0;\n color: tomato;\n}', + {'block-indent': ' '} + ); + }); + + it('Should detect no indent for one-line code', function() { + let test = new Test(this); + test.shouldDetect( + ['block-indent'], + 'a{ top: 0; color: tomato; }', + {} + ); + }); + + it('Valid string value => should set proper space after combnator', function() { + let test = new Test(this, { + 'block-indent': ' ', + 'space-before-closing-brace': '\n' + }); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); + }); +}); diff --git a/test/options/block-indent/lint/test.js b/test/options/block-indent/lint/test.js new file mode 100644 index 00000000..231e4209 --- /dev/null +++ b/test/options/block-indent/lint/test.js @@ -0,0 +1,4 @@ +describe('Option `block-indent`, lint', function() { + describe('css', function() { + }); +}); diff --git a/test/options/block-indent/process/sass/test.js b/test/options/block-indent/process/sass/test.js deleted file mode 100644 index 17a74581..00000000 --- a/test/options/block-indent/process/sass/test.js +++ /dev/null @@ -1,19 +0,0 @@ -describe.skip('options/block-indent (sass):', function() { - describe('process', function() { - it('First level ruleset\'s block', function() { - this.comb.configure({ 'block-indent': 2 }); - return this.shouldBeEqual('block.sass', 'block.expected.sass'); - }); - - it('Nested ruleset', function() { - this.comb.configure({ 'block-indent': 2 }); - return this.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); - }); - - it('Mixin', function() { - this.comb.configure({ 'block-indent': 4 }); - return this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); - }); - }); -}); - diff --git a/test/options/block-indent/process/scss/test.js b/test/options/block-indent/process/scss/test.js deleted file mode 100644 index 64e23760..00000000 --- a/test/options/block-indent/process/scss/test.js +++ /dev/null @@ -1,8 +0,0 @@ -describe.skip('options/block-indent (scss):', function() { - describe('process', function() { - it('Issue 213', function() { - this.comb.configure({ 'block-indent': 2 }); - return this.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); - }); - }); -}); diff --git a/test/options/block-indent/process/test.js b/test/options/block-indent/process/test.js index 2aed90e8..3f61e4a6 100644 --- a/test/options/block-indent/process/test.js +++ b/test/options/block-indent/process/test.js @@ -1,72 +1,59 @@ -describe.skip('options/block-indent:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'block-indent': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'block-indent': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); +describe('Option `block-indent`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'block-indent': ['', ' ']}); + return test.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'block-indent': 3.5 }); - return this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'block-indent': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper number of spaces', function() { - this.comb.configure({ 'block-indent': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'block-indent': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Valid string value => should set proper number of spaces', function() { - this.comb.configure({ 'block-indent': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Integer value => should set proper number of spaces', function() { + let test = new Test(this, {'block-indent': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Issue 379', function() { - this.comb.configure({ 'block-indent': 4 }); - return this.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); - }); + it('Valid string value => should set proper number of spaces', function() { + let test = new Test(this, {'block-indent': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); }); - describe('detect', function() { - it('Should detect nothing with an empty block, test 1', function() { - this.shouldDetect( - ['block-indent'], - 'a{ }', - {} - ); - }); + it('Issue 379', function() { + let test = new Test(this, {'block-indent': 4}); + return test.shouldBeEqual('issue-379.css', 'issue-379.expected.css'); + }); + }); - it('Should detect nothing with an empty block, test 2', function() { - this.shouldDetect( - ['block-indent'], - 'a{}', - {} - ); - }); + describe('sass', function() { + it('First level ruleset\'s block', function() { + let test = new Test(this, {'block-indent': 2}); + return test.shouldBeEqual('block.sass', 'block.expected.sass'); + }); - it('Should detect correct number of spaces', function() { - this.shouldDetect( - ['block-indent'], - 'a{\n top: 0;\n color: tomato;\n}', - { 'block-indent': ' ' } - ); - }); + it('Nested ruleset', function() { + let test = new Test(this, {'block-indent': 2}); + return test.shouldBeEqual('nested-ruleset.sass', 'nested-ruleset.expected.sass'); + }); - it('Should detect no indent for one-line code', function() { - this.shouldDetect( - ['block-indent'], - 'a{ top: 0; color: tomato; }', - {} - ); - }); + it('Mixin', function() { + let test = new Test(this, {'block-indent': 4}); + return test.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + }); + }); - it('Valid string value => should set proper space after combnator', function() { - this.comb.configure({ 'block-indent': ' ', 'space-before-closing-brace': '\n' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + describe('scss', function() { + it('Issue 213', function() { + let test = new Test(this, {'block-indent': 2}); + return test.shouldBeEqual('nested-include.scss', 'nested-include.expected.scss'); }); + }); }); diff --git a/test/options/color-case/detect/test.js b/test/options/color-case/detect/test.js new file mode 100644 index 00000000..cc075c37 --- /dev/null +++ b/test/options/color-case/detect/test.js @@ -0,0 +1,59 @@ +let Test = require('../../option_test'); + +describe('Option `block-indent`, detect', function() { + describe('css', function() { + it('Should detect uppercase color', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #F3F3F3 }', + {'color-case': 'upper'} + ); + }); + + it('Should detect lowercase color', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #f6f6f6 }', + {'color-case': 'lower'} + ); + }); + + it('Should detect uppercase color in a shorthand', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #FFF }', + {'color-case': 'upper'} + ); + }); + + it('Should detect lowercase color in a shorthand', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #fff }', + {'color-case': 'lower'} + ); + }); + + it('Shouldn’t detect color case if it contains only digits', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #333 }', + {} + ); + }); + + it('Shouldn’t detect color case if it is in mixed case', function() { + let test = new Test(this); + test.shouldDetect( + ['color-case'], + 'a { color: #fFfFfF }', + {} + ); + }); + }); +}); diff --git a/test/options/color-case/lint/test.js b/test/options/color-case/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/color-case/process/test.js b/test/options/color-case/process/test.js index 790736b4..3b8ae697 100644 --- a/test/options/color-case/process/test.js +++ b/test/options/color-case/process/test.js @@ -1,100 +1,40 @@ -var assert = require('assert'); - -describe.skip('options/color-case', function() { - describe('process', function() { - it('Should switch colors to upper case', function() { - this.comb.configure({ 'color-case': 'upper' }); - return this.comb.processString( - 'div { color: #fff }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #FFF }'); - }); - }); - - it('Should switch colors to lower case', function() { - this.comb.configure({ 'color-case': 'lower' }); - return this.comb.processString( - 'div { color: #FFF }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #fff }'); - }); - }); - - it('Should switch color-case in complex rules', function() { - this.comb.configure({ 'color-case': 'lower' }); - this.comb.processString( - 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + - ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' - ).then(function(actual) { - assert.equal(actual, 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat; box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }'); - }); - }); - - it('Should not switch selector case', function() { - this.comb.configure({ 'color-case': 'lower' }); - return this.comb.processString( - '#Header { color: #FFF }' - ).then(function(actual) { - assert.equal(actual, '#Header { color: #fff }'); - }); - }); +let assert = require('assert'); +let Test = require('../../option_test'); + +describe('Option `color-case`, process', function() { + describe('css', function() { + it('Should switch colors to upper case', function() { + let test = new Test(this, {'color-case': 'upper'}); + return test.comb.processString('div { color: #fff }') + .then(actual => { + assert.equal(actual, 'div { color: #FFF }'); + }); }); - describe('detect', function() { - it('Should detect uppercase color', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #F3F3F3 }', - { - 'color-case': 'upper' - } - ); - }); - - it('Should detect lowercase color', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #f6f6f6 }', - { - 'color-case': 'lower' - } - ); - }); - - it('Should detect uppercase color in a shorthand', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #FFF }', - { - 'color-case': 'upper' - } - ); - }); - - it('Should detect lowercase color in a shorthand', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #fff }', - { - 'color-case': 'lower' - } - ); - }); + it('Should switch colors to lower case', function() { + let test = new Test(this, {'color-case': 'lower'}); + return test.comb.processString('div { color: #FFF }') + .then(actual => { + assert.equal(actual, 'div { color: #fff }'); + }); + }); - it('Shouldn’t detect color case if it contains only digits', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #333 }', - {} - ); - }); + it('Should switch color-case in complex rules', function() { + let test = new Test(this, {'color-case': 'lower'}); + return test.comb.processString( + 'div { background: url(img.png#RND) #E3E3E3 0 100% no-repeat;' + + ' box-shadow: 1px 2px 3px 4px #F0F0F0 inset; }' + ).then(actual => { + assert.equal(actual, 'div { background: url(img.png#RND) #e3e3e3 0 100% no-repeat; box-shadow: 1px 2px 3px 4px #f0f0f0 inset; }'); + }); + }); - it('Shouldn’t detect color case if it is in mixed case', function() { - this.shouldDetect( - ['color-case'], - 'a { color: #fFfFfF }', - {} - ); - }); + it('Should not switch selector case', function() { + let test = new Test(this, {'color-case': 'lower'}); + return test.comb.processString('#Header { color: #FFF }') + .then(function(actual) { + assert.equal(actual, '#Header { color: #fff }'); + }); }); + }); }); diff --git a/test/options/color-shorthand/detect/css b/test/options/color-shorthand/detect/css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/color-shorthand/detect/test.js b/test/options/color-shorthand/detect/test.js new file mode 100644 index 00000000..59e46933 --- /dev/null +++ b/test/options/color-shorthand/detect/test.js @@ -0,0 +1,41 @@ +let Test = require('../../option_test'); + +describe('Option `color-shorthand`, detect', function() { + describe('css', function() { + it('Should detect non-shorthanded color', function() { + let test = new Test(this); + test.shouldDetect( + ['color-shorthand'], + 'a { color: #FF33EE }', + {'color-shorthand': false} + ); + }); + + it('Should detect shorthanded color', function() { + let test = new Test(this); + test.shouldDetect( + ['color-shorthand'], + 'a { color: #fff }', + {'color-shorthand': true} + ); + }); + + it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { + let test = new Test(this); + test.shouldDetect( + ['color-shorthand'], + 'a { color: #F3F3F3 }', + {} + ); + }); + + it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { + let test = new Test(this); + test.shouldDetect( + ['color-shorthand'], + 'a { color: rgba(0,0,0,0.5) }', + {} + ); + }); + }); +}); diff --git a/test/options/color-shorthand/lint/css b/test/options/color-shorthand/lint/css new file mode 100644 index 00000000..e69de29b diff --git a/test/options/color-shorthand/lint/test.js b/test/options/color-shorthand/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/color-shorthand/process/test.js b/test/options/color-shorthand/process/test.js index fd2bd3e3..b9b1be7a 100644 --- a/test/options/color-shorthand/process/test.js +++ b/test/options/color-shorthand/process/test.js @@ -1,70 +1,33 @@ var assert = require('assert'); +let Test = require('../../option_test'); -describe.skip('options/color-shorthand', function() { - describe('process', function() { - it('Should shrink hexadecimal colors to 3 symbols', function() { - this.comb.configure({ 'color-shorthand': true }); - return this.comb.processString( - 'div { color: #aabbcc }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #abc }'); - }); - }); - - it('Should expand hexadecimal colors to 6 symbols', function() { - this.comb.configure({ 'color-shorthand': false }); - return this.comb.processString( - 'div { color: #7ad }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #77aadd }'); - }); - }); - - it('Should save case while processing', function() { - this.comb.configure({ 'color-shorthand': true }); - return this.comb.processString( - 'div { color: #fFAafF }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #fAf }'); - }); - }); +describe('Option `color-shorthand`, process', function() { + describe('css', function() { + it('Should shrink hexadecimal colors to 3 symbols', function() { + let test = new Test(this, {'color-shorthand': true}); + return test.comb.processString( + 'div { color: #aabbcc }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #abc }'); + }); }); - describe('detect', function() { - it('Should detect non-shorthanded color', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #FF33EE }', - { - 'color-shorthand': false - } - ); - }); - - it('Should detect shorthanded color', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #fff }', - { - 'color-shorthand': true - } - ); - }); - - it('Shouldn’t detect if a color is shorthanded if it can’t be shorthanded', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: #F3F3F3 }', - {} - ); - }); + it('Should expand hexadecimal colors to 6 symbols', function() { + let test = new Test(this, {'color-shorthand': false}); + return test.comb.processString( + 'div { color: #7ad }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #77aadd }'); + }); + }); - it('Shouldn’t detect if a color is shorthanded if it is not a vhash', function() { - this.shouldDetect( - ['color-shorthand'], - 'a { color: rgba(0,0,0,0.5) }', - {} - ); - }); + it('Should save case while processing', function() { + let test = new Test(this, {'color-shorthand': true}); + return test.comb.processString( + 'div { color: #fFAafF }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #fAf }'); + }); }); + }); }); diff --git a/test/options/element-case/detect/test.js b/test/options/element-case/detect/test.js new file mode 100644 index 00000000..909eb18e --- /dev/null +++ b/test/options/element-case/detect/test.js @@ -0,0 +1,60 @@ +let Test = require('../../option_test'); + +describe('Option `element-case`, process', function() { + describe('css', function() { + it('Should detect lowercase elements', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + 'a { color: red }', + {'element-case': 'lower'} + ); + }); + + it('Should detect uppercase elements', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + 'A { color: red }', + {'element-case': 'upper'} + ); + }); + + it('Should detect lowercase elements in a long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + 'ul li:not(:hover) A { color: red }', + {'element-case': 'lower'} + ); + }); + + it('Should detect uppercase elements in a long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + 'ul .lol:not(LI) A { color: red }', + {'element-case': 'upper'} + ); + }); + + it('Shouldn’t detect case of elements in a mixed case', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + 'aRtIcLe { color: red }', + {} + ); + }); + + it('Shouldn’t detect case of elements when there are no such', function() { + let test = new Test(this); + test.shouldDetect( + ['element-case'], + '*.lol { color: red }', + {} + ); + }); + }); +}); + diff --git a/test/options/element-case/lint/test.js b/test/options/element-case/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/element-case/process/scss/test.js b/test/options/element-case/process/scss/test.js deleted file mode 100644 index 293d269b..00000000 --- a/test/options/element-case/process/scss/test.js +++ /dev/null @@ -1,8 +0,0 @@ -describe.skip('options/element-case (scss):', function() { - describe('process', function() { - it('Should not touch mixin names', function() { - this.comb.configure({ 'element-case': 'lower' }); - return this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); - }); - }); -}); diff --git a/test/options/element-case/process/test.js b/test/options/element-case/process/test.js index bf4d99b9..350970fe 100644 --- a/test/options/element-case/process/test.js +++ b/test/options/element-case/process/test.js @@ -1,99 +1,49 @@ var assert = require('assert'); - -describe.skip('options/element-case', function() { - describe('process', function() { - it('Invalid String should not change case of elements', function() { - this.comb.configure({ 'element-case': 'foobar' }); - return this.comb.processString( - 'LI a { color : red }' - ).then(function(actual) { - assert.equal(actual, 'LI a { color : red }'); - }); - }); - - it('Should switch tag name to upper case', function() { - this.comb.configure({ 'element-case': 'upper' }); - return this.comb.processString( - 'div { color: #fff }' - ).then(function(actual) { - assert.equal(actual, 'DIV { color: #fff }'); - }); - }); - - it('Should switch tag name to lower case', function() { - this.comb.configure({ 'element-case': 'lower' }); - return this.comb.processString( - 'DIV { color: #FFF }' - ).then(function(actual) { - assert.equal(actual, 'div { color: #FFF }'); - }); - }); - - it('Should switch element-case in complex rules', function() { - this.comb.configure({ 'element-case': 'lower' }); - return this.comb.processString( - 'UL > LI > .foo:not(A) { color: red }' - ).then(function(actual) { - assert.equal(actual, 'ul > li > .foo:not(a) { color: red }'); - }); - }); +let Test = require('../../option_test'); + +describe('Option `element-case`, process', function() { + describe('css', function() { + it('Invalid String should not change case of elements', function() { + let test = new Test(this, {'element-case': 'foobar'}); + return test.comb.processString( + 'LI a { color : red }' + ).then(function(actual) { + assert.equal(actual, 'LI a { color : red }'); + }); }); - describe('detect', function() { - it('Should detect lowercase elements', function() { - this.shouldDetect( - ['element-case'], - 'a { color: red }', - { - 'element-case': 'lower' - } - ); - }); - - it('Should detect uppercase elements', function() { - this.shouldDetect( - ['element-case'], - 'A { color: red }', - { - 'element-case': 'upper' - } - ); - }); - - it('Should detect lowercase elements in a long selector', function() { - this.shouldDetect( - ['element-case'], - 'ul li:not(:hover) A { color: red }', - { - 'element-case': 'lower' - } - ); - }); + it('Should switch tag name to upper case', function() { + let test = new Test(this, {'element-case': 'upper'}); + return test.comb.processString( + 'div { color: #fff }' + ).then(function(actual) { + assert.equal(actual, 'DIV { color: #fff }'); + }); + }); - it('Should detect uppercase elements in a long selector', function() { - this.shouldDetect( - ['element-case'], - 'ul .lol:not(LI) A { color: red }', - { - 'element-case': 'upper' - } - ); - }); + it('Should switch tag name to lower case', function() { + let test = new Test(this, {'element-case': 'lower'}); + return test.comb.processString( + 'DIV { color: #FFF }' + ).then(function(actual) { + assert.equal(actual, 'div { color: #FFF }'); + }); + }); - it('Shouldn’t detect case of elements in a mixed case', function() { - this.shouldDetect( - ['element-case'], - 'aRtIcLe { color: red }', - {} - ); - }); + it('Should switch element-case in complex rules', function() { + let test = new Test(this, {'element-case': 'lower'}); + return test.comb.processString( + 'UL > LI > .foo:not(A) { color: red }' + ).then(function(actual) { + assert.equal(actual, 'ul > li > .foo:not(a) { color: red }'); + }); + }); + }); - it('Shouldn’t detect case of elements when there are no such', function() { - this.shouldDetect( - ['element-case'], - '*.lol { color: red }', - {} - ); - }); + describe('scss', function() { + it('Should not touch mixin names', function() { + let test = new Test(this, {'element-case': 'lower'}); + return test.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); }); + }); }); diff --git a/test/options/eof-newline/detect/test.js b/test/options/eof-newline/detect/test.js new file mode 100644 index 00000000..c7c6cd80 --- /dev/null +++ b/test/options/eof-newline/detect/test.js @@ -0,0 +1,42 @@ +let Test = require('../../option_test'); + +describe('Option `eof-newline`, detect', function() { + describe('css', function() { + it('Shouldn’t detect eof newline', function() { + let test = new Test(this); + test.shouldDetect( + ['eof-newline'], + 'a { color: red }', + {'eof-newline': false} + ); + }); + + it('Should detect eof newline', function() { + let test = new Test(this); + test.shouldDetect( + ['eof-newline'], + 'a { color: red }\n', + {'eof-newline': true} + ); + }); + + it('Shouldn’t detect eof newline with spaces at the end', function() { + let test = new Test(this); + test.shouldDetect( + ['eof-newline'], + 'a { color: red } ', + {'eof-newline': false} + ); + }); + + it('Should detect eof newline with mixed spaces at the end', function() { + let test = new Test(this); + test.shouldDetect( + ['eof-newline'], + 'a { color: red } \n ', + {'eof-newline': true} + ); + }); + }); +}); + diff --git a/test/options/eof-newline/lint/test.js b/test/options/eof-newline/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/eof-newline/process/test.js b/test/options/eof-newline/process/test.js index f26b47f0..3991f373 100644 --- a/test/options/eof-newline/process/test.js +++ b/test/options/eof-newline/process/test.js @@ -1,74 +1,33 @@ var assert = require('assert'); +let Test = require('../../option_test'); -describe.skip('options/eof-newline', function() { - describe('process', function() { - it('Invalid value should not change trim trailing brac', function() { - this.comb.configure({ 'eof-newline': 'foobar' }); - return this.comb.processString( - 'a { color: red } \n' - ).then(function(actual) { - assert.equal(actual, 'a { color: red } \n'); - }); - }); - - it('Boolean true value should insert line-break at eof', function() { - this.comb.configure({ 'eof-newline': true }); - return this.comb.processString( - 'a {color:red} ' - ).then(function(actual) { - assert.equal(actual, 'a {color:red} \n'); - }); - }); - - it('Boolean false value should remove line-break from eof', function() { - this.comb.configure({ 'eof-newline': false }); - return this.comb.processString( - 'a {color:red} \n' - ).then(function(actual) { - assert.equal(actual, 'a {color:red} '); - }); - }); +describe('Option `eof-newline`, process', function() { + describe('css', function() { + it('Invalid value should not change trim trailing brac', function() { + let test = new Test(this, {'eof-newline': 'foobar'}); + return test.comb.processString( + 'a { color: red } \n' + ).then(function(actual) { + assert.equal(actual, 'a { color: red } \n'); + }); }); - describe('detect', function() { - it('Shouldn’t detect eof newline', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red }', - { - 'eof-newline': false - } - ); - }); - - it('Should detect eof newline', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red }\n', - { - 'eof-newline': true - } - ); - }); - - it('Shouldn’t detect eof newline with spaces at the end', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red } ', - { - 'eof-newline': false - } - ); - }); + it('Boolean true value should insert line-break at eof', function() { + let test = new Test(this, {'eof-newline': true}); + return test.comb.processString( + 'a {color:red} ' + ).then(function(actual) { + assert.equal(actual, 'a {color:red} \n'); + }); + }); - it('Should detect eof newline with mixed spaces at the end', function() { - this.shouldDetect( - ['eof-newline'], - 'a { color: red } \n ', - { - 'eof-newline': true - } - ); - }); + it('Boolean false value should remove line-break from eof', function() { + let test = new Test(this, {'eof-newline': false}); + return test.comb.processString( + 'a {color:red} \n' + ).then(function(actual) { + assert.equal(actual, 'a {color:red} '); + }); }); + }); }); diff --git a/test/options/integral/detect/css/integral.expected.css b/test/options/integral/detect/css/integral.expected.css new file mode 100644 index 00000000..f59d0a21 --- /dev/null +++ b/test/options/integral/detect/css/integral.expected.css @@ -0,0 +1,151 @@ +/* foobar */ +@media all and (min-width:0) +{ + .radio-button_theme_normal .radio-button__radio:before + { + background: rgba(0,0,0,.4); + background: -webkit-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: -moz-linear-gradient(top, rgba(0,0,0,.2) 0, rgba(0,0,0,.4) 100%); + background: -o-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: linear-gradient(to bottom, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + -moz-box-shadow: 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 1px 0 rgba(0,0,0,.07); + } + + /* :after — фон */ + .radio-button_theme_normal .radio-button__radio[class^='radio']:after + { + content: 'it\'s something different'; + + background: #fff; + background: -webkit-linear-gradient(top, #fff 0,#eee 100%); + background: -moz-linear-gradient(top, #fff 0, #eee 100%); + background: -o-linear-gradient(top, #fff 0,#eee 100%); + background: linear-gradient(to bottom, #fff 0,#eee 100%); + } + + /* _focused_yes */ + .radio-button_theme_normal .radio-button__radio_focused_yes:before + { + content: 'hello'; + + -moz-box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + } +} + +/* Фигурные скобки. Вариант 1 */ +a, +b, +i /* foobar */ +{ + margin: 0; + padding: 0; +} +div p +{ + font-size: 1px; + + top: 0; +} +div p em +{ + font-style: italic; + + border-bottom: 1px solid red; +} + +@media all and (min-width:0) +{ + /* В нажатом состоянии смещается вниз на 1px вся кнопка, текст не смещается */ + .button_pressed_yes.button_shadow_yes + { + top: 1px; + } + + .button_pressed_yes.button_shadow_yes .button__text + { + top: 0; + } +} + +@media all /* media */ +{ + /* foobar */ + .input__control + { + font-size: 100%; + + position: relative; + z-index: 3; + + width: 100%; + margin: 0; + + color: #000; + } +} + +@media screen and (min-width: 35em) /* screen */, + print and (min-width: 40em) /* print */ +{ + /* foobar */ + .input__control + { + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: .4em 0; + + border: 0; + outline: 0; + background: none; + } +} + +/* Фигурные скобки. Вариант 2 */ +div +{ + margin: 0; + padding: 0; +} +div p +{ + font-size: 1px; + + top: 0; +} +div p em +{ + font-style: italic;/* inline comment*/ + + border-bottom: 1px solid red; +} + +/* Фигурные скобки. Вариант 3 */ +div +{ + margin: 0; + padding: 0; +} +/* foo */ div ~ p +{ + font-size: 1px; + + top: 0; +} +div > p + em +{ + /* upline comment*/ + font-style: italic; + + border-bottom: 1px solid red; /* trololo */ /* trololo */ +} + +a:not(b) +{ + top: 0;/* ololo */margin: 0; +} +b +{ + top: 0/* trololo */;margin: 0; +} diff --git a/test/options/integral/detect/test.js b/test/options/integral/detect/test.js new file mode 100644 index 00000000..e4f40a28 --- /dev/null +++ b/test/options/integral/detect/test.js @@ -0,0 +1,15 @@ +let Test = require('../../option_test'); + +describe('Option `integral`, detect', function() { + describe('css', function() { + it('Should detect everything in integral test', function() { + let test = new Test(this); + let input = test.readFile('integral.expected.css'); + // Clone the required config object, otherwise other tests would fail. + let expected = JSON.parse(JSON.stringify(test.Comb.getConfig('csscomb'))); + delete expected['sort-order']; + delete expected.exclude; + test.shouldDetect(undefined, input, expected); + }); + }); +}); diff --git a/test/options/integral/lint/test.js b/test/options/integral/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/integral/process/test.js b/test/options/integral/process/test.js index 16e1c28d..d2a30d73 100644 --- a/test/options/integral/process/test.js +++ b/test/options/integral/process/test.js @@ -1,32 +1,23 @@ -describe.skip('integral test', function() { - describe('process', function() { - it('Process result must be equal to expected.css', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('integral.css', 'integral.expected.css'); - }); +let Test = require('../../option_test'); - it('Issue 252', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); - }); +describe('Option `integral`, process', function() { + describe('css', function() { + it('Process result must be equal to expected.css', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('integral.css', 'integral.expected.css'); + }); - it('Issue 374', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('issue-374.css'); - }); + it.skip('Issue 252', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); }); - describe('detect', function() { - it('Should detect everything in integral test', function() { - var input = this.readFile('integral.expected.css'); - // Clone the required config object, otherwise other tests would fail - var expected = JSON.parse(JSON.stringify(this.Comb.getConfig('csscomb'))); - delete expected['sort-order']; - delete expected.exclude; - this.shouldDetect(undefined, input, expected); - }); + it('Issue 374', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('issue-374.css'); }); + }); }); diff --git a/test/options/leading-zero/detect/test.js b/test/options/leading-zero/detect/test.js new file mode 100644 index 00000000..7656ea99 --- /dev/null +++ b/test/options/leading-zero/detect/test.js @@ -0,0 +1,33 @@ +let Test = require('../../option_test'); + +describe('Option `leading-zero`, detect', function() { + describe('css', function() { + it('Should detect leading zero option', function() { + let test = new Test(this); + test.shouldDetect( + ['leading-zero'], + 'a { width: 0.5em }', + {'leading-zero': true} + ); + }); + + it('Should detect leading zero option set to false', function() { + let test = new Test(this); + test.shouldDetect( + ['leading-zero'], + 'a { width: .5em }', + {'leading-zero': false} + ); + }); + + it('Shouldn’t detect leading zero option', function() { + let test = new Test(this); + test.shouldDetect( + ['leading-zero'], + 'a { width: 10.5em }', + {} + ); + }); + }); +}); + diff --git a/test/options/leading-zero/lint/test.js b/test/options/leading-zero/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/leading-zero/process/test.js b/test/options/leading-zero/process/test.js index 74348907..d6eef264 100644 --- a/test/options/leading-zero/process/test.js +++ b/test/options/leading-zero/process/test.js @@ -1,53 +1,24 @@ var assert = require('assert'); +let Test = require('../../option_test'); -describe.skip('options/leading-zero', function() { - describe('process', function() { - it('Should add leading zero in dimensions', function() { - this.comb.configure({ 'leading-zero': true }); - return this.comb.processString( - 'div { margin: .5em }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: 0.5em }'); - }); - }); - - it('Should remove leading zero in dimensions', function() { - this.comb.configure({ 'leading-zero': false }); - return this.comb.processString( - 'div { margin: 0.5em }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: .5em }'); - }); - }); +describe('Option `leading-zero`, process', function() { + describe('css', function() { + it('Should add leading zero in dimensions', function() { + let test = new Test(this, {'leading-zero': true}); + return test.comb.processString( + 'div { margin: .5em }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0.5em }'); + }); }); - describe('detect', function() { - it('Should detect leading zero option', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: 0.5em }', - { - 'leading-zero': true - } - ); - }); - - it('Should detect leading zero option set to false', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: .5em }', - { - 'leading-zero': false - } - ); - }); - - it('Shouldn’t detect leading zero option', function() { - this.shouldDetect( - ['leading-zero'], - 'a { width: 10.5em }', - {} - ); - }); + it('Should remove leading zero in dimensions', function() { + let test = new Test(this, {'leading-zero': false}); + return test.comb.processString( + 'div { margin: 0.5em }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: .5em }'); + }); }); + }); }); diff --git a/test/options/option_test.js b/test/options/option_test.js new file mode 100644 index 00000000..e17e7e87 --- /dev/null +++ b/test/options/option_test.js @@ -0,0 +1,54 @@ +let assert = require('assert'); +let fs = require('fs'); +let path = require('path'); + +let Comb = require('../../lib/csscomb'); + +class OptionTest { + constructor(context, config) { + this.file = context.test.file; + this.syntax = context.test.parent.title; + + this.Comb = Comb; + this.comb = new Comb(); + if (config) this.comb.configure(config); + } + + useConfig(name) { + let config = Comb.getConfig(name); + this.comb.configure(config); + } + + getErrors(filename) { + let input = this.readFile(filename); + return this.comb.lintString(input, {syntax: this.syntax}); + } + + shouldBeEqual(inputFile, expectedFile) { + let input = this.readFile(inputFile); + let expected = expectedFile ? this.readFile(expectedFile) : input; + + return this.comb.processString(input, {syntax: this.syntax}) + .then(string => assert.equal(string, expected)); + } + + /** + * Detect options in a file and compare result with expected. + * File names should be relative to test suite's folder. + * @param {Array} options List of options that should be detected + * @param {String} input Name of template file + * @param {Object} expected Expected config with detected options + */ + shouldDetect(options, input, expected) { + let detectedConfig = Comb.detectInString(input, options); + assert.deepEqual(detectedConfig, expected); + } + + readFile(filename) { + let dirname = path.dirname(this.file); + let filePath = path.join(dirname, this.syntax, filename); + return fs.readFileSync(filePath, 'utf8'); + } +} + +module.exports = OptionTest; diff --git a/test/options/quotes/detect/test.js b/test/options/quotes/detect/test.js new file mode 100644 index 00000000..959a4abb --- /dev/null +++ b/test/options/quotes/detect/test.js @@ -0,0 +1,51 @@ +let Test = require('../../option_test'); + +describe('Option `quotes`, detect', function() { + describe('css', function() { + it('Should not detect quotes when there are none', function() { + let test = new Test(this); + test.shouldDetect( + ['quotes'], + 'a { color:red }', + {} + ); + }); + + it('Should detect double quotes', function() { + let test = new Test(this); + test.shouldDetect( + ['quotes'], + 'a { content: "foo" }', + {quotes: 'double'} + ); + }); + + it('Should detect single quotes', function() { + let test = new Test(this); + test.shouldDetect( + ['quotes'], + 'a { content: \'foo\' }', + {quotes: 'single'} + ); + }); + + it('Should detect single quotes in attribute', function() { + let test = new Test(this); + test.shouldDetect( + ['quotes'], + 'a[class^=\'foo\'] { color: red }', + {quotes: 'single'} + ); + }); + + it('Should detect double quotes in url', function() { + let test = new Test(this); + test.shouldDetect( + ['quotes'], + 'a { background: url("foo.png") }', + {quotes: 'double'} + ); + }); + }); +}); + diff --git a/test/options/quotes/lint/test.js b/test/options/quotes/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/quotes/process/test.js b/test/options/quotes/process/test.js index e79bfcd1..e37562e2 100644 --- a/test/options/quotes/process/test.js +++ b/test/options/quotes/process/test.js @@ -1,109 +1,60 @@ var assert = require('assert'); - -describe.skip('options/quotes', function() { - describe('process', function() { - it('Invalid String should not change quotes', function() { - this.comb.configure({ quotes: 3 }); - return this.comb.processString( - 'a { content: "" }b { content: \'\' }' - ).then(function(actual) { - assert.equal(actual, 'a { content: "" }b { content: \'\' }'); - }); - }); - - it('`single` value should set the quotes to single', function() { - this.comb.configure({ quotes: 'single' }); - return this.comb.processString( - 'a { content: "" }b { content: \'\' }' - ).then(function(actual) { - assert.equal(actual, 'a { content: \'\' }b { content: \'\' }'); - }); - }); - - it('`double` value should set the quotes to double', function() { - this.comb.configure({ quotes: 'double' }); - return this.comb.processString( - 'a { content: "" }b { content: \'\' }' - ).then(function(actual) { - assert.equal(actual, 'a { content: "" }b { content: "" }'); - }); - }); - - it('`double` value should set the quotes to double in attrs and urls', function() { - this.comb.configure({ quotes: 'double' }); - return this.comb.processString( - 'a[class^=\'foo\'] { background: url(\'foo.png\') }' - ).then(function(actual) { - assert.equal(actual, 'a[class^="foo"] { background: url("foo.png") }'); - }); - }); - - it('`double` value should escape the unescaped double quotes on change', function() { - this.comb.configure({ quotes: 'double' }); - return this.comb.processString( - 'a { content: "\\"" }b { content: \'"\' }' - ).then(function(actual) { - assert.equal(actual, 'a { content: "\\"" }b { content: "\\"" }'); - }); - }); - - it('`single` value should unescape the escaped double quotes on change', function() { - this.comb.configure({ quotes: 'single' }); - return this.comb.processString( - 'a { content: "\\"" }' - ).then(function(actual) { - assert.equal(actual, 'a { content: \'"\' }'); - }); - }); +let Test = require('../../option_test'); + +describe('Option `quotes`, process', function() { + describe('css', function() { + it('Invalid String should not change quotes', function() { + let test = new Test(this, {quotes: 3}); + return test.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "" }b { content: \'\' }'); + }); }); - describe('detect', function() { - it('Should not detect quotes when there are none', function() { - this.shouldDetect( - ['quotes'], - 'a { color:red }', - {} - ); - }); + it('`single` value should set the quotes to single', function() { + let test = new Test(this, {quotes: 'single'}); + return test.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: \'\' }b { content: \'\' }'); + }); + }); - it('Should detect double quotes', function() { - this.shouldDetect( - ['quotes'], - 'a { content: "foo" }', - { - quotes: 'double' - } - ); - }); + it('`double` value should set the quotes to double', function() { + let test = new Test(this, {quotes: 'double'}); + return test.comb.processString( + 'a { content: "" }b { content: \'\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "" }b { content: "" }'); + }); + }); - it('Should detect single quotes', function() { - this.shouldDetect( - ['quotes'], - 'a { content: \'foo\' }', - { - quotes: 'single' - } - ); - }); + it('`double` value should set the quotes to double in attrs and urls', function() { + let test = new Test(this, {quotes: 'double'}); + return test.comb.processString( + 'a[class^=\'foo\'] { background: url(\'foo.png\') }' + ).then(function(actual) { + assert.equal(actual, 'a[class^="foo"] { background: url("foo.png") }'); + }); + }); - it('Should detect single quotes in attribute', function() { - this.shouldDetect( - ['quotes'], - 'a[class^=\'foo\'] { color: red }', - { - quotes: 'single' - } - ); - }); + it('`double` value should escape the unescaped double quotes on change', function() { + let test = new Test(this, {quotes: 'double'}); + return test.comb.processString( + 'a { content: "\\"" }b { content: \'"\' }' + ).then(function(actual) { + assert.equal(actual, 'a { content: "\\"" }b { content: "\\"" }'); + }); + }); - it('Should detect double quotes in url', function() { - this.shouldDetect( - ['quotes'], - 'a { background: url("foo.png") }', - { - quotes: 'double' - } - ); - }); + it('`single` value should unescape the escaped double quotes on change', function() { + let test = new Test(this, {quotes: 'single'}); + return test.comb.processString( + 'a { content: "\\"" }' + ).then(function(actual) { + assert.equal(actual, 'a { content: \'"\' }'); + }); }); + }); }); diff --git a/test/options/remove-empty-rulesets/detect/test.js b/test/options/remove-empty-rulesets/detect/test.js new file mode 100644 index 00000000..2fa734f5 --- /dev/null +++ b/test/options/remove-empty-rulesets/detect/test.js @@ -0,0 +1,78 @@ +let Test = require('../../option_test'); + +describe('Option `remove-empty-rulesets`, detect', function() { + describe('css', function() { + it('Should detect test option set to `true`', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + 'a { color: red }', + {'remove-empty-rulesets': true} + ); + }); + + it('Should detect test option set to `false` with empty block', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + 'a {}', + {'remove-empty-rulesets': false} + ); + }); + + it('Should detect test option set to `false` with block containing whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + 'a { }', + {'remove-empty-rulesets': false} + ); + }); + + it('Should detect test option set to `true` with block containing comment', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + 'a { /* Hello */ }', + {'remove-empty-rulesets': true} + ); + }); + + it('Should detect test option set to `true` with media query containing block', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + '@media all and (min-width:0) { a { /* Hello */ } }', + {'remove-empty-rulesets': true} + ); + }); + + it('Should detect test option set to `true` with media query containing comment', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + '@media all and (min-width:0) {/* Hello */}', + {'remove-empty-rulesets': true} + ); + }); + + it('Should detect test option set to `false` with empty media query', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + '@media all and (min-width:0) {}', + {'remove-empty-rulesets': false} + ); + }); + + it('Should detect test option set to `false` with media query containing whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['remove-empty-rulesets'], + '@media all and (min-width:0) { \n }', + {'remove-empty-rulesets': false} + ); + }); + }); +}); + diff --git a/test/options/remove-empty-rulesets/lint/test.js b/test/options/remove-empty-rulesets/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/remove-empty-rulesets/process/less/test.js b/test/options/remove-empty-rulesets/process/less/test.js deleted file mode 100644 index 28001e80..00000000 --- a/test/options/remove-empty-rulesets/process/less/test.js +++ /dev/null @@ -1,31 +0,0 @@ -var assert = require('assert'); - -describe.skip('options/remove-empty-rulesets (less):', function() { - describe('process', function() { - it('Issue 201. Test 1', function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - return this.shouldBeEqual('1.less', '1.expected.less'); - }); - - it('Issue 201. Test 2', function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - var string = '#a {#b {} #d {}}'; - return this.comb.processString(string, { syntax: 'less' }) - .then(function(actual) { - assert.equal(actual, ''); - }); - }); - - it('Issue 201. Test 3', function() { - this.comb.configure({ - 'remove-empty-rulesets': false, - 'always-semicolon': true - }); - var string = '#a {#b {} #d {}}'; - return this.comb.processString(string, { syntax: 'less' }) - .then(function(actual) { - assert.equal(actual, string); - }); - }); - }); -}); diff --git a/test/options/remove-empty-rulesets/process/scss/test.js b/test/options/remove-empty-rulesets/process/scss/test.js deleted file mode 100644 index ae74b099..00000000 --- a/test/options/remove-empty-rulesets/process/scss/test.js +++ /dev/null @@ -1,23 +0,0 @@ -describe.skip('options/remove-empty-rulesets (scss)', function() { - beforeEach(function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - }); - - describe('process', function() { - it('Should not remove rulesets which contain only includes', function() { - return this.shouldBeEqual('include.scss'); - }); - - it('Should remove rulesets with contain only empty nested rules', function() { - return this.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); - }); - - it('Should not remove rulesets with non-empty nested rules. Test 1', function() { - return this.shouldBeEqual('nested-rule-1.scss'); - }); - - it('Should not remove rulesets with non-empty nested rules. Test 2', function() { - return this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); - }); - }); -}); diff --git a/test/options/remove-empty-rulesets/process/test.js b/test/options/remove-empty-rulesets/process/test.js index bcaf073d..c80097b5 100644 --- a/test/options/remove-empty-rulesets/process/test.js +++ b/test/options/remove-empty-rulesets/process/test.js @@ -1,129 +1,96 @@ var assert = require('assert'); +let Test = require('../../option_test'); -describe.skip('options/remove-empty-rulesets', function() { - describe('process', function() { - it('Configured with invalid value, should not remove empty ruleset', function() { - this.comb.configure({ 'remove-empty-rulesets': 'foobar' }); - return this.comb.processString('a { width: 10px; } b {}') - .then(function(actual) { - assert.equal(actual, 'a { width: 10px; } b {}'); - }); - }); - - describe('configured with Boolean "true" value', function() { - beforeEach(function() { - this.comb.configure({ 'remove-empty-rulesets': true }); - }); - - it('should remove empty ruleset', function() { - return this.comb.processString(' b {} ') - .then(function(actual) { - assert.equal(actual, ' '); - }); - }); +describe('Option `remove-empty-rulesets`, process', function() { + describe('css', function() { + it('Configured with invalid value, should not remove empty ruleset', function() { + let test = new Test(this, {'remove-empty-rulesets': 'foobar'}); + return test.comb.processString('a { width: 10px; } b {}') + .then(function(actual) { + assert.equal(actual, 'a { width: 10px; } b {}'); + }); + }); - it('should remove ruleset with spaces', function() { - return this.comb.processString(' b { } ') - .then(function(actual) { - assert.equal(actual, ' '); - }); - }); + it('Should remove empty ruleset', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.comb.processString(' b {} ') + .then(function(actual) { + assert.equal(actual, ' '); + }); + }); - it('should leave ruleset with declarations', function() { - return this.comb.processString('a { width: 10px; }\nb {} ') - .then(function(actual) { - assert.equal(actual, 'a { width: 10px; }\n '); - }); - }); + it('Should remove ruleset with spaces', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.comb.processString(' b { } ') + .then(function(actual) { + assert.equal(actual, ' '); + }); + }); - it('should leave ruleset with comments', function() { - return this.comb.processString('a { /* comment */ }\nb {} ') - .then(function(actual) { - assert.equal(actual, 'a { /* comment */ }\n '); - }); - }); - }); + it('Should leave ruleset with declarations', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.comb.processString('a { width: 10px; }\nb {} ') + .then(function(actual) { + assert.equal(actual, 'a { width: 10px; }\n '); + }); }); - describe('detect', function() { - it('Should detect this option set to `true`', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - 'a { color: red }', - { - 'remove-empty-rulesets': true - } - ); - }); + it('Should leave ruleset with comments', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.comb.processString('a { /* comment */ }\nb {} ') + .then(function(actual) { + assert.equal(actual, 'a { /* comment */ }\n '); + }); + }); + }); - it('Should detect this option set to `false` with empty block', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - 'a {}', - { - 'remove-empty-rulesets': false - } - ); - }); + describe('less', function() { + it('Issue 201. Test 1', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.shouldBeEqual('1.less', '1.expected.less'); + }); - it('Should detect this option set to `false` with block containing whitespace', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - 'a { }', - { - 'remove-empty-rulesets': false - } - ); - }); + it('Issue 201. Test 2', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + let string = '#a {#b {} #d {}}'; + return test.comb.processString(string, {syntax: 'less'}) + .then(function(actual) { + assert.equal(actual, ''); + }); + }); - it('Should detect this option set to `true` with block containing comment', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - 'a { /* Hello */ }', - { - 'remove-empty-rulesets': true - } - ); - }); + it('Issue 201. Test 3', function() { + let test = new Test(this, { + 'remove-empty-rulesets': false, + 'always-semicolon': true + }); + let string = '#a {#b {} #d {}}'; + return test.comb.processString(string, {syntax: 'less'}) + .then(function(actual) { + assert.equal(actual, string); + }); + }); + }); - it('Should detect this option set to `true` with media query containing block', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - '@media all and (min-width:0) { a { /* Hello */ } }', - { - 'remove-empty-rulesets': true - } - ); - }); + describe('scss', function() { + it('Should not remove rulesets which contain only includes', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.shouldBeEqual('include.scss'); + }); - it('Should detect this option set to `true` with media query containing comment', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - '@media all and (min-width:0) {/* Hello */}', - { - 'remove-empty-rulesets': true - } - ); - }); + it('Should remove rulesets with contain only empty nested rules', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.shouldBeEqual('empty-nested-rule.scss', 'empty-nested-rule.expected.scss'); + }); - it('Should detect this option set to `false` with empty media query', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - '@media all and (min-width:0) {}', - { - 'remove-empty-rulesets': false - } - ); - }); + it('Should not remove rulesets with non-empty nested rules. Test 1', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.shouldBeEqual('nested-rule-1.scss'); + }); - it('Should detect this option set to `false` with media query containing whitespace', function() { - this.shouldDetect( - ['remove-empty-rulesets'], - '@media all and (min-width:0) { \n }', - { - 'remove-empty-rulesets': false - } - ); - }); + it('Should not remove rulesets with non-empty nested rules. Test 2', function() { + let test = new Test(this, {'remove-empty-rulesets': true}); + return test.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); }); + }); }); diff --git a/test/options/sort-order-fallback/detect/test.js b/test/options/sort-order-fallback/detect/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/sort-order-fallback/lint/test.js b/test/options/sort-order-fallback/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/sort-order-fallback/process/test.js b/test/options/sort-order-fallback/process/test.js index a869e42a..0514b387 100644 --- a/test/options/sort-order-fallback/process/test.js +++ b/test/options/sort-order-fallback/process/test.js @@ -1,34 +1,36 @@ -describe.skip('options/sort-order-fallback', function() { - describe('process', function() { - it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { - var config = { - 'sort-order-fallback': 'abc', - 'sort-order': [ - ['top', 'left'], - ['...'], - ['color'] - ] - }; - this.comb.configure(config); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); +let Test = require('../../option_test'); - it('Should sort unknown properties alphabetically if `sort-order-fallback` is set', function() { - var config = { - 'sort-order-fallback': 'abc', - 'sort-order': ['top', 'left'] - }; - this.comb.configure(config); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); +describe('Option `sort-order-fallback`, process', function() { + describe('css', function() { + it('Should sort leftovers alphabetically if `sort-order-fallback` is set', function() { + let config = { + 'sort-order-fallback': 'abc', + 'sort-order': [ + ['top', 'left'], + ['...'], + ['color'] + ] + }; + let test = new Test(this, config); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); + + it('Should sort unknown properties alphabetically if `sort-order-fallback` is set', function() { + let config = { + 'sort-order-fallback': 'abc', + 'sort-order': ['top', 'left'] + }; + let test = new Test(this, config); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { - var config = { - 'sort-order': ['top', 'left'] - }; - this.comb.configure(config); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { + let config = { + 'sort-order': ['top', 'left'] + }; + let test = new Test(this, config); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); + }); }); diff --git a/test/options/sort-order/detect/test.js b/test/options/sort-order/detect/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/sort-order/lint/test.js b/test/options/sort-order/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/sort-order/process/less/test.js b/test/options/sort-order/process/less/test.js deleted file mode 100644 index 7c201127..00000000 --- a/test/options/sort-order/process/less/test.js +++ /dev/null @@ -1,108 +0,0 @@ -describe.skip('options/sort-order (less)', function() { - describe('process', function() { - it('Should sort properties inside rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('rule.less', 'rule.expected.less'); - }); - - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); - }); - - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); - }); - - it('Should group declarations with proper comments and spaces (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); - }); - - it('Should group declarations with proper comments and spaces (multiple lines). Test 1', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); - }); - - it('Should group declarations with proper comments and spaces (multiple lines). Test 2', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - return this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); - }); - - it('Should group declarations with proper comments and spaces (multiple lines). Test 3', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - return this.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); - }); - - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - return this.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); - }); - - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - return this.shouldBeEqual('variable.less', 'variable.expected.less'); - }); - - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - return this.shouldBeEqual('import.less', 'import.expected.less'); - }); - - it('Should sort included mixins. Test 1', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color', 'border-top', 'border-bottom'] - ] }); - return this.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); - }); - - it('Should sort included mixins. Test 2', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'top', 'color'] - ] }); - return this.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); - }); - - it('Should sort included mixins. Test 3', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'border', 'color'] - ] }); - return this.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); - }); - - it('Should sort included mixins with specified name. Test 4', function() { - this.comb.configure({ 'sort-order': [ - ['$include'], ['color'], ['$include media'] - ] }); - this.shouldBeEqual('mixin-4.less', 'mixin-4.expected.less'); - }); - - it('Should sort @extend-s', function() { - this.comb.configure({ 'sort-order': [ - ['$extend', 'color'] - ] }); - this.shouldBeEqual('extend.less', 'extend.expected.less'); - }); - }); -}); diff --git a/test/options/sort-order/process/sass/test.js b/test/options/sort-order/process/sass/test.js deleted file mode 100644 index 230f4bf7..00000000 --- a/test/options/sort-order/process/sass/test.js +++ /dev/null @@ -1,116 +0,0 @@ -describe.skip('options/sort-order (sass)', function() { - describe('process', function() { - it('Should sort properties inside rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('rule.sass', 'rule.expected.sass'); - }); - - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); - }); - - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); - }); - - it('Should group declarations with proper comments and spaces (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('comments.sass', 'comments.expected.sass'); - }); - - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - return this.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); - }); - - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - return this.shouldBeEqual('variable.sass', 'variable.expected.sass'); - }); - - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - return this.shouldBeEqual('import.sass', 'import.expected.sass'); - }); - - it('Should sort @include-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - return this.shouldBeEqual('include.sass', 'include.expected.sass'); - }); - - it('Should sort @extend-s', function() { - this.comb.configure({ 'sort-order': [ - ['$extend', 'color'] - ] }); - return this.shouldBeEqual('extend.sass', 'extend.expected.sass'); - }); - - it('Should sort @include-s with specified name. Test 1', function() { - this.comb.configure({ 'sort-order': [ - ['$include'], ['color'], ['$include media'] - ] }); - this.shouldBeEqual('include-specified-1.sass', 'include-specified-1.expected.sass'); - }); - - it('Should sort @include-s with specified name. Test 2', function() { - this.comb.configure({ 'sort-order': [ - ['$include'], ['color'], ['$include media'] - ] }); - this.shouldBeEqual('include-specified-2.sass', 'include-specified-2.expected.sass'); - }); - - it('Should sort properties inside blocks passed to mixins', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); - }); - - it('Should handle properties preceeding rulesets', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - return this.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); - }); - - it('Should handle properties preceeding conditions', function() { - this.comb.configure({ 'sort-order': [ - ['font-size', 'display', 'top', 'color'] - ] }); - return this.shouldBeEqual('condition.sass', 'condition.expected.sass'); - }); - - it('Issue 332', function() { - this.comb.configure({ 'sort-order': [ - ['color'], ['$include'] - ] }); - return this.shouldBeEqual('issue-332.sass', 'issue-332.expected.sass'); - }); - - it('Issue 332, test 2', function() { - this.comb.configure({ - 'sort-order': [['...']], - 'sort-order-fallback': 'abc' - }); - return this.shouldBeEqual('issue-332-2.sass', 'issue-332-2.expected.sass'); - }); - }); -}); diff --git a/test/options/sort-order/process/scss/test.js b/test/options/sort-order/process/scss/test.js deleted file mode 100644 index 8613d400..00000000 --- a/test/options/sort-order/process/scss/test.js +++ /dev/null @@ -1,136 +0,0 @@ -describe.skip('options/sort-order (scss)', function() { - describe('process', function() { - it('Should sort properties inside rules (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('rule.scss', 'rule.expected.scss'); - }); - - it('Should sort properties inside rules (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('rule.scss', 'rule.expected.scss'); - }); - - it('Should sort properties inside nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); - }); - - it('Should sort properties divided by nested rules', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - return this.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); - }); - - it('Should group declarations with proper comments and spaces (multiple lines)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); - }); - - it('Should group declarations with proper comments and spaces (single line)', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); - }); - - it('Should divide properties from different groups with an empty line', function() { - this.comb.configure({ 'sort-order': [ - ['top'], ['color'] - ] }); - return this.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); - }); - - it('Should sort variables', function() { - this.comb.configure({ 'sort-order': [ - ['$variable', 'color'] - ] }); - return this.shouldBeEqual('variable.scss', 'variable.expected.scss'); - }); - - it('Should sort imports', function() { - this.comb.configure({ 'sort-order': [ - ['$import', 'color'] - ] }); - return this.shouldBeEqual('import.scss', 'import.expected.scss'); - }); - - it('Should sort @include-s', function() { - this.comb.configure({ 'sort-order': [ - ['$include', 'color'] - ] }); - return this.shouldBeEqual('include.scss', 'include.expected.scss'); - }); - - it('Should sort @include-s with specified name', function() { - this.comb.configure({ 'sort-order': [ - ['$include'], ['color'], ['$include media'] - ] }); - this.shouldBeEqual('include-specified.scss', 'include-specified.expected.scss'); - }); - - it('Should sort @extend-s', function() { - this.comb.configure({ 'sort-order': [ - ['$extend', 'color'] - ] }); - return this.shouldBeEqual('extend.scss', 'extend.expected.scss'); - }); - - it('Should sort properties inside blocks passed to mixins', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'color'] - ] }); - return this.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); - }); - - it('Should handle properties preceeding rulesets', function() { - this.comb.configure({ 'sort-order': [ - ['top', 'left', 'color'] - ] }); - return this.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); - }); - - it('Should handle properties preceeding conditions', function() { - this.comb.configure({ 'sort-order': [ - ['font-size', 'display', 'top', 'color'] - ] }); - return this.shouldBeEqual('condition.scss', 'condition.expected.scss'); - }); - - it('Should sort complex case with leftovers', function() { - this.comb.configure({ - "sort-order": [ - ["$variable"], - ["position"], - ["...", "border"], - ["$include"], - ["font"] - ] - }); - return this.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); - }); - - it('Issue 317', function() { - this.comb.configure({ 'sort-order': ['...'] }); - return this.shouldBeEqual('issue-317.scss'); - }); - - it('Issue 333', function() { - this.comb.configure({ 'sort-order': ['...'] }); - return this.shouldBeEqual('issue-333.scss'); - }); - - it.skip('Issue 399', function() { - this.comb.configure({ "sort-order": [["$extend", "color"]]}); - return this.shouldBeEqual('issue-399.expected.scss'); - }); - }); -}); diff --git a/test/options/sort-order/process/test.js b/test/options/sort-order/process/test.js index b650ae86..6d95c827 100644 --- a/test/options/sort-order/process/test.js +++ b/test/options/sort-order/process/test.js @@ -1,129 +1,493 @@ var assert = require('assert'); +let Test = require('../../option_test'); -describe.skip('options/sort-order', function() { - describe('process', function() { - it('Should be in expected order in case properties are not grouped', function() { - this.comb.configure({ 'sort-order': ['position', 'z-index'] }); - return this.shouldBeEqual('single-group.css', 'single-group.expected.css'); - }); - - it('Should be in expected order in case of 1 group', function() { - this.comb.configure({ 'sort-order': [ - ['position', 'z-index'] - ] }); - return this.shouldBeEqual('single-group.css', 'single-group.expected.css'); - }); - - it('Shuld be in expected order in case of multiple groups', function() { - this.comb.configure({ 'sort-order': [ - ['position', 'z-index'], - ['width', 'height'] - ] }); - return this.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); - - }); - - it('Should work correctly with comments in case of 1 group', function() { - this.comb.configure({ 'sort-order': [ - ['border-bottom', 'font-style'], - ] }); - return this.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); - }); - - it('Should work correctly with comments in case of multiple groups', function() { - this.comb.configure({ 'sort-order': [ - ['margin'], - ['padding'] - ] }); - return this.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); - }); - - it('Should parse semicolons inside data uri correctly', function() { - this.comb.configure({ - 'sort-order': [ - ['position', 'background', 'color'] - ] - }); - return this.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); - }); - - it('Should not add more than 1 line between groups', function() { - var input = this.readFile('multiple-groups-2.css'); - var expected = this.readFile('multiple-groups-2.expected.css'); - this.comb.configure({ - 'sort-order': [ - ['top'], ['color'] - ] - }); - - this.comb.processString(input) - .then(this.comb.processString) - .then(this.comb.processString) - .then(this.comb.processString) - .then(this.comb.processString) - .then(this.comb.processString) - .then(function(actual) { - assert.equal(actual, expected); - }); - }); - - it('Issue 94. Test 1', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); - }); - - it('Issue 94. Test 2', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); - }); - - it('Issue 94. Test 3', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); - }); - - it('Should place the leftovers in the end', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - return this.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); - }); - - it('Should place the leftovers in the beginning', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][0].unshift(['...']); - this.comb.configure(config); - return this.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css') - .then(function() { - config['sort-order'][0].shift(); - }); - }); - - it('Should place the leftovers in the beginning of its group', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][1].unshift('...'); - this.comb.configure(config); - return this.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css') - .then(function() { - config['sort-order'][1].shift(); - }); - }); - - it('Should place the leftovers in the middle of its group', function() { - var config = this.Comb.getConfig('csscomb'); - config['sort-order'][1].splice(1, 0, '...'); - this.comb.configure(config); - return this.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css') - .then(function() { - config['sort-order'][1].splice(1, 1); - }); - }); - - it('Should add declaration delimiters if they are missing', function() { - this.comb.configure({ 'sort-order': ['position', 'z-index'] }); - return this.shouldBeEqual('missing-delimiter.css', 'missing-delimiter.expected.css'); - }); +describe('Option `sort-order`, process', function() { + describe('css', function() { + it('Should be in expected order in case properties are not grouped', function() { + let test = new Test(this, {'sort-order': ['position', 'z-index']}); + return test.shouldBeEqual('single-group.css', 'single-group.expected.css'); }); + + it('Should be in expected order in case of 1 group', function() { + let test = new Test(this, {'sort-order': [['position', 'z-index']]}); + return test.shouldBeEqual('single-group.css', 'single-group.expected.css'); + }); + + it('Shuld be in expected order in case of multiple groups', function() { + let test = new Test(this, { + 'sort-order': [ + ['position', 'z-index'], + ['width', 'height'] + ] + }); + return test.shouldBeEqual('multiple-groups.css', 'multiple-groups.expected.css'); + }); + + it('Should work correctly with comments in case of 1 group', function() { + let test = new Test(this, { + 'sort-order': [ + ['border-bottom', 'font-style'], + ] + }); + return test.shouldBeEqual('single-group-comments.css', 'single-group-comments.expected.css'); + }); + + it('Should work correctly with comments in case of multiple groups', function() { + let test = new Test(this, { + 'sort-order': [ + ['margin'], ['padding'] + ] + }); + return test.shouldBeEqual('multiple-groups-comments.css', 'multiple-groups-comments.expected.css'); + }); + + it('Should parse semicolons inside data uri correctly', function() { + let test = new Test(this, { + 'sort-order': [ + ['position', 'background', 'color'] + ] + }); + return test.shouldBeEqual('data-uri.css', 'data-uri.expected.css'); + }); + + it('Should not add more than 1 line between groups', function() { + let test = new Test(this, { + 'sort-order': [ + ['top'], ['color'] + ] + }); + let input = test.readFile('multiple-groups-2.css'); + let expected = test.readFile('multiple-groups-2.expected.css'); + + test.comb.processString(input) + .then(test.comb.processString) + .then(test.comb.processString) + .then(test.comb.processString) + .then(test.comb.processString) + .then(test.comb.processString) + .then(function(actual) { + assert.equal(actual, expected); + }); + }); + + it('Issue 94. Test 1', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('issue-94-1.css', 'issue-94-1.expected.css'); + }); + + it('Issue 94. Test 2', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('issue-94-2.css', 'issue-94-2.expected.css'); + }); + + it('Issue 94. Test 3', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('issue-94-3.css', 'issue-94-3.expected.css'); + }); + + it('Should place the leftovers in the end', function() { + let test = new Test(this); + test.useConfig('csscomb'); + return test.shouldBeEqual('leftovers-1.css', 'leftovers-1.expected.css'); + }); + + it('Should place the leftovers in the beginning', function() { + let test = new Test(this); + let config = test.Comb.getConfig('csscomb'); + config['sort-order'][0].unshift(['...']); + test.comb.configure(config); + + return test.shouldBeEqual('leftovers-2.css', 'leftovers-2.expected.css') + .then(function() { + config['sort-order'][0].shift(); + }); + }); + + it('Should place the leftovers in the beginning of its group', function() { + let test = new Test(this); + let config = test.Comb.getConfig('csscomb'); + config['sort-order'][1].unshift('...'); + test.comb.configure(config); + return test.shouldBeEqual('leftovers-3.css', 'leftovers-3.expected.css') + .then(function() { + config['sort-order'][1].shift(); + }); + }); + + it('Should place the leftovers in the middle of its group', function() { + let test = new Test(this); + let config = test.Comb.getConfig('csscomb'); + config['sort-order'][1].splice(1, 0, '...'); + test.comb.configure(config); + return test.shouldBeEqual('leftovers-4.css', 'leftovers-4.expected.css') + .then(function() { + config['sort-order'][1].splice(1, 1); + }); + }); + + it('Should add declaration delimiters if they are missing', function() { + let test = new Test(this, {'sort-order': ['position', 'z-index']}); + return test.shouldBeEqual('missing-delimiter.css', 'missing-delimiter.expected.css'); + }); + }); + + describe('less', function() { + it('Should sort properties inside rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('rule.less', 'rule.expected.less'); + }); + + it('Should sort properties inside nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('nested-rule-1.less', 'nested-rule-1.expected.less'); + }); + + it('Should sort properties divided by nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'left', 'color']] + }); + return test.shouldBeEqual('nested-rule-2.less', 'nested-rule-2.expected.less'); + }); + + it('Should group declarations with proper comments and spaces (single line)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('comments-1.less', 'comments-1.expected.less'); + }); + + it('Should group declarations with proper comments and spaces (multiple lines). Test 1', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('comments-2.less', 'comments-2.expected.less'); + }); + + it('Should group declarations with proper comments and spaces (multiple lines). Test 2', function() { + let test = new Test(this, { + 'sort-order': [['$variable', 'color']] + }); + return test.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + }); + + it('Should group declarations with proper comments and spaces (multiple lines). Test 3', function() { + let test = new Test(this, { + 'sort-order': [['$variable', 'color']] + }); + return test.shouldBeEqual('comments-3.less', 'comments-3.expected.less'); + }); + + it('Should divide properties from different groups with an empty line', function() { + let test = new Test(this, { + 'sort-order': [['top'], ['color']] + }); + return test.shouldBeEqual('different-groups.less', 'different-groups.expected.less'); + }); + + it('Should sort variables', function() { + let test = new Test(this, { + 'sort-order': [['$variable', 'color']] + }); + return test.shouldBeEqual('variable.less', 'variable.expected.less'); + }); + + it('Should sort imports', function() { + let test = new Test(this, { + 'sort-order': [['$import', 'color']] + }); + return test.shouldBeEqual('import.less', 'import.expected.less'); + }); + + it('Should sort included mixins. Test 1', function() { + let test = new Test(this, { + 'sort-order': [['$include', 'color', 'border-top', 'border-bottom']] + }); + return test.shouldBeEqual('mixin-1.less', 'mixin-1.expected.less'); + }); + + it('Should sort included mixins. Test 2', function() { + let test = new Test(this, { + 'sort-order': [['$include', 'top', 'color']] + }); + return test.shouldBeEqual('mixin-2.less', 'mixin-2.expected.less'); + }); + + it('Should sort included mixins. Test 3', function() { + let test = new Test(this, { + 'sort-order': [['$include', 'border', 'color']] + }); + return test.shouldBeEqual('mixin-3.less', 'mixin-3.expected.less'); + }); + + it('Should sort included mixins with specified name. Test 4', function() { + let test = new Test(this, { + 'sort-order': [['$include'], ['color'], ['$include media']] + }); + return test.shouldBeEqual('mixin-4.less', 'mixin-4.expected.less'); + }); + + it('Should sort @extend-s', function() { + let test = new Test(this, { + 'sort-order': [['$extend', 'color']] + }); + return test.shouldBeEqual('extend.less', 'extend.expected.less'); + }); + }); + + describe('sass', function() { + it('Should sort properties inside rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('rule.sass', 'rule.expected.sass'); + }); + + it('Should sort properties inside nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('nested-rule-1.sass', 'nested-rule-1.expected.sass'); + }); + + it('Should sort properties divided by nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'left', 'color']] + }); + return test.shouldBeEqual('nested-rule-2.sass', 'nested-rule-2.expected.sass'); + }); + + it('Should group declarations with proper comments and spaces (multiple lines)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('comments.sass', 'comments.expected.sass'); + }); + + it('Should divide properties from different groups with an empty line', function() { + let test = new Test(this, { + 'sort-order': [['top'], ['color']] + }); + return test.shouldBeEqual('different-groups.sass', 'different-groups.expected.sass'); + }); + + it('Should sort variables', function() { + let test = new Test(this, { + 'sort-order': [['$variable', 'color']] + }); + return test.shouldBeEqual('variable.sass', 'variable.expected.sass'); + }); + + it('Should sort imports', function() { + let test = new Test(this, { + 'sort-order': [['$import', 'color']] + }); + return test.shouldBeEqual('import.sass', 'import.expected.sass'); + }); + + it('Should sort @include-s', function() { + let test = new Test(this, { + 'sort-order': [['$include', 'color']] + }); + return test.shouldBeEqual('include.sass', 'include.expected.sass'); + }); + + it('Should sort @extend-s', function() { + let test = new Test(this, { + 'sort-order': [['$extend', 'color']] + }); + return test.shouldBeEqual('extend.sass', 'extend.expected.sass'); + }); + + it.skip('Should sort @include-s with specified name. Test 1', function() { + let test = new Test(this, { + 'sort-order': [['$include'], ['color'], ['$include media']] + }); + return test.shouldBeEqual('include-specified-1.sass', 'include-specified-1.expected.sass'); + }); + + it.skip('Should sort @include-s with specified name. Test 2', function() { + let test = new Test(this, { + 'sort-order': [['$include'], ['color'], ['$include media']] + }); + return test.shouldBeEqual('include-specified-2.sass', 'include-specified-2.expected.sass'); + }); + + it('Should sort properties inside blocks passed to mixins', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('mixin.sass', 'mixin.expected.sass'); + }); + + it('Should handle properties preceeding rulesets', function() { + let test = new Test(this, { + 'sort-order': [['top', 'left', 'color']] + }); + return test.shouldBeEqual('ruleset.sass', 'ruleset.expected.sass'); + }); + + it('Should handle properties preceeding conditions', function() { + let test = new Test(this, { + 'sort-order': [['font-size', 'display', 'top', 'color']] + }); + return test.shouldBeEqual('condition.sass', 'condition.expected.sass'); + }); + + it('Issue 332', function() { + let test = new Test(this, { + 'sort-order': [['color'], ['$include']] + }); + return test.shouldBeEqual('issue-332.sass', 'issue-332.expected.sass'); + }); + + it('Issue 332, test 2', function() { + let test = new Test(this, { + 'sort-order': [['...']], + 'sort-order-fallback': 'abc' + }); + return test.shouldBeEqual('issue-332-2.sass', 'issue-332-2.expected.sass'); + }); + }); + + describe('scss', function() { + it('Should sort properties inside rules (single line)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('rule.scss', 'rule.expected.scss'); + }); + + it('Should sort properties inside rules (multiple lines)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('rule.scss', 'rule.expected.scss'); + }); + + it('Should sort properties inside nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('nested-rule-1.scss', 'nested-rule-1.expected.scss'); + }); + + it('Should sort properties divided by nested rules', function() { + let test = new Test(this, { + 'sort-order': [['top', 'left', 'color']] + }); + return test.shouldBeEqual('nested-rule-2.scss', 'nested-rule-2.expected.scss'); + }); + + it('Should group declarations with proper comments and spaces (multiple lines)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('comments-1.scss', 'comments-1.expected.scss'); + }); + + it('Should group declarations with proper comments and spaces (single line)', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('comments-2.scss', 'comments-2.expected.scss'); + }); + + it('Should divide properties from different groups with an empty line', function() { + let test = new Test(this, { + 'sort-order': [['top'], ['color']] + }); + return test.shouldBeEqual('different-groups.scss', 'different-groups.expected.scss'); + }); + + it('Should sort variables', function() { + let test = new Test(this, { + 'sort-order': [['$variable', 'color']] + }); + return test.shouldBeEqual('variable.scss', 'variable.expected.scss'); + }); + + it('Should sort imports', function() { + let test = new Test(this, { + 'sort-order': [['$import', 'color']] + }); + return test.shouldBeEqual('import.scss', 'import.expected.scss'); + }); + + it('Should sort @include-s', function() { + let test = new Test(this, { + 'sort-order': [['$include', 'color']] + }); + return test.shouldBeEqual('include.scss', 'include.expected.scss'); + }); + + it.skip('Should sort @include-s with specified name', function() { + let test = new Test(this, { + 'sort-order': [['$include'], ['color'], ['$include media']] + }); + return test.shouldBeEqual('include-specified.scss', 'include-specified.expected.scss'); + }); + + it('Should sort @extend-s', function() { + let test = new Test(this, { + 'sort-order': [['$extend', 'color']] + }); + return test.shouldBeEqual('extend.scss', 'extend.expected.scss'); + }); + + it('Should sort properties inside blocks passed to mixins', function() { + let test = new Test(this, { + 'sort-order': [['top', 'color']] + }); + return test.shouldBeEqual('mixin.scss', 'mixin.expected.scss'); + }); + + it('Should handle properties preceeding rulesets', function() { + let test = new Test(this, { + 'sort-order': [['top', 'left', 'color']] + }); + return test.shouldBeEqual('ruleset.scss', 'ruleset.expected.scss'); + }); + + it('Should handle properties preceeding conditions', function() { + let test = new Test(this, { + 'sort-order': [['font-size', 'display', 'top', 'color']] + }); + return test.shouldBeEqual('condition.scss', 'condition.expected.scss'); + }); + + it('Should sort complex case with leftovers', function() { + let test = new Test(this, { + 'sort-order': [ + ['$variable'], + ['position'], + ['...', 'border'], + ['$include'], + ['font'] + ] + }); + return test.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); + }); + + it('Issue 317', function() { + let test = new Test(this, {'sort-order': ['...']}); + return test.shouldBeEqual('issue-317.scss'); + }); + + it('Issue 333', function() { + let test = new Test(this, {'sort-order': ['...']}); + return test.shouldBeEqual('issue-333.scss'); + }); + + it.skip('Issue 399', function() { + let test = new Test(this, {'sort-order': [['$extend', 'color']]}); + return test.shouldBeEqual('issue-399.expected.scss'); + }); + }); }); diff --git a/test/options/space-after-colon/detect/test.js b/test/options/space-after-colon/detect/test.js new file mode 100644 index 00000000..5f325223 --- /dev/null +++ b/test/options/space-after-colon/detect/test.js @@ -0,0 +1,43 @@ +let Test = require('../../option_test'); + +describe('Option `space-after-colon`, detect', function() { + describe('css', function() { + it('Should detect no whitespaces', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-colon'], + 'a { color:red }', + {'space-after-colon': ''} + ); + }); + + it('Should detect space from two variants', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-colon'], + 'a { color: red; color :red }', + {'space-after-colon': ' '} + ); + }); + + it('Should detect no whitespaces along three variants', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-colon'], + 'a { color: red; background :red } b { width:10px }', + {'space-after-colon': ''} + ); + }); + + it('Should detect space', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-colon'], + 'a { color : red; background :red } b { width: 10px }', + {'space-after-colon': ' '} + ); + }); + }); +}); + + diff --git a/test/options/space-after-colon/lint/test.js b/test/options/space-after-colon/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-after-colon/process/sass/test.js b/test/options/space-after-colon/process/sass/test.js deleted file mode 100644 index b0b5685c..00000000 --- a/test/options/space-after-colon/process/sass/test.js +++ /dev/null @@ -1,13 +0,0 @@ -describe.skip('options/space-after-colon (sass):', function() { - describe('process', function() { - it('Should set proper space if colon is after property name', function() { - this.comb.configure({ 'space-after-colon': 2 }); - return this.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); - }); - - it('Should not change space after colon which is before property name', function() { - this.comb.configure({ 'space-after-colon': 1 }); - return this.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); - }); - }); -}); diff --git a/test/options/space-after-colon/process/scss/test.js b/test/options/space-after-colon/process/scss/test.js deleted file mode 100644 index 2cb13b06..00000000 --- a/test/options/space-after-colon/process/scss/test.js +++ /dev/null @@ -1,8 +0,0 @@ -describe.skip('options/space-after-colon (scss):', function() { - describe('process', function() { - it('Space after colon should not affect pseudo elements', function() { - this.comb.configure({ 'space-after-colon': 1 }); - return this.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); - }); - }); -}); diff --git a/test/options/space-after-colon/process/test.js b/test/options/space-after-colon/process/test.js index 2e575849..84119b16 100644 --- a/test/options/space-after-colon/process/test.js +++ b/test/options/space-after-colon/process/test.js @@ -1,68 +1,55 @@ -describe.skip('options/space-after-colon:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); +describe('Option `space-after-colon`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-after-colon': ['', ' ']}); + return test.shouldBeEqual('test.css'); + }); - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-colon': 3.5 }); - return this.shouldBeEqual('test.css'); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-after-colon': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-after-colon': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Valid string value (spaces only)=> should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Integer value => should set proper space after colon', function() { + let test = new Test(this, {'space-after-colon': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Valid string value (spacesand newlines)=> should set proper space after colon', function() { - this.comb.configure({ 'space-after-colon': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Valid string value (spaces only)=> should set proper space after colon', function() { + let test = new Test(this, {'space-after-colon': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); }); - describe('detect', function() { - it('Should detect no whitespaces', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color:red }', - { 'space-after-colon': '' } - ); - }); + it('Valid string value (spacesand newlines)=> should set proper space after colon', function() { + let test = new Test(this, {'space-after-colon': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); + }); - it('Should detect space from two variants', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color: red; color :red }', - { 'space-after-colon': ' ' } - ); - }); + describe('sass', function() { + it('Should set proper space if colon is after property name', function() { + let test = new Test(this, {'space-after-colon': 2}); + return test.shouldBeEqual('colon-after-property-name.sass', 'colon-after-property-name.expected.sass'); + }); - it('Should detect no whitespaces along three variants', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color: red; background :red } b { width:10px }', - { 'space-after-colon': '' } - ); - }); + it('Should not change space after colon which is before property name', function() { + let test = new Test(this, {'space-after-colon': 1}); + return test.shouldBeEqual('colon-before-property-name.sass', 'colon-before-property-name.expected.sass'); + }); + }); - it('Should detect space', function() { - this.shouldDetect( - ['space-after-colon'], - 'a { color : red; background :red } b { width: 10px }', - { 'space-after-colon': ' ' } - ); - }); + describe('scss', function() { + it('Space after colon should not affect pseudo elements', function() { + let test = new Test(this, {'space-after-colon': 1}); + return test.shouldBeEqual('pseudo-elements.scss', 'pseudo-elements.expected.scss'); }); + }); }); diff --git a/test/options/space-after-combinator/detect/test.js b/test/options/space-after-combinator/detect/test.js new file mode 100644 index 00000000..6728f664 --- /dev/null +++ b/test/options/space-after-combinator/detect/test.js @@ -0,0 +1,61 @@ +let Test = require('../../option_test'); + +describe('Option `space-after-combinator`, detect', function() { + describe('css', function() { + it('Should detect no whitespaces after combinator', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a+b { color:red }', + {'space-after-combinator': ''} + ); + }); + + it('Should detect a space after combinator', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a + \n b { color:red }', + {'space-after-combinator': ' \n '} + ); + }); + + it('Should detect a space after combinator in long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a + b ~ c>d { color:red }', + {'space-after-combinator': ' '} + ); + }); + + it('Should detect a space after combinator in long selector, test 2', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a>b + c + d { color:red }', + {'space-after-combinator': ' '} + ); + }); + + it('Should detect no whitespaces after combinator in long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a+b ~ c+d { color:red }', + {'space-after-combinator': ''} + ); + }); + + it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-combinator'], + 'a { color:red }', + {} + ); + }); + }); +}); + + diff --git a/test/options/space-after-combinator/lint/test.js b/test/options/space-after-combinator/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-after-combinator/process/test.js b/test/options/space-after-combinator/process/test.js index aab922e4..8af41c68 100644 --- a/test/options/space-after-combinator/process/test.js +++ b/test/options/space-after-combinator/process/test.js @@ -1,84 +1,35 @@ -describe.skip('options/space-after-combinator:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-combinator': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space after combinator', function() { - this.comb.configure({ 'space-after-combinator': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); +describe('Option `space-after-combinator`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-after-combinator': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespaces after combinator', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a+b { color:red }', - { 'space-after-combinator': '' } - ); - }); - - it('Should detect a space after combinator', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a + \n b { color:red }', - { 'space-after-combinator': ' \n ' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-after-combinator': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect a space after combinator in long selector', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a + b ~ c>d { color:red }', - { 'space-after-combinator': ' ' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-after-combinator': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect a space after combinator in long selector, test 2', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a>b + c + d { color:red }', - { 'space-after-combinator': ' ' } - ); - }); + it('Integer value => should set proper space after combinator', function() { + let test = new Test(this, {'space-after-combinator': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect no whitespaces after combinator in long selector', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a+b ~ c+d { color:red }', - { 'space-after-combinator': '' } - ); - }); + it('Valid string value (spaces only) => should set proper space after combinator', function() { + let test = new Test(this, {'space-after-combinator': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Shouldn’t detect whitespaces after combinator in selector without combinators', function() { - this.shouldDetect( - ['space-after-combinator'], - 'a { color:red }', - {} - ); - }); + it('Valid string value (spaces and newlines) => should set proper space after combinator', function() { + let test = new Test(this, {'space-after-combinator': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); + }); }); - diff --git a/test/options/space-after-opening-brace/detect/test.js b/test/options/space-after-opening-brace/detect/test.js new file mode 100644 index 00000000..533cc965 --- /dev/null +++ b/test/options/space-after-opening-brace/detect/test.js @@ -0,0 +1,59 @@ +let Test = require('../../option_test'); + +describe('Option `space-after-opening-brace`, detect', function() { + describe('css', function() { + it('Should detect no whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0}', + {'space-after-opening-brace': ''} + ); + }); + + it('Should detect whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{\n\ttop:0}', + {'space-after-opening-brace': '\n\t'} + ); + }); + + it('Should detect no whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0} b{\n left:0}', + {'space-after-opening-brace': ''} + ); + }); + + it('Should detect whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{ top:0 } b{left:0}', + {'space-after-opening-brace': ' '} + ); + }); + + it('Should detect no whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{top:0} b { left: 0 } c{\n\tright:0}', + {'space-after-opening-brace': ''} + ); + }); + + it('Should detect whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-opening-brace'], + 'a{\ntop:0} b{\nleft:0} c{\n right:0}', + {'space-after-opening-brace': '\n'} + ); + }); + }); +}); diff --git a/test/options/space-after-opening-brace/lint/test.js b/test/options/space-after-opening-brace/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-after-opening-brace/process/test.js b/test/options/space-after-opening-brace/process/test.js index cb26106f..c65c6841 100644 --- a/test/options/space-after-opening-brace/process/test.js +++ b/test/options/space-after-opening-brace/process/test.js @@ -1,89 +1,41 @@ -describe.skip('options/space-after-opening-brace:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-opening-brace': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space after {', function() { - this.comb.configure({ 'space-after-opening-brace': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); - - it('Issue 387', function() { - this.comb.configure({ 'space-after-opening-brace': '\n' }); - return this.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); - }); +describe('Option `space-after-opening-brace`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-after-opening-brace': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0}', - { 'space-after-opening-brace': '' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-after-opening-brace': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{\n\ttop:0}', - { 'space-after-opening-brace': '\n\t' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-after-opening-brace': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0} b{\n left:0}', - { 'space-after-opening-brace': '' } - ); - }); + it('Integer value => should set proper space after {', function() { + let test = new Test(this, {'space-after-opening-brace': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{ top:0 } b{left:0}', - { 'space-after-opening-brace': ' ' } - ); - }); + it('Valid string value (spaces only) => should set proper space after {', function() { + let test = new Test(this, {'space-after-opening-brace': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{top:0} b { left: 0 } c{\n\tright:0}', - { 'space-after-opening-brace': '' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space after {', function() { + let test = new Test(this, {'space-after-opening-brace': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-opening-brace'], - 'a{\ntop:0} b{\nleft:0} c{\n right:0}', - { 'space-after-opening-brace': '\n' } - ); - }); + it('Issue 387', function() { + let test = new Test(this, {'space-after-opening-brace': '\n'}); + return test.shouldBeEqual('issue-387.css', 'issue-387.expected.css'); }); + }); }); diff --git a/test/options/space-after-selector-delimiter/detect/test.js b/test/options/space-after-selector-delimiter/detect/test.js new file mode 100644 index 00000000..228942f1 --- /dev/null +++ b/test/options/space-after-selector-delimiter/detect/test.js @@ -0,0 +1,59 @@ +let Test = require('../../option_test'); + +describe('Option `space-after-selector-delimiter`, detect', function() { + describe('css', function() { + it('Should detect no whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0}', + {'space-after-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a, \n b {top:0}', + {'space-after-selector-delimiter': ' \n '} + ); + }); + + it('Should detect no whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0} a, b{left:0}', + {'space-after-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a, b {top:0} b,a{left:0}', + {'space-after-selector-delimiter': ' '} + ); + }); + + it('Should detect no whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a, b{top:0} b,c{left:0} c,d{right:0}', + {'space-after-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-after-selector-delimiter'], + 'a,b{top:0} b, c{left:0} c, sd{right:0}', + {'space-after-selector-delimiter': ' '} + ); + }); + }); +}); diff --git a/test/options/space-after-selector-delimiter/lint/test.js b/test/options/space-after-selector-delimiter/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-after-selector-delimiter/process/sass/test.js b/test/options/space-after-selector-delimiter/process/sass/test.js deleted file mode 100644 index d7996311..00000000 --- a/test/options/space-after-selector-delimiter/process/sass/test.js +++ /dev/null @@ -1,8 +0,0 @@ -describe.skip('options/space-after-selector-delimiter (sass):', function() { - describe('process', function() { - it('Issue 238', function() { - this.comb.configure({ 'space-after-selector-delimiter': '\n' }); - return this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); - }); - }); -}); diff --git a/test/options/space-after-selector-delimiter/process/test.js b/test/options/space-after-selector-delimiter/process/test.js index eafe597c..4875c8a8 100644 --- a/test/options/space-after-selector-delimiter/process/test.js +++ b/test/options/space-after-selector-delimiter/process/test.js @@ -1,83 +1,42 @@ -describe.skip('options/space-after-selector-delimiter:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-after-selector-delimiter': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space after selector delimiter', function() { - this.comb.configure({ 'space-after-selector-delimiter': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); +describe('Option `space-after-selector-delimiter`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-after-selector-delimiter': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-after-selector-delimiter': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, \n b {top:0}', - { 'space-after-selector-delimiter': ' \n ' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-after-selector-delimiter': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0} a, b{left:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + it('Integer value => should set proper space after selector delimiter', function() { + let test = new Test(this, {'space-after-selector-delimiter': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, b {top:0} b,a{left:0}', - { 'space-after-selector-delimiter': ' ' } - ); - }); + it('Valid string value (spaces only) => should set proper space after selector delimiter', function() { + let test = new Test(this, {'space-after-selector-delimiter': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a, b{top:0} b,c{left:0} c,d{right:0}', - { 'space-after-selector-delimiter': '' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space after selector delimiter', function() { + let test = new Test(this, {'space-after-selector-delimiter': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-after-selector-delimiter'], - 'a,b{top:0} b, c{left:0} c, sd{right:0}', - { 'space-after-selector-delimiter': ' ' } - ); - }); + describe('sass', function() { + it('Issue 238', function() { + let test = new Test(this, {'space-after-selector-delimiter': '\n'}); + return test.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass'); }); + }); }); diff --git a/test/options/space-before-closing-brace/detect/test.js b/test/options/space-before-closing-brace/detect/test.js new file mode 100644 index 00000000..abbed180 --- /dev/null +++ b/test/options/space-before-closing-brace/detect/test.js @@ -0,0 +1,50 @@ +let Test = require('../../option_test'); + +describe('Option `space-before-closing-brace`, detect', function() { + describe('css', function() { + it('Should detect no whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-closing-brace'], + 'a{top:0}', + {'space-before-closing-brace': ''} + ); + }); + + it('Should detect no whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-closing-brace'], + 'a{top:0} b { color: tomato; }', + {'space-before-closing-brace': ''} + ); + }); + + it('Should detect whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-closing-brace'], + 'a { top:0 }', + {'space-before-closing-brace': ' '} + ); + }); + + it('Should detect whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-closing-brace'], + 'a { top:0 } b{color:tomato;}', + {'space-before-closing-brace': ' '} + ); + }); + + it('Should detect whitespace (mix with block indent)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-closing-brace', 'block-indent'], + 'a {\n top:0\n }\nb{\n color:tomato;\n }', + {'block-indent': ' ', 'space-before-closing-brace': '\n '} + ); + }); + }); +}); diff --git a/test/options/space-before-closing-brace/lint/test.js b/test/options/space-before-closing-brace/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-before-closing-brace/process/test.js b/test/options/space-before-closing-brace/process/test.js index 496de360..1bc22dbf 100644 --- a/test/options/space-before-closing-brace/process/test.js +++ b/test/options/space-before-closing-brace/process/test.js @@ -1,76 +1,36 @@ -describe.skip('options/space-before-closing-brace:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-closing-brace': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space before }', function() { - this.comb.configure({ 'space-before-closing-brace': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); +describe('Option `space-before-closing-brace`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-before-closing-brace': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a{top:0}', - { 'space-before-closing-brace': '' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-before-closing-brace': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a{top:0} b { color: tomato; }', - { 'space-before-closing-brace': '' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-before-closing-brace': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a { top:0 }', - { 'space-before-closing-brace': ' ' } - ); - }); + it('Integer value => should set proper space before }', function() { + let test = new Test(this, {'space-before-closing-brace': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-closing-brace'], - 'a { top:0 } b{color:tomato;}', - { 'space-before-closing-brace': ' ' } - ); - }); + it('Valid string value (spaces only) => should set proper space before }', function() { + let test = new Test(this, {'space-before-closing-brace': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect whitespace (mix with block indent)', function() { - this.shouldDetect( - ['space-before-closing-brace', 'block-indent'], - 'a {\n top:0\n }\nb{\n color:tomato;\n }', - { 'block-indent': ' ', 'space-before-closing-brace': '\n ' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space before }', function() { + let test = new Test(this, {'space-before-closing-brace': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); + }); }); diff --git a/test/options/space-before-colon/detect/test.js b/test/options/space-before-colon/detect/test.js new file mode 100644 index 00000000..7189a60a --- /dev/null +++ b/test/options/space-before-colon/detect/test.js @@ -0,0 +1,43 @@ +let Test = require('../../option_test'); + +describe('Option `space-before-colon`, detect', function() { + describe('css', function() { + it('Should detect no whitespaces', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-colon'], + 'a { color:red }', + {'space-before-colon': ''} + ); + }); + + it('Should detect no space from two variants', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-colon'], + 'a { color: red; color :red }', + {'space-before-colon': ''} + ); + }); + + it('Should detect no whitespaces along three variants', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-colon'], + 'a { color: red; background :red } b { width:10px }', + {'space-before-colon': ''} + ); + }); + + it('Should detect space', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-colon'], + 'a { color : red; background :red } b { width:10px }', + {'space-before-colon': ' '} + ); + }); + }); +}); + + diff --git a/test/options/space-before-colon/lint/test.js b/test/options/space-before-colon/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-before-colon/process/sass/test.js b/test/options/space-before-colon/process/sass/test.js deleted file mode 100644 index 62e6380b..00000000 --- a/test/options/space-before-colon/process/sass/test.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('options/space-before-colon-sass:', function() { - describe('process', function() { - it('Should correct space', function() { - this.comb.configure({ 'space-before-colon': 1 }); - return this.shouldBeEqual('test.sass', 'test.expected.sass'); - }); - - it('Should not correct space', function() { - this.comb.configure({ 'space-before-colon': 1 }); - return this.shouldBeEqual('test2.sass'); - }); - }); -}); - diff --git a/test/options/space-before-colon/process/test.js b/test/options/space-before-colon/process/test.js index b223d752..c3b860f2 100644 --- a/test/options/space-before-colon/process/test.js +++ b/test/options/space-before-colon/process/test.js @@ -1,68 +1,48 @@ -describe.skip('options/space-before-colon:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-colon': 3.5 }); - return this.shouldBeEqual('test.css'); - }); +describe('Option `space-before-colon`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-before-colon': ['', ' ']}); + return test.shouldBeEqual('test.css'); + }); - it('Integer value => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-before-colon': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Valid string value (spaces only) => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-before-colon': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before colon', function() { - this.comb.configure({ 'space-before-colon': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Integer value => should set proper space before colon', function() { + let test = new Test(this, {'space-before-colon': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); }); - describe('detect', function() { - it('Should detect no whitespaces', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color:red }', - { 'space-before-colon': '' } - ); - }); + it('Valid string value (spaces only) => should set proper space before colon', function() { + let test = new Test(this, {'space-before-colon': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect no space from two variants', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color: red; color :red }', - { 'space-before-colon': '' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space before colon', function() { + let test = new Test(this, {'space-before-colon': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); + }); - it('Should detect no whitespaces along three variants', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color: red; background :red } b { width:10px }', - { 'space-before-colon': '' } - ); - }); + describe('sass', function() { + it('Should correct space', function() { + let test = new Test(this, {'space-before-colon': 1}); + return test.shouldBeEqual('test.sass', 'test.expected.sass'); + }); - it('Should detect space', function() { - this.shouldDetect( - ['space-before-colon'], - 'a { color : red; background :red } b { width:10px }', - { 'space-before-colon': ' ' } - ); - }); + it('Should not correct space', function() { + let test = new Test(this, {'space-before-colon': 1}); + return test.shouldBeEqual('test2.sass'); }); + }); }); diff --git a/test/options/space-before-combinator/detect/test.js b/test/options/space-before-combinator/detect/test.js new file mode 100644 index 00000000..e24e9a72 --- /dev/null +++ b/test/options/space-before-combinator/detect/test.js @@ -0,0 +1,61 @@ +let Test = require('../../option_test'); + +describe('Option `space-before-combinator`, detect', function() { + describe('css', function() { + it('Should detect no whitespaces before combinator', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a+b { color:red }', + {'space-before-combinator': ''} + ); + }); + + it('Should detect a space before combinator', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a + b { color:red }', + {'space-before-combinator': ' '} + ); + }); + + it('Should detect a space before combinator in long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a + b ~ c>d { color:red }', + {'space-before-combinator': ' '} + ); + }); + + it('Should detect a space before combinator in long selector, test 2', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a>b + c + d { color:red }', + {'space-before-combinator': ' '} + ); + }); + + it('Should detect no whitespaces before combinator in long selector', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a+b ~ c+d { color:red }', + {'space-before-combinator': ''} + ); + }); + + it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-combinator'], + 'a { color:red }', + {} + ); + }); + }); +}); + + diff --git a/test/options/space-before-combinator/lint/test.js b/test/options/space-before-combinator/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-before-combinator/process/test.js b/test/options/space-before-combinator/process/test.js index ee401ddd..aec191c0 100644 --- a/test/options/space-before-combinator/process/test.js +++ b/test/options/space-before-combinator/process/test.js @@ -1,89 +1,40 @@ -describe.skip('options/space-before-combinator:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-combinator': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space before combinator', function() { - this.comb.configure({ 'space-before-combinator': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); - - it('Issue 381', function() { - this.comb.configure({ 'space-before-combinator': ' ' }); - return this.shouldBeEqual('issue-381.css'); - }); +describe('Option `space-before-combinator`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-before-combinator': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespaces before combinator', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a+b { color:red }', - { 'space-before-combinator': '' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-before-combinator': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect a space before combinator', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a + b { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-before-combinator': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect a space before combinator in long selector', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a + b ~ c>d { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Integer value => should set proper space before combinator', function() { + let test = new Test(this, {'space-before-combinator': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect a space before combinator in long selector, test 2', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a>b + c + d { color:red }', - { 'space-before-combinator': ' ' } - ); - }); + it('Valid string value (spaces only) => should set proper space before combinator', function() { + let test = new Test(this, {'space-before-combinator': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect no whitespaces before combinator in long selector', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a+b ~ c+d { color:red }', - { 'space-before-combinator': '' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space before combinator', function() { + let test = new Test(this, {'space-before-combinator': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() { - this.shouldDetect( - ['space-before-combinator'], - 'a { color:red }', - {} - ); - }); + it('Issue 381', function() { + let test = new Test(this, {'space-before-combinator': ' '}); + return test.shouldBeEqual('issue-381.css'); }); + }); }); - diff --git a/test/options/space-before-opening-brace/detect/test.js b/test/options/space-before-opening-brace/detect/test.js new file mode 100644 index 00000000..b75bfae9 --- /dev/null +++ b/test/options/space-before-opening-brace/detect/test.js @@ -0,0 +1,59 @@ +let Test = require('../../option_test'); + +describe('Option `space-before-opening-brace`, detect', function() { + describe('css', function() { + it('Should detect no whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0}', + {'space-before-opening-brace': ''} + ); + }); + + it('Should detect whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a \n {top:0}', + {'space-before-opening-brace': ' \n '} + ); + }); + + it('Should detect no whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0} b {left:0}', + {'space-before-opening-brace': ''} + ); + }); + + it('Should detect whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a {top:0} b{left:0}', + {'space-before-opening-brace': ' '} + ); + }); + + it('Should detect no whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a {top:0} b{left:0} c{right:0}', + {'space-before-opening-brace': ''} + ); + }); + + it('Should detect whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-opening-brace'], + 'a{top:0} b {left:0} c {right:0}', + {'space-before-opening-brace': ' '} + ); + }); + }); +}); diff --git a/test/options/space-before-opening-brace/lint/test.js b/test/options/space-before-opening-brace/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-before-opening-brace/process/scss/test.js b/test/options/space-before-opening-brace/process/scss/test.js deleted file mode 100644 index a7e1f6ca..00000000 --- a/test/options/space-before-opening-brace/process/scss/test.js +++ /dev/null @@ -1,13 +0,0 @@ -describe.skip('options/space-before-opening-brace (scss):', function() { - describe('process', function() { - it('Issue 231', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - return this.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); - }); - - it('Issue 319', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - return this.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); - }); - }); -}); diff --git a/test/options/space-before-opening-brace/process/test.js b/test/options/space-before-opening-brace/process/test.js index f7af132d..dbf0de74 100644 --- a/test/options/space-before-opening-brace/process/test.js +++ b/test/options/space-before-opening-brace/process/test.js @@ -1,89 +1,52 @@ -describe.skip('options/space-before-opening-brace:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-opening-brace': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); +describe('Option `space-before-opening-brace`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-before-opening-brace': ['', ' ']}); + return test.shouldBeEqual('test.css'); + }); - it('Valid string value (spaces and newlines) => should set proper space before {', function() { - this.comb.configure({ 'space-before-opening-brace': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-before-opening-brace': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Issue 232', function() { - this.comb.configure({ 'space-before-opening-brace': 1 }); - return this.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-before-opening-brace': 3.5}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0}', - { 'space-before-opening-brace': '' } - ); - }); + it('Integer value => should set proper space before {', function() { + let test = new Test(this, {'space-before-opening-brace': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a \n {top:0}', - { 'space-before-opening-brace': ' \n ' } - ); - }); + it('Valid string value (spaces only) => should set proper space before {', function() { + let test = new Test(this, {'space-before-opening-brace': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0} b {left:0}', - { 'space-before-opening-brace': '' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space before {', function() { + let test = new Test(this, {'space-before-opening-brace': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a {top:0} b{left:0}', - { 'space-before-opening-brace': ' ' } - ); - }); + it('Issue 232', function() { + let test = new Test(this, {'space-before-opening-brace': 1}); + return test.shouldBeEqual('issue-232.css', 'issue-232.expected.css'); + }); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a {top:0} b{left:0} c{right:0}', - { 'space-before-opening-brace': '' } - ); - }); + describe('scss', function() { + it('Issue 231', function() { + let test = new Test(this, {'space-before-opening-brace': 1}); + return test.shouldBeEqual('issue-231.scss', 'issue-231.expected.scss'); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-opening-brace'], - 'a{top:0} b {left:0} c {right:0}', - { 'space-before-opening-brace': ' ' } - ); - }); + it('Issue 319', function() { + let test = new Test(this, {'space-before-opening-brace': 1}); + return test.shouldBeEqual('issue-319.scss', 'issue-319.expected.scss'); }); + }); }); - diff --git a/test/options/space-before-selector-delimiter/detect/test.js b/test/options/space-before-selector-delimiter/detect/test.js new file mode 100644 index 00000000..72f67296 --- /dev/null +++ b/test/options/space-before-selector-delimiter/detect/test.js @@ -0,0 +1,59 @@ +let Test = require('../../option_test'); + +describe('Option `space-before-selector-delimiter`, detect', function() { + describe('css', function() { + it('Should detect no whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0}', + {'space-before-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a \n ,b {top:0}', + {'space-before-selector-delimiter': ' \n '} + ); + }); + + it('Should detect no whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0} a ,b{left:0}', + {'space-before-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace (2 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a ,b {top:0} b,a{left:0}', + {'space-before-selector-delimiter': ' '} + ); + }); + + it('Should detect no whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a ,b{top:0} b,c{left:0} c,d{right:0}', + {'space-before-selector-delimiter': ''} + ); + }); + + it('Should detect whitespace (3 blocks)', function() { + let test = new Test(this); + test.shouldDetect( + ['space-before-selector-delimiter'], + 'a,b{top:0} b ,c{left:0} c ,d{right:0}', + {'space-before-selector-delimiter': ' '} + ); + }); + }); +}); diff --git a/test/options/space-before-selector-delimiter/lint/test.js b/test/options/space-before-selector-delimiter/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-before-selector-delimiter/process/test.js b/test/options/space-before-selector-delimiter/process/test.js index b91d3140..828e820f 100644 --- a/test/options/space-before-selector-delimiter/process/test.js +++ b/test/options/space-before-selector-delimiter/process/test.js @@ -1,83 +1,35 @@ -describe.skip('options/space-before-selector-delimiter:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-before-selector-delimiter': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': 0 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': ' ' }); - return this.shouldBeEqual('test.css', 'test-2.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space before selector delimiter', function() { - this.comb.configure({ 'space-before-selector-delimiter': '\n ' }); - return this.shouldBeEqual('test.css', 'test-3.expected.css'); - }); +describe('Option `space-before-selector-delimiter`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-before-selector-delimiter': ['', ' ']}); + return test.shouldBeEqual('test.css'); }); - describe('detect', function() { - it('Should detect no whitespace', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0}', - { 'space-before-selector-delimiter': '' } - ); - }); - - it('Should detect whitespace', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a \n ,b {top:0}', - { 'space-before-selector-delimiter': ' \n ' } - ); - }); + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-before-selector-delimiter': ' nani '}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect no whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0} a ,b{left:0}', - { 'space-before-selector-delimiter': '' } - ); - }); + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-before-selector-delimiter': 3.5}); + return test.shouldBeEqual('test.css'); + }); - it('Should detect whitespace (2 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a ,b {top:0} b,a{left:0}', - { 'space-before-selector-delimiter': ' ' } - ); - }); + it('Integer value => should set proper space before selector delimiter', function() { + let test = new Test(this, {'space-before-selector-delimiter': 0}); + return test.shouldBeEqual('test.css', 'test.expected.css'); + }); - it('Should detect no whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a ,b{top:0} b,c{left:0} c,d{right:0}', - { 'space-before-selector-delimiter': '' } - ); - }); + it('Valid string value (spaces only) => should set proper space before selector delimiter', function() { + let test = new Test(this, {'space-before-selector-delimiter': ' '}); + return test.shouldBeEqual('test.css', 'test-2.expected.css'); + }); - it('Should detect whitespace (3 blocks)', function() { - this.shouldDetect( - ['space-before-selector-delimiter'], - 'a,b{top:0} b ,c{left:0} c ,d{right:0}', - { 'space-before-selector-delimiter': ' ' } - ); - }); + it('Valid string value (spaces and newlines) => should set proper space before selector delimiter', function() { + let test = new Test(this, {'space-before-selector-delimiter': '\n '}); + return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); + }); }); diff --git a/test/options/space-between-declarations/detect/test.js b/test/options/space-between-declarations/detect/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-between-declarations/lint/test.js b/test/options/space-between-declarations/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/space-between-declarations/process/test.js b/test/options/space-between-declarations/process/test.js index a106cde9..f230d06c 100644 --- a/test/options/space-between-declarations/process/test.js +++ b/test/options/space-between-declarations/process/test.js @@ -1,48 +1,50 @@ -describe.skip('options/space-between-declarations:', function() { - describe('process', function() { - it('Array value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': ['', ' '] }); - return this.shouldBeEqual('test.css'); - }); - - it('Invalid string value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': ' nani ' }); - return this.shouldBeEqual('test.css'); - }); - - it('Float number value => should not change anything', function() { - this.comb.configure({ 'space-between-declarations': 3.5 }); - return this.shouldBeEqual('test.css'); - }); - - it('Integer value => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': 0 }); - return this.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); - }); - - it('Valid string value (spaces only) => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': ' ' }); - return this.shouldBeEqual('space-value.css', 'space-value.expected.css'); - }); - - it('Valid string value (spaces and newlines) => should set proper space after declaration', function() { - this.comb.configure({ 'space-between-declarations': '\n ' }); - return this.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); - }); - - it('Should leave comments as is', function() { - this.comb.configure({ 'space-between-declarations': 1 }); - return this.shouldBeEqual('comments.css', 'comments.expected.css'); - }); - - it('Issue 239', function() { - this.comb.configure({ 'space-between-declarations': '\n ' }); - return this.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); - }); - - it('Issue 378', function() { - this.comb.configure({ 'space-between-declarations': '\n' }); - return this.shouldBeEqual('issue-378.css'); - }); +let Test = require('../../option_test'); + +describe('Option `space-between-declarations`, process', function() { + describe('css', function() { + it('Array value => should not change anything', function() { + let test = new Test(this, {'space-between-declarations': ['', ' ']}); + return test.shouldBeEqual('test.css'); + }); + + it('Invalid string value => should not change anything', function() { + let test = new Test(this, {'space-between-declarations': ' nani '}); + return test.shouldBeEqual('test.css'); + }); + + it('Float number value => should not change anything', function() { + let test = new Test(this, {'space-between-declarations': 3.5}); + return test.shouldBeEqual('test.css'); + }); + + it('Integer value => should set proper space after declaration', function() { + let test = new Test(this, {'space-between-declarations': 0}); + return test.shouldBeEqual('integer-value.css', 'integer-value.expected.css'); + }); + + it('Valid string value (spaces only) => should set proper space after declaration', function() { + let test = new Test(this, {'space-between-declarations': ' '}); + return test.shouldBeEqual('space-value.css', 'space-value.expected.css'); + }); + + it('Valid string value (spaces and newlines) => should set proper space after declaration', function() { + let test = new Test(this, {'space-between-declarations': '\n '}); + return test.shouldBeEqual('space-newline-value.css', 'space-newline-value.expected.css'); + }); + + it('Should leave comments as is', function() { + let test = new Test(this, {'space-between-declarations': 1}); + return test.shouldBeEqual('comments.css', 'comments.expected.css'); + }); + + it('Issue 239', function() { + let test = new Test(this, {'space-between-declarations': '\n '}); + return test.shouldBeEqual('issue-239.css', 'issue-239.expected.css'); + }); + + it('Issue 378', function() { + let test = new Test(this, {'space-between-declarations': '\n'}); + return test.shouldBeEqual('issue-378.css'); }); + }); }); diff --git a/test/options/strip-spaces/detect/test.js b/test/options/strip-spaces/detect/test.js new file mode 100644 index 00000000..e121275c --- /dev/null +++ b/test/options/strip-spaces/detect/test.js @@ -0,0 +1,77 @@ +let Test = require('../../option_test'); + +describe('Option `strip-spaces`, detect', function() { + describe('css', function() { + it('Should detect strip-spaces option set to `true`', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red }', + {'strip-spaces': true} + ); + }); + + it('Should detect strip-spaces option set to `false`', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red } ', + {'strip-spaces': false} + ); + }); + + it('Should detect strip-spaces option set to `true` with newline', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red }\nb { color: blue }', + {'strip-spaces': true} + ); + }); + + it('Should detect strip-spaces option set to `false` with newline', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red } \nb { color: blue }', + {'strip-spaces': false} + ); + }); + + it('Should detect strip-spaces option set to `true` inside a value', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a {\n color:\n red }', + {'strip-spaces': true} + ); + }); + + it('Should detect strip-spaces option set to `false` inside a value', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a {\n color: \n red }', + {'strip-spaces': false} + ); + }); + + it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red }\n', + {'strip-spaces': true} + ); + }); + + it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { + let test = new Test(this); + test.shouldDetect( + ['strip-spaces'], + 'a { color: red }\n\n', + {'strip-spaces': false} + ); + }); + }); +}); diff --git a/test/options/strip-spaces/lint/test.js b/test/options/strip-spaces/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/strip-spaces/process/test.js b/test/options/strip-spaces/process/test.js index bb083149..1c73598c 100644 --- a/test/options/strip-spaces/process/test.js +++ b/test/options/strip-spaces/process/test.js @@ -1,118 +1,37 @@ var assert = require('assert'); - -describe.skip('options/strip-spaces', function() { - describe('process', function() { - it('Invalid value should not trim trailing spaces', function() { - this.comb.configure({ 'strip-spaces': 'foobar' }); - return this.comb.processString('a { color: red } \n') - .then(function(actual) { - assert.equal(actual, 'a { color: red } \n'); - }); - }); - - it('Boolean true value should trim all trailing spaces', function() { - this.comb.configure({ 'strip-spaces': true }); - return this.comb.processString( - 'a { color: red } \n' + - 'a{color:red}\t /* foobar */\t \n' + - 'a {color:red} \n \n' - ).then(function(actual) { - assert.equal(actual, - 'a { color: red }\n' + - 'a{color:red}\t /* foobar */\n' + - 'a {color:red}\n'); - }); - }); - - it('Boolean true value should trim trailing spaces at eof', function() { - this.comb.configure({ 'strip-spaces': true }); - return this.comb.processString( - 'a {color:red} ' - ).then(function(actual) { - assert.equal(actual, 'a {color:red}'); - }); - }); +let Test = require('../../option_test'); + +describe('Option `strip-spaces`, process', function() { + describe('css', function() { + it('Invalid value should not trim trailing spaces', function() { + let test = new Test(this, {'strip-spaces': 'foobar'}); + return test.comb.processString('a { color: red } \n') + .then(function(actual) { + assert.equal(actual, 'a { color: red } \n'); + }); }); - describe('detect', function() { - it('Should detect strip-spaces option set to `true`', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }', - { - 'strip-spaces': true - } - ); - }); - - it('Should detect strip-spaces option set to `false`', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red } ', - { - 'strip-spaces': false - } - ); - }); - - it('Should detect strip-spaces option set to `true` with newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\nb { color: blue }', - { - 'strip-spaces': true - } - ); - }); - - it('Should detect strip-spaces option set to `false` with newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red } \nb { color: blue }', - { - 'strip-spaces': false - } - ); - }); - - it('Should detect strip-spaces option set to `true` inside a value', function() { - this.shouldDetect( - ['strip-spaces'], - 'a {\n color:\n red }', - { - 'strip-spaces': true - } - ); - }); - - it('Should detect strip-spaces option set to `false` inside a value', function() { - this.shouldDetect( - ['strip-spaces'], - 'a {\n color: \n red }', - { - 'strip-spaces': false - } - ); - }); - - it('Should detect strip-spaces option set to `true` if the only trailing space is the last newline', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\n', - { - 'strip-spaces': true - } - ); - }); + it('Boolean true value should trim all trailing spaces', function() { + let test = new Test(this, {'strip-spaces': true}); + return test.comb.processString( + 'a { color: red } \n' + + 'a{color:red}\t /* foobar */\t \n' + + 'a {color:red} \n \n' + ).then(function(actual) { + assert.equal(actual, + 'a { color: red }\n' + + 'a{color:red}\t /* foobar */\n' + + 'a {color:red}\n'); + }); + }); - it('Should detect strip-spaces option set to `false` if there is more than one newline at the end', function() { - this.shouldDetect( - ['strip-spaces'], - 'a { color: red }\n\n', - { - 'strip-spaces': false - } - ); - }); + it('Boolean true value should trim trailing spaces at eof', function() { + let test = new Test(this, {'strip-spaces': true}); + return test.comb.processString( + 'a {color:red} ' + ).then(function(actual) { + assert.equal(actual, 'a {color:red}'); + }); }); + }); }); diff --git a/test/options/tab-size/detect/test.js b/test/options/tab-size/detect/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/tab-size/lint/test.js b/test/options/tab-size/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/tab-size/process/test.js b/test/options/tab-size/process/test.js index 05c1193f..ea4a4650 100644 --- a/test/options/tab-size/process/test.js +++ b/test/options/tab-size/process/test.js @@ -1,18 +1,20 @@ -describe.skip('options/tab-size:', function() { - describe('process', function() { - it('Test 1: String value => should not change anything', function() { - this.comb.configure({ 'tab-size': ' ' }); - return this.shouldBeEqual('test.css'); - }); +let Test = require('../../option_test'); - it('Test 2: Float value => should not change anything', function() { - this.comb.configure({ 'tab-size': 4.5 }); - return this.shouldBeEqual('test.css'); - }); +describe('Option `tab-size`, process', function() { + describe('css', function() { + it('Test 1: String value => should not change anything', function() { + let test = new Test(this, {'tab-size': ' '}); + return test.shouldBeEqual('test.css'); + }); + + it('Test 2: Float value => should not change anything', function() { + let test = new Test(this, {'tab-size': 4.5}); + return test.shouldBeEqual('test.css'); + }); - it('Test 3: Integer value => should replace tabs with proper number of spaces', function() { - this.comb.configure({ 'tab-size': 4 }); - return this.shouldBeEqual('test.css', 'test.expected.css'); - }); + it('Test 3: Integer value => should replace tabs with proper number of spaces', function() { + let test = new Test(this, {'tab-size': 4}); + return test.shouldBeEqual('test.css', 'test.expected.css'); }); + }); }); diff --git a/test/options/unitless-zero/detect/test.js b/test/options/unitless-zero/detect/test.js new file mode 100644 index 00000000..5d407a49 --- /dev/null +++ b/test/options/unitless-zero/detect/test.js @@ -0,0 +1,69 @@ +let Test = require('../../option_test'); + +describe('Option `unitless-zero`, detect', function() { + describe('css', function() { + it('Should detect unitless zero option', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { width: 0 }', + {'unitless-zero': true} + ); + }); + + it('Should detect zero with unit', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { width: 0px }', + {'unitless-zero': false} + ); + }); + + it('Should detect unitless zero option with multiple values', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0 }', + {'unitless-zero': true} + ); + }); + + it('Should detect zero with unit and multiple values', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0em }', + {'unitless-zero': false} + ); + }); + + it('Shouldn’t detect unitless zero option if there is no unit', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { color: red }', + {} + ); + }); + + it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { transform: rotate(0deg) }', + {} + ); + }); + + it('Should detect unitless zero option with percents', function() { + let test = new Test(this); + test.shouldDetect( + ['unitless-zero'], + 'a { padding: 0% 0 0 }', + {'unitless-zero': true} + ); + }); + }); +}); + diff --git a/test/options/unitless-zero/lint/test.js b/test/options/unitless-zero/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/unitless-zero/process/test.js b/test/options/unitless-zero/process/test.js index c42d5205..5c879de3 100644 --- a/test/options/unitless-zero/process/test.js +++ b/test/options/unitless-zero/process/test.js @@ -1,109 +1,42 @@ var assert = require('assert'); - -describe.skip('options/unitless-zero', function() { - describe('process', function() { - it('Should remove units in zero-valued dimensions', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { margin: 0em; padding: 0px }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: 0; padding: 0 }'); - }); - }); - - it('Should remove units in zero-valued dimensions, test 2', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { margin: 0% }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: 0 }'); - }); - }); - - it('Should remove units in zero-valued media-query params', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - '@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }' - ).then(function(actual) { - assert.equal(actual, '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }'); - }); - }); - - it('Should not remove units (degs) in rotate property', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { -webkit-transform: rotate(0deg); }' - ).then(function(actual) { - assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); - }); - }); +let Test = require('../../option_test'); + +describe('Option `unitless-zero`, process', function() { + describe('css', function() { + it('Should remove units in zero-valued dimensions', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.comb.processString( + 'div { margin: 0em; padding: 0px }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0; padding: 0 }'); + }); }); - describe('detect', function() { - it('Should detect unitless zero option', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0 }', - { - 'unitless-zero': true - } - ); - }); - - it('Should detect zero with unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0px }', - { - 'unitless-zero': false - } - ); - }); - - it('Should detect unitless zero option with multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0 }', - { - 'unitless-zero': true - } - ); - }); - - it('Should detect zero with unit and multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0em }', - { - 'unitless-zero': false - } - ); - }); - - it('Shouldn’t detect unitless zero option if there is no unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { color: red }', - {} - ); - }); + it('Should remove units in zero-valued dimensions, test 2', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.comb.processString( + 'div { margin: 0% }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0 }'); + }); + }); - it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { transform: rotate(0deg) }', - {} - ); - }); + it('Should remove units in zero-valued media-query params', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.comb.processString( + '@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }' + ).then(function(actual) { + assert.equal(actual, '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }'); + }); + }); - it('Should detect unitless zero option with percents', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0% 0 0 }', - { - 'unitless-zero': true - } - ); - }); + it('Should not remove units (degs) in rotate property', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.comb.processString( + 'div { -webkit-transform: rotate(0deg); }' + ).then(function(actual) { + assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); + }); }); + }); }); diff --git a/test/options/vendor-prefix-align/detect/css/already-aligned.css b/test/options/vendor-prefix-align/detect/css/already-aligned.css new file mode 100644 index 00000000..35b7eeec --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/already-aligned.css @@ -0,0 +1,11 @@ +.radio-button_theme_normal .radio-button__radio:before +{ + background: rgba(0,0,0,.4); + background: -webkit-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: -moz-linear-gradient(top, rgba(0,0,0,.2) 0, rgba(0,0,0,.4) 100%); + background: -o-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: linear-gradient(to bottom, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + + -moz-box-shadow: 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 1px 0 rgba(0,0,0,.07); +} diff --git a/test/options/vendor-prefix-align/detect/css/complex.css b/test/options/vendor-prefix-align/detect/css/complex.css new file mode 100644 index 00000000..3f896df2 --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/complex.css @@ -0,0 +1,30 @@ +@media all and (min-width:0) +{ + .radio-button_theme_normal .radio-button__radio:before + { + background: rgba(0,0,0,.4); + background: -webkit-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: -moz-linear-gradient(top, rgba(0,0,0,.2) 0, rgba(0,0,0,.4) 100%); + background: -o-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: linear-gradient(to bottom, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + -moz-box-shadow: 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 1px 0 rgba(0,0,0,.07); + } + + /* :after — фон */ + .radio-button_theme_normal .radio-button__radio:after + { + background: #fff; + background: -webkit-linear-gradient(top, #fff 0,#eee 100%); + background: -moz-linear-gradient(top, #fff 0, #eee 100%); + background: -o-linear-gradient(top, #fff 0,#eee 100%); + background: linear-gradient(to bottom, #fff 0,#eee 100%); + } + + /* _focused_yes */ + .radio-button_theme_normal .radio-button__radio_focused_yes:before + { + -moz-box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + } +} diff --git a/test/options/vendor-prefix-align/detect/css/complex.expected.css b/test/options/vendor-prefix-align/detect/css/complex.expected.css new file mode 100644 index 00000000..688ecd61 --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/complex.expected.css @@ -0,0 +1,30 @@ +@media all and (min-width:0) +{ + .radio-button_theme_normal .radio-button__radio:before + { + background: rgba(0,0,0,.4); + background: -webkit-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: -moz-linear-gradient(top, rgba(0,0,0,.2) 0, rgba(0,0,0,.4) 100%); + background: -o-linear-gradient(top, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + background: linear-gradient(to bottom, rgba(0,0,0,.2) 0,rgba(0,0,0,.4) 100%); + -moz-box-shadow: 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 1px 0 rgba(0,0,0,.07); + } + + /* :after — фон */ + .radio-button_theme_normal .radio-button__radio:after + { + background: #fff; + background: -webkit-linear-gradient(top, #fff 0,#eee 100%); + background: -moz-linear-gradient(top, #fff 0, #eee 100%); + background: -o-linear-gradient(top, #fff 0,#eee 100%); + background: linear-gradient(to bottom, #fff 0,#eee 100%); + } + + /* _focused_yes */ + .radio-button_theme_normal .radio-button__radio_focused_yes:before + { + -moz-box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + box-shadow: 0 0 6px 2px rgba(255,204,0,.7), 0 1px 0 rgba(0,0,0,.07); + } +} diff --git a/test/options/vendor-prefix-align/detect/css/property-align.css b/test/options/vendor-prefix-align/detect/css/property-align.css new file mode 100644 index 00000000..b19d6b7c --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/property-align.css @@ -0,0 +1,8 @@ +a +{ + color: #fff; + + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} diff --git a/test/options/vendor-prefix-align/detect/css/property-align.expected.css b/test/options/vendor-prefix-align/detect/css/property-align.expected.css new file mode 100644 index 00000000..25808572 --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/property-align.expected.css @@ -0,0 +1,8 @@ +a +{ + color: #fff; + + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; +} diff --git a/test/options/vendor-prefix-align/detect/css/value-align.css b/test/options/vendor-prefix-align/detect/css/value-align.css new file mode 100644 index 00000000..f15a3620 --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/value-align.css @@ -0,0 +1,10 @@ +b +{ + color: #fff; + + background: -webkit-linear-gradient(linear, left top, right top, color-stop(0,rgba(255,255,255,0)), color-stop(20%, #fff)); + background: -moz-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: -o-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: -ms-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: linear-gradient(to right, rgba(255,255,255,0) 0, #fff 20%); +} diff --git a/test/options/vendor-prefix-align/detect/css/value-align.expected.css b/test/options/vendor-prefix-align/detect/css/value-align.expected.css new file mode 100644 index 00000000..60aba2ee --- /dev/null +++ b/test/options/vendor-prefix-align/detect/css/value-align.expected.css @@ -0,0 +1,10 @@ +b +{ + color: #fff; + + background: -webkit-linear-gradient(linear, left top, right top, color-stop(0,rgba(255,255,255,0)), color-stop(20%, #fff)); + background: -moz-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: -o-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: -ms-linear-gradient(left, rgba(255,255,255,0) 0, #fff 20%); + background: linear-gradient(to right, rgba(255,255,255,0) 0, #fff 20%); +} diff --git a/test/options/vendor-prefix-align/detect/test.js b/test/options/vendor-prefix-align/detect/test.js new file mode 100644 index 00000000..ca683896 --- /dev/null +++ b/test/options/vendor-prefix-align/detect/test.js @@ -0,0 +1,86 @@ +let Test = require('../../option_test'); + +describe('Option `vendor-prefix-align`, detect', function() { + describe('css', function() { + it('Shouldn not detect anything if there are no prefixed groups', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + 'a{ color: red }a{ -webkit-transform: translateZ(0) }', + {} + ); + }); + + it('Shouldn detect vendor-prefix-align as false in properties', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('property-align.css'), + {'vendor-prefix-align': false} + ); + }); + + it('Shouldn detect vendor-prefix-align as true in properties', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('property-align.expected.css'), + {'vendor-prefix-align': true} + ); + }); + + it('Shouldn detect vendor-prefix-align as false in values', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('value-align.css'), + {'vendor-prefix-align': false} + ); + }); + + it('Shouldn detect vendor-prefix-align as true in values', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('value-align.expected.css'), + {'vendor-prefix-align': true} + ); + }); + + it('Shouldn detect vendor-prefix-align as true, test 1', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('already-aligned.css'), + {'vendor-prefix-align': true} + ); + }); + + it('Shouldn detect vendor-prefix-align as true, test 2', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('complex.expected.css'), + {'vendor-prefix-align': true} + ); + }); + + it('Shouldn detect vendor-prefix-align as false', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + test.readFile('complex.css'), + {'vendor-prefix-align': false} + ); + }); + + it('Should not detect anything in simple case', function() { + let test = new Test(this); + test.shouldDetect( + ['vendor-prefix-align'], + 'a{border:0;}', + {} + ); + }); + }); +}); diff --git a/test/options/vendor-prefix-align/lint/test.js b/test/options/vendor-prefix-align/lint/test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/options/vendor-prefix-align/process/sass/test.js b/test/options/vendor-prefix-align/process/sass/test.js deleted file mode 100644 index 80a2b7d6..00000000 --- a/test/options/vendor-prefix-align/process/sass/test.js +++ /dev/null @@ -1,15 +0,0 @@ -describe.skip('options/vendor-prefix-align', function() { - beforeEach(function() { - this.comb.configure({ 'vendor-prefix-align': true }); - }); - - describe('process', function() { - it('Should align prexied values', function() { - return this.shouldBeEqual('value.sass', 'value.expected.sass'); - }); - - it('Should not align prefixed property names', function() { - return this.shouldBeEqual('property.sass'); - }); - }); -}); diff --git a/test/options/vendor-prefix-align/process/test.js b/test/options/vendor-prefix-align/process/test.js index e4b4dd72..1b4d70ac 100644 --- a/test/options/vendor-prefix-align/process/test.js +++ b/test/options/vendor-prefix-align/process/test.js @@ -1,159 +1,95 @@ -describe.skip('options/vendor-prefix-align', function() { - beforeEach(function() { - this.comb.configure({ 'vendor-prefix-align': true }); - }); - - describe('process', function() { - it('Should correctly work when there is comment before property name', function() { - return this.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); - }); - - it('Should correctly work when there is comment before property name. Test 2', function() { - return this.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); - }); - - it('Should correctly work when there is comment before property name. Test 3', function() { - return this.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); - }); - - it('Should correctly align prefixes in properties', function() { - return this.shouldBeEqual('property-align.css', 'property-align.expected.css'); - }); - - it('Should correctly align prefixes in values', function() { - return this.shouldBeEqual('value-align.css', 'value-align.expected.css'); - }); - - it('Should not touch already align prefixes', function() { - return this.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); - }); - - it('Should correctly align prefixes in properties and values at the same time', function() { - return this.shouldBeEqual('both.css', 'both.expected.css'); - }); - - it('Should correctly work when value and property names are the same', function() { - return this.shouldBeEqual('same-name.css', 'same-name.expected.css'); - }); - - it('Should correctly work when there is no whitespace after colon', function() { - return this.shouldBeEqual('without-space.css', 'without-space.expected.css'); - }); - - it('Should correctly work when there is comment after colon', function() { - return this.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); - }); - - it('Should not do anything with oneliners', function() { - return this.shouldBeEqual('one-line.css', 'one-line.expected.css'); - }); - - it('Should not do anything with oneliners. Test 2', function() { - return this.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); - }); - - it('Should always correctly align prefixes', function() { - return this.shouldBeEqual('complex.css', 'complex.expected.css'); - }); - - it('Issue 193: should handle declarations without preceding spaces', function() { - return this.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); - }); - - it('Issue 241: should not break tabs', function() { - this.comb.configure({ - 'block-indent': '\t', - 'vendor-prefix-align': true - }); - return this.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); - }); - }); - - describe('detect', function() { - it('Shouldn not detect anything if there are no prefixed groups', function() { - this.shouldDetect( - ['vendor-prefix-align'], - 'a{ color: red }a{ -webkit-transform: translateZ(0) }', - {} - ); - }); - - it('Shouldn detect vendor-prefix-align as false in properties', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('property-align.css'), - { - 'vendor-prefix-align': false - } - ); - }); - - it('Shouldn detect vendor-prefix-align as true in properties', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('property-align.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); - - it('Shouldn detect vendor-prefix-align as false in values', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('value-align.css'), - { - 'vendor-prefix-align': false - } - ); - }); - - it('Shouldn detect vendor-prefix-align as true in values', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('value-align.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); - - it('Shouldn detect vendor-prefix-align as true, test 1', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('already-aligned.css'), - { - 'vendor-prefix-align': true - } - ); - }); - - it('Shouldn detect vendor-prefix-align as true, test 2', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('complex.expected.css'), - { - 'vendor-prefix-align': true - } - ); - }); - - it('Shouldn detect vendor-prefix-align as false', function() { - this.shouldDetect( - ['vendor-prefix-align'], - this.readFile('complex.css'), - { - 'vendor-prefix-align': false - } - ); - }); - - it('Should not detect anything in simple case', function() { - this.shouldDetect( - ['vendor-prefix-align'], - 'a{border:0;}', - {} - ); - }); +let Test = require('../../option_test'); + +describe('Option `vendor-prefix-align`, process', function() { + describe('css', function() { + it('Should correctly work when there is comment before property name', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('with-comment-property.css', 'with-comment-property.expected.css'); + }); + + it('Should correctly work when there is comment before property name. Test 2', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('with-comment-property-2.css', 'with-comment-property-2.expected.css'); + }); + + it('Should correctly work when there is comment before property name. Test 3', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('multiline-comments.css', 'multiline-comments.expected.css'); + }); + + it('Should correctly align prefixes in properties', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('property-align.css', 'property-align.expected.css'); + }); + + it('Should correctly align prefixes in values', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('value-align.css', 'value-align.expected.css'); + }); + + it('Should not touch already align prefixes', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('already-aligned.css', 'already-aligned.expected.css'); + }); + + it('Should correctly align prefixes in properties and values at the same time', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('both.css', 'both.expected.css'); + }); + + it('Should correctly work when value and property names are the same', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('same-name.css', 'same-name.expected.css'); + }); + + it('Should correctly work when there is no whitespace after colon', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('without-space.css', 'without-space.expected.css'); + }); + + it('Should correctly work when there is comment after colon', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('with-comment.css', 'with-comment.expected.css'); + }); + + it('Should not do anything with oneliners', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('one-line.css', 'one-line.expected.css'); + }); + + it('Should not do anything with oneliners. Test 2', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('one-line-2.css', 'one-line-2.expected.css'); + }); + + it('Should always correctly align prefixes', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('complex.css', 'complex.expected.css'); + }); + + it('Issue 193: should handle declarations without preceding spaces', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('issue-193.css', 'issue-193.expected.css'); + }); + + it('Issue 241: should not break tabs', function() { + let test = new Test(this, { + 'block-indent': '\t', + 'vendor-prefix-align': true + }); + return test.shouldBeEqual('issue-241.css', 'issue-241.expected.css'); + }); + }); + + describe('sass', function() { + it('Should align prexied values', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('value.sass', 'value.expected.sass'); + }); + + it('Should not align prefixed property names', function() { + let test = new Test(this, {'vendor-prefix-align': true}); + return test.shouldBeEqual('property.sass'); }); + }); }); diff --git a/test/test_helpers.js b/test/test_helpers.js deleted file mode 100644 index 1742c686..00000000 --- a/test/test_helpers.js +++ /dev/null @@ -1,64 +0,0 @@ -let assert = require('assert'); -let fs = require('fs'); -let path = require('path'); - -let Comb = process.env.TEST_COV ? - require('../lib-cov/csscomb') : require('../lib/csscomb'); - -let helpers = { - getErrors(filename) { - let syntax = filename.split('.').pop(); - let input = helpers.readFile.call(this, filename); - return this.comb.lintString(input, {syntax: syntax}); - }, - - shouldBeEqual(input, expected) { - let syntax = input.split('.').pop(); - input = helpers.readFile.call(this, input); - expected = expected ? helpers.readFile.call(this, expected) : input; - return this.comb.processString(input, {syntax: syntax}) - .then(function(string) { - assert.equal(string, expected); - }); - }, - - /** - * Detect options in a file and compare result with expected. - * File names should be relative to test suite's folder. - * @param {Array} options List of options that should be detected - * @param {String} input Name of template file - * @param {Object} expected Expected config with detected options - */ - shouldDetect(options, input, expected) { - // We need to “sort” the input and expected objects, as their order - // may vary. - let actual = helpers.sortObject(Comb.detectInString(input, options)); - assert.equal( - JSON.stringify(helpers.sortObject(actual)), - JSON.stringify(helpers.sortObject(expected)) - ); - }, - - readFile(filename) { - let dirname = path.dirname(this.test.file); - return fs.readFileSync(dirname + '/' + filename, 'utf8'); - }, - - sortObject(o) { - let a = []; - for (let key in o) { - if (o.hasOwnProperty(key)) { - a.push(key); - } - } - a.sort(); - - let sorted = {}; - for (let key = 0; key < a.length; key++) { - sorted[a[key]] = o[a[key]]; - } - return sorted; - } -}; - -module.exports = helpers; From 72c699455c59ae95f214b93a309e80701709d3b2 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 21 Aug 2015 12:40:09 +0300 Subject: [PATCH 107/184] Refactor --- src/cli.js | 196 ++-- src/csscomb.js | 370 ++++---- src/format.js | 2 +- src/options/always-semicolon.js | 258 +++--- src/options/block-indent.js | 241 +++-- src/options/color-case.js | 102 +- src/options/color-shorthand.js | 102 +- src/options/element-case.js | 120 ++- src/options/eof-newline.js | 100 +- src/options/leading-zero.js | 70 +- src/options/quotes.js | 94 +- src/options/remove-empty-rulesets.js | 142 +-- src/options/sort-order-fallback.js | 8 +- src/options/sort-order.js | 810 ++++++++-------- src/options/space-after-colon.js | 102 +- src/options/space-after-combinator.js | 111 ++- src/options/space-after-opening-brace.js | 110 +-- src/options/space-after-selector-delimiter.js | 104 +-- src/options/space-before-closing-brace.js | 181 ++-- src/options/space-before-colon.js | 102 +- src/options/space-before-combinator.js | 105 ++- src/options/space-before-opening-brace.js | 152 ++- .../space-before-selector-delimiter.js | 112 +-- src/options/space-between-declarations.js | 159 ++-- src/options/strip-spaces.js | 104 +-- src/options/tab-size.js | 34 +- src/options/unitless-zero.js | 127 +-- src/options/vendor-prefix-align.js | 870 +++++++++--------- 28 files changed, 2561 insertions(+), 2427 deletions(-) diff --git a/src/cli.js b/src/cli.js index 263763d7..0fdb3199 100644 --- a/src/cli.js +++ b/src/cli.js @@ -13,125 +13,125 @@ var Comb = require('./csscomb'); var comb = new Comb(); var getInputData = new vow.Promise(function(resolve) { - var input = ''; - process.stdin.resume(); - process.stdin.setEncoding('utf8'); - process.stdin.on('data', function(data) { - input += data; - }); - process.stdin.on('end', function() { - resolve(input); - }); + var input = ''; + process.stdin.resume(); + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function(data) { + input += data; + }); + process.stdin.on('end', function() { + resolve(input); + }); }); function processInputData(input) { - try { - process.stdout.write(comb.processString(input)); - process.exit(0); - } catch (e) { - process.stderr.write(e.message); - process.exit(1); - } + try { + process.stdout.write(comb.processString(input)); + process.exit(0); + } catch (e) { + process.stderr.write(e.message); + process.exit(1); + } } function processSTDIN() { - getInputData.then(processInputData); + getInputData.then(processInputData); } function processFiles(files, config) { - vow.all(files.map(comb.processPath.bind(comb))).then(function(c) { - c = c.filter(function(isChanged) { - return isChanged !== undefined; - }); - - var tbchanged = c.reduce(function(a, b) { - return a + b; - }, 0); - - var changed = config.lint ? 0 : tbchanged; - - if (config.verbose) { - let message = `\n - ${c.length} file${c.length === 1 ? '' : 's'} processed\n - ${changed} file${changed === 1 ? '' : 's'} fixed\n`; - process.stdout.write(format(message)); - console.timeEnd('Time spent'); - } - - if (config.lint && tbchanged) { - process.exit(1); - } - - process.exit(0); - }).fail(function(e) { - process.stderr.write(e.stack); - process.exit(1); + vow.all(files.map(comb.processPath.bind(comb))).then(function(c) { + c = c.filter(function(isChanged) { + return isChanged !== undefined; }); -} -function getOptions() { - var parserOptions = { - boolean: ['verbose', 'lint'], - alias: { - config: 'c', - detect: 'd', - lint: 'l', - verbose: 'v' - } - }; - return parseArgs(process.argv.slice(2), parserOptions); -} + var tbchanged = c.reduce(function(a, b) { + return a + b; + }, 0); -function applyTemplate(config) { - if (!config.template) return; + var changed = config.lint ? 0 : tbchanged; - if (!fs.existsSync(config.template)) { - let message = `Template configuration file ${config.template} - was not found.`; - process.stderr.write(format(message)); - process.exit(1); + if (config.verbose) { + let message = `\n + ${c.length} file${c.length === 1 ? '' : 's'} processed\n + ${changed} file${changed === 1 ? '' : 's'} fixed\n`; + process.stdout.write(format(message)); + console.timeEnd('Time spent'); } - var templateConfig = Comb.detectInFile(config.template); - for (var attrname in templateConfig) { - if (templateConfig.hasOwnProperty(attrname) && !config[attrname]) { - config[attrname] = templateConfig[attrname]; - } + if (config.lint && tbchanged) { + process.exit(1); } + + process.exit(0); + }).fail(function(e) { + process.stderr.write(e.stack); + process.exit(1); + }); } -function getConfig(options) { - var configPath = options.config && - path.resolve(process.cwd(), options.config) || - Comb.getCustomConfigPath(); - - var config; - if (!fs.existsSync(configPath)) { - config = require('../config/csscomb.json'); - } else if (configPath.match(/\.css$/)) { - config = Comb.detectInFile(configPath); - } else { - config = Comb.getCustomConfig(configPath); +function getOptions() { + var parserOptions = { + boolean: ['verbose', 'lint'], + alias: { + config: 'c', + detect: 'd', + lint: 'l', + verbose: 'v' } + }; + return parseArgs(process.argv.slice(2), parserOptions); +} - if (!config) { - let message = `Configuration file ${configPath} was not found.`; - process.stderr.write(format(message)); - process.exit(1); +function applyTemplate(config) { + if (!config.template) return; + + if (!fs.existsSync(config.template)) { + let message = `Template configuration file ${config.template} + was not found.`; + process.stderr.write(format(message)); + process.exit(1); + } + + var templateConfig = Comb.detectInFile(config.template); + for (var attrname in templateConfig) { + if (templateConfig.hasOwnProperty(attrname) && !config[attrname]) { + config[attrname] = templateConfig[attrname]; } + } +} - applyTemplate(config); - if (options.verbose) config.verbose = options.verbose; - if (options.lint) config.lint = options.lint; - - return config; +function getConfig(options) { + var configPath = options.config && + path.resolve(process.cwd(), options.config) || + Comb.getCustomConfigPath(); + + var config; + if (!fs.existsSync(configPath)) { + config = require('../config/csscomb.json'); + } else if (configPath.match(/\.css$/)) { + config = Comb.detectInFile(configPath); + } else { + config = Comb.getCustomConfig(configPath); + } + + if (!config) { + let message = `Configuration file ${configPath} was not found.`; + process.stderr.write(format(message)); + process.exit(1); + } + + applyTemplate(config); + if (options.verbose) config.verbose = options.verbose; + if (options.lint) config.lint = options.lint; + + return config; } function detectConfig(file) { - var config = Comb.detectInFile(file); - config = JSON.stringify(config, false, 4); - process.stdout.write(config); - process.exit(0); + var config = Comb.detectInFile(file); + config = JSON.stringify(config, false, 4); + process.stdout.write(config); + process.exit(0); } console.time('Time spent'); @@ -139,10 +139,14 @@ console.time('Time spent'); var options = getOptions(); if (options.detect) { - detectConfig(options.detect); + detectConfig(options.detect); } var config = getConfig(options); comb.configure(config); -process.stdin.isTTY ? processFiles(options._, config) : processSTDIN(); +if (process.stdin.isTTY) { + processFiles(options._, config); +} else { + processSTDIN(); +} diff --git a/src/csscomb.js b/src/csscomb.js index 0681fa2a..f490c024 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -10,25 +10,25 @@ let path = require('path'); * @name CSScomb */ let CSScomb = function(config) { - let comb = new Comb(); - - // Add plugins. - fs.readdirSync(__dirname + '/options').map(function(option) { - return require('./options/' + option); - }).forEach(function(option) { - comb.use(option); - }); - - // If config was passed, configure: - if (typeof config === 'string') { - config = CSScomb.getConfig(config); - } - if (typeof config === 'object') { - comb.configure(config); - } - - // Chaining. - return comb; + let comb = new Comb(); + + // Add plugins. + fs.readdirSync(__dirname + '/options').map(function(option) { + return require('./options/' + option); + }).forEach(function(option) { + comb.use(option); + }); + + // If config was passed, configure: + if (typeof config === 'string') { + config = CSScomb.getConfig(config); + } + if (typeof config === 'object') { + comb.configure(config); + } + + // Chaining. + return comb; }; /** @@ -50,8 +50,8 @@ let CSScomb = function(config) { * @returns {Object} Detected options */ CSScomb.detectInFile = function detectInFile(file, options) { - var stylesheet = fs.readFileSync(file, 'utf8'); - return CSScomb.detectInString(stylesheet, options); + var stylesheet = fs.readFileSync(file, 'utf8'); + return CSScomb.detectInString(stylesheet, options); }; /** @@ -62,38 +62,38 @@ CSScomb.detectInFile = function detectInFile(file, options) { * @returns {Object} Detected options */ CSScomb.detectInString = function detectInString(text, options) { - var result; - var handlers = []; - - if (!text) return text; - - var optionNames = fs.readdirSync(__dirname + '/options'); - optionNames.forEach(function(option) { - option = option.slice(0, -3); - if (options && options.indexOf(option) < 0) return; - try { - handlers.push(getHandler(option)); - } catch (e) { - let message = `\nFailed to load "${option}" option:\n${e.message}`; - console.warn(message); - } - }); + var result; + var handlers = []; - var tree = cssToAST(text); - var detectedOptions = detectInTree(tree, handlers); - result = getDetectedOptions(detectedOptions, handlers); + if (!text) return text; - // Handle conflicting options with spaces around braces: - var blockIndent = result['block-indent']; - var spaceAfterOpeningBrace = result['space-after-opening-brace']; - - if (typeof blockIndent === 'string' && - spaceAfterOpeningBrace && - spaceAfterOpeningBrace.indexOf('\n') > -1) { - result['space-after-opening-brace'] = '\n'; + var optionNames = fs.readdirSync(__dirname + '/options'); + optionNames.forEach(function(option) { + option = option.slice(0, -3); + if (options && options.indexOf(option) < 0) return; + try { + handlers.push(getHandler(option)); + } catch (e) { + let message = `\nFailed to load "${option}" option:\n${e.message}`; + console.warn(message); } + }); - return result; + var tree = cssToAST(text); + var detectedOptions = detectInTree(tree, handlers); + result = getDetectedOptions(detectedOptions, handlers); + + // Handle conflicting options with spaces around braces: + var blockIndent = result['block-indent']; + var spaceAfterOpeningBrace = result['space-after-opening-brace']; + + if (typeof blockIndent === 'string' && + spaceAfterOpeningBrace && + spaceAfterOpeningBrace.indexOf('\n') > -1) { + result['space-after-opening-brace'] = '\n'; + } + + return result; }; /** @@ -103,32 +103,32 @@ CSScomb.detectInString = function detectInString(text, options) { * @returns {Object} Configuration object */ CSScomb.getConfig = function getConfig(name) { - const DEFAULT_CONFIG_NAME = 'csscomb'; - name = name || DEFAULT_CONFIG_NAME; - - if (typeof name !== 'string') { - throw new Error('Config name must be a string.'); - } - - let CONFIG_DIR_PATH = '../config'; - let dir = `${__dirname}/${CONFIG_DIR_PATH}`; - let availableConfigsNames = fs.readdirSync(dir) - .map(function(configFileName) { - return configFileName.split('.')[0]; // Strip file extension(s) - }); - - if (availableConfigsNames.indexOf(name) < 0) { - let configsNamesAsString = availableConfigsNames - .map(function(configName) { - return '\'' + configName + '\''; - }) - .join(', '); - let message = `"${name}" is not a valid config name. Try one - of the following: ${configsNamesAsString}.`; - throw new Error(format(message)); - } - - return require(CONFIG_DIR_PATH + '/' + name + '.json'); + const DEFAULT_CONFIG_NAME = 'csscomb'; + name = name || DEFAULT_CONFIG_NAME; + + if (typeof name !== 'string') { + throw new Error('Config name must be a string.'); + } + + let CONFIG_DIR_PATH = '../config'; + let dir = `${__dirname}/${CONFIG_DIR_PATH}`; + let availableConfigsNames = fs.readdirSync(dir) + .map(function(configFileName) { + return configFileName.split('.')[0]; // Strip file extension(s) + }); + + if (availableConfigsNames.indexOf(name) < 0) { + let configsNamesAsString = availableConfigsNames + .map(function(configName) { + return '\'' + configName + '\''; + }) + .join(', '); + let message = `"${name}" is not a valid config name. Try one + of the following: ${configsNamesAsString}.`; + throw new Error(format(message)); + } + + return require(CONFIG_DIR_PATH + '/' + name + '.json'); }; /** @@ -139,16 +139,16 @@ CSScomb.getConfig = function getConfig(name) { * @returns {Object|null} */ CSScomb.getCustomConfig = function getCustomConfig(configPath) { - var config; - configPath = configPath || CSScomb.getCustomConfigPath(); + var config; + configPath = configPath || CSScomb.getCustomConfigPath(); - try { - config = JSON.parse(fs.readFileSync(configPath, 'utf8')); - } catch (e) { - config = null; - } + try { + config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + } catch (e) { + config = null; + } - return config; + return config; }; /** @@ -160,29 +160,29 @@ CSScomb.getCustomConfig = function getCustomConfig(configPath) { * @returns {String | null} */ CSScomb.getCustomConfigPath = function getCustomConfigPath(configPath) { - var HOME = process.env.HOME || - process.env.HOMEPATH || - process.env.USERPROFILE; - - configPath = configPath || path.join(process.cwd(), '.csscomb.json'); - - // If we've finally found a config, return its path: - if (fs.existsSync(configPath)) return fs.realpathSync(configPath); - - // If we are in HOME dir already and yet no config file, return a default - // one from our package. - // If project is located not under HOME, compare to root instead. - // Since there appears to be no good way to get root path in - // Windows, assume that if current dir has no parent dir, we're in - // root. - var dirname = path.dirname(configPath); - var parentDirname = path.dirname(dirname); - if (dirname === HOME || dirname === parentDirname) return null; - - // If there is no config in this directory, go one level up and look for - // a config there: - configPath = path.join(parentDirname, '.csscomb.json'); - return CSScomb.getCustomConfigPath(configPath); + var HOME = process.env.HOME || + process.env.HOMEPATH || + process.env.USERPROFILE; + + configPath = configPath || path.join(process.cwd(), '.csscomb.json'); + + // If we've finally found a config, return its path: + if (fs.existsSync(configPath)) return fs.realpathSync(configPath); + + // If we are in HOME dir already and yet no config file, return a default + // one from our package. + // If project is located not under HOME, compare to root instead. + // Since there appears to be no good way to get root path in + // Windows, assume that if current dir has no parent dir, we're in + // root. + var dirname = path.dirname(configPath); + var parentDirname = path.dirname(dirname); + if (dirname === HOME || dirname === parentDirname) return null; + + // If there is no config in this directory, go one level up and look for + // a config there: + configPath = path.join(parentDirname, '.csscomb.json'); + return CSScomb.getCustomConfigPath(configPath); }; /** @@ -194,24 +194,24 @@ CSScomb.getCustomConfigPath = function getCustomConfigPath(configPath) { * @returns {Array} AST */ function cssToAST(text, syntax, filename) { - var string = JSON.stringify; - var fileInfo = filename ? ' at ' + filename : ''; - var tree; - - try { - tree = gonzales.parse(text, {syntax: syntax}); - } catch (e) { - throw new Error('Parsing error' + fileInfo + ': ' + e.message); - } - - // TODO: When can tree be undefined? - if (typeof tree === 'undefined') { - let message = `Undefined tree ${fileInfo}: ${string(text)} => - ${string(tree)}`; - throw new Error(format(message)); - } - - return tree; + var string = JSON.stringify; + var fileInfo = filename ? ' at ' + filename : ''; + var tree; + + try { + tree = gonzales.parse(text, {syntax: syntax}); + } catch (e) { + throw new Error('Parsing error' + fileInfo + ': ' + e.message); + } + + // TODO: When can tree be undefined? + if (typeof tree === 'undefined') { + let message = `Undefined tree ${fileInfo}: ${string(text)} => + ${string(tree)}`; + throw new Error(format(message)); + } + + return tree; } /** @@ -223,14 +223,14 @@ function cssToAST(text, syntax, filename) { * values */ function detectInTree(tree, handlers) { - var detectedOptions = {}; - // We walk across complete tree for each handler, - // because we need strictly maintain order in which handlers work, - // despite fact that handlers work on different level of the tree. - handlers.forEach(function(handler) { - detectedOptions[handler.name] = handler.detect(tree); - }); - return detectedOptions; + var detectedOptions = {}; + // We walk across complete tree for each handler, + // because we need strictly maintain order in which handlers work, + // despite fact that handlers work on different level of the tree. + handlers.forEach(function(handler) { + detectedOptions[handler.name] = handler.detect(tree); + }); + return detectedOptions; } /** @@ -241,53 +241,53 @@ function detectInTree(tree, handlers) { * @returns {Object} */ function getDetectedOptions(detected, handlers) { - var options = {}; - Object.keys(detected).forEach(function(option) { - // List of all the detected variants from the stylesheet - // for the given option: - var values = detected[option]; - var i; - if (!values.length) { - // If there are no values for the option, check if there is - // a default one: - for (i = handlers.length; i--;) { - if (handlers[i].name === option && - handlers[i].detectDefault !== undefined) { - options[option] = handlers[i].detectDefault; - break; - } - } - } else if (values.length === 1) { - options[option] = values[0]; + var options = {}; + Object.keys(detected).forEach(function(option) { + // List of all the detected variants from the stylesheet + // for the given option: + var values = detected[option]; + var i; + if (!values.length) { + // If there are no values for the option, check if there is + // a default one: + for (i = handlers.length; i--;) { + if (handlers[i].name === option && + handlers[i].detectDefault !== undefined) { + options[option] = handlers[i].detectDefault; + break; + } + } + } else if (values.length === 1) { + options[option] = values[0]; + } else { + // If there are more than one value for the option, find + // the most popular one; `variants` would be populated + // with the popularity for different values. + var variants = {}; + var bestGuess = null; + var maximum = 0; + for (i = values.length; i--;) { + var currentValue = values[i]; + // Count the current value: + if (variants[currentValue]) { + variants[currentValue]++; } else { - // If there are more than one value for the option, find - // the most popular one; `variants` would be populated - // with the popularity for different values. - var variants = {}; - var bestGuess = null; - var maximum = 0; - for (i = values.length; i--;) { - var currentValue = values[i]; - // Count the current value: - if (variants[currentValue]) { - variants[currentValue]++; - } else { - variants[currentValue] = 1; - } - // If the current variant is the most popular one, treat - // it as the best guess: - if (variants[currentValue] >= maximum) { - maximum = variants[currentValue]; - bestGuess = currentValue; - } - } - if (bestGuess !== null) { - options[option] = bestGuess; - } + variants[currentValue] = 1; + } + // If the current variant is the most popular one, treat + // it as the best guess: + if (variants[currentValue] >= maximum) { + maximum = variants[currentValue]; + bestGuess = currentValue; } - }); + } + if (bestGuess !== null) { + options[option] = bestGuess; + } + } + }); - return options; + return options; } /** @@ -298,15 +298,15 @@ function getDetectedOptions(detected, handlers) { * and default value for the case when nothing can be detected */ function getHandler(optionName) { - var option = require('./options/' + optionName); - if (!option.detect) - throw new Error('Option does not have `detect()` method.'); - - return { - name: option.name, - detect: option.detect, - detectDefault: option.detectDefault - }; + var option = require('./options/' + optionName); + if (!option.detect) + throw new Error('Option does not have `detect()` method.'); + + return { + name: option.name, + detect: option.detect, + detectDefault: option.detectDefault + }; } module.exports = CSScomb; diff --git a/src/format.js b/src/format.js index bdfc0f07..f2f8b376 100644 --- a/src/format.js +++ b/src/format.js @@ -1,3 +1,3 @@ module.exports = function(string) { - return string.replace(/\n\s+/gm, ' '); + return string.replace(/\n\s+/gm, ' '); }; diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index e9c8cfed..d6aec939 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -1,126 +1,144 @@ var gonzales = require('../gonzales'); -module.exports = { - name: 'always-semicolon', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - boolean: [true] - }, - - /** - * Processes tree node. - * @param {node} ast - * @return {Array} List of errors - */ - lint: function(ast) { - var errors = []; - - ast.traverseByType('block', function(block) { - block.eachFor(function(currentNode) { - var nodeWithoutSemicolon; - // Skip nodes that already have `;` at the end: - if (currentNode.is('declarationDelimiter')) return null; - - // Add semicolon only after declarations and includes. - // If current node is include, insert semicolon right into it. - // If it's declaration, look for value node: - if (currentNode.is('include') || - currentNode.is('extend')) { - nodeWithoutSemicolon = currentNode; - } else if (currentNode.is('declaration')) { - nodeWithoutSemicolon = currentNode.last('value'); - } else { - return; - } - - errors.push({ - message: 'Missing semicolon', - line: nodeWithoutSemicolon.end.line, - column: nodeWithoutSemicolon.end.column + 1 - }); - - // Stop looping through block's children: - return null; - }); - }); - - return errors; - }, - - - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'always-semicolon'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + boolean: [true] + }; + }, + + /** + * Checks ast for code style errors. + * @param {Node} ast + * @return {Array} List of found errors. + */ + lint(ast) { + var errors = []; + + ast.traverseByType('block', (block) => { + block.eachFor((currentNode) => { var nodeWithoutSemicolon; - - ast.traverseByType('block', function(block) { - block.eachFor(function(currentNode) { - // Skip nodes that already have `;` at the end: - if (currentNode.is('declarationDelimiter')) return null; - - // Add semicolon only after declarations and includes. - // If current node is include, insert semicolon right into it. - // If it's declaration, look for value node: - if (currentNode.is('include') || - currentNode.is('extend')) { - nodeWithoutSemicolon = currentNode; - } else if (currentNode.is('declaration')) { - nodeWithoutSemicolon = currentNode.last('value'); - } else { - return; - } - - // Check if there are spaces and comments at the end of the node - for (var j = nodeWithoutSemicolon.length; j--;) { - var lastNode = nodeWithoutSemicolon.get(j); - - // If the node's last child is block, do not add semicolon: - // TODO: Add syntax check and run the code only for scss - if (lastNode.is('block')) { - return null; - } else if (!lastNode.is('space') && - !lastNode.is('multilineComment') && - !lastNode.is('singlelineComment')) { - j++; - break; - } - } - - var declDelim = gonzales.createNode({ - type: 'declarationDelimiter', - content: ';' - }); - nodeWithoutSemicolon.insert(j, declDelim); - return null; - }); - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - * @return {Array} List of detected values - */ - detect: function(ast) { - var detected = []; - - ast.traverseByType('block', function(block) { - block.eachFor(function(node) { - if (node.is('declarationDelimiter')) { - detected.push(true); - return null; - } else if (node.is('declaration')) { - detected.push(false); - return null; - } - }); + // Skip nodes that already have `;` at the end: + if (currentNode.is('declarationDelimiter')) return null; + + // Add semicolon only after declarations and includes. + // If current node is include, insert semicolon right into it. + // If it's declaration, look for value node: + if (currentNode.is('include') || + currentNode.is('extend')) { + nodeWithoutSemicolon = currentNode; + } else if (currentNode.is('declaration')) { + nodeWithoutSemicolon = currentNode.last('value'); + } else { + return; + } + + errors.push({ + message: 'Missing semicolon', + line: nodeWithoutSemicolon.end.line, + column: nodeWithoutSemicolon.end.column + 1 }); - return detected; - } + // Stop looping through block's children: + return null; + }); + }); + + return errors; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + var nodeWithoutSemicolon; + + ast.traverseByType('block', (block) => { + block.eachFor((currentNode) => { + // Skip nodes that already have `;` at the end: + if (currentNode.is('declarationDelimiter')) return null; + + // Add semicolon only after declarations and includes. + // If current node is include, insert semicolon right into it. + // If it's declaration, look for value node: + if (currentNode.is('include') || + currentNode.is('extend')) { + nodeWithoutSemicolon = currentNode; + } else if (currentNode.is('declaration')) { + nodeWithoutSemicolon = currentNode.last('value'); + } else { + return; + } + + // Check if there are spaces and comments at the end of the node + for (var j = nodeWithoutSemicolon.length; j--;) { + var lastNode = nodeWithoutSemicolon.get(j); + + // If the node's last child is block, do not add semicolon: + // TODO: Add syntax check and run the code only for scss + if (lastNode.is('block')) { + return null; + } else if (!lastNode.is('space') && + !lastNode.is('multilineComment') && + !lastNode.is('singlelineComment')) { + j++; + break; + } + } + + var declDelim = gonzales.createNode({ + type: 'declarationDelimiter', + content: ';' + }); + nodeWithoutSemicolon.insert(j, declDelim); + return null; + }); + }); + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + var detected = []; + + ast.traverseByType('block', (block) => { + block.eachFor((node) => { + if (node.is('declarationDelimiter')) { + detected.push(true); + return null; + } else if (node.is('declaration')) { + detected.push(false); + return null; + } + }); + }); + + return detected; + } }; + +module.exports = option; diff --git a/src/options/block-indent.js b/src/options/block-indent.js index e82bc20a..3da174ac 100644 --- a/src/options/block-indent.js +++ b/src/options/block-indent.js @@ -1,103 +1,140 @@ -module.exports = { - name: 'block-indent', - - runBefore: 'sort-order', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - number: true, - string: /^[ \t]*$/ - }, - - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function process(ast) { - ast.eachFor('space', function(whitespaceNode, i) { - var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); - - if (spaces === '') { - ast.remove(i); - } else { - whitespaceNode.content = spaces; - } - }); - - this._processNode(ast, 0); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - var detected = []; - - ast.traverse(function(node) { - // Continue only with non-empty {...} blocks: - if (!node.is('atrulers') && !node.is('block') || !node.length) - return; - - node.eachFor('space', function(whitespaceNode) { - var spaces = whitespaceNode.content; - var lastIndex = spaces.lastIndexOf('\n'); - - // Do not continue if there is no line break: - if (lastIndex < 0) return; - - // Number of spaces from beginning of line: - var spacesLength = spaces.slice(lastIndex + 1).length + 1; - detected.push(new Array(spacesLength).join(' ')); - }); - }); - - return detected; - }, - - _processNode: function _processNode(node, level) { - var that = this; - - node.forEach(function(n) { - if (node.syntax === 'sass' && n.is('block')) { - that._processSassBlock(n, level); - } - - // Continue only with space nodes inside {...}: - if (node.syntax !== 'sass' && level !== 0 && n.is('space')) { - that._processSpaceNode(n, level); - } - - if (n.is('block') || n.is('atrulers')) level++; - - that._processNode(n, level); - }); - }, - - _processSassBlock: function _processSassBlock(node, level) { - var value = this.value; - - node.eachFor('space', function(whitespaceNode) { - if (whitespaceNode.content === '\n') return; - - var spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); - spaces += new Array(level + 2).join(value); - whitespaceNode.content = spaces; - }); - }, - - _processSpaceNode: function _processSpaceNode(node, level) { - var value = this.value; - - // Remove all whitespaces and tabs, leave only new lines: - var spaces = node.content.replace(/[ \t]/gm, ''); - - if (!spaces) return; - - spaces += new Array(level + 1).join(value); - node.content = spaces; - } +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'block-indent'; + }, + + /** + * Name of option that must run after this option. + * @type {String} + */ + get runBefore() { + return 'sort-order'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + number: true, + string: /^[ \t]*$/ + }; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + ast.eachFor('space', function(whitespaceNode, i) { + var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); + + if (spaces === '') { + ast.remove(i); + } else { + whitespaceNode.content = spaces; + } + }); + + this._processNode(ast, 0); + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + var detected = []; + + ast.traverse(function(node) { + // Continue only with non-empty {...} blocks: + if (!node.is('atrulers') && !node.is('block') || !node.length) + return; + + node.eachFor('space', function(whitespaceNode) { + var spaces = whitespaceNode.content; + var lastIndex = spaces.lastIndexOf('\n'); + + // Do not continue if there is no line break: + if (lastIndex < 0) return; + + // Number of spaces from beginning of line: + var spacesLength = spaces.slice(lastIndex + 1).length + 1; + detected.push(new Array(spacesLength).join(' ')); + }); + }); + + return detected; + }, + + /** + * @param {Node} node + * @param {Number} level + */ + _processNode(node, level) { + var that = this; + + node.forEach(function(n) { + if (node.syntax === 'sass' && n.is('block')) { + that._processSassBlock(n, level); + } + + // Continue only with space nodes inside {...}: + if (node.syntax !== 'sass' && level !== 0 && n.is('space')) { + that._processSpaceNode(n, level); + } + + if (n.is('block') || n.is('atrulers')) level++; + + that._processNode(n, level); + }); + }, + + /** + * @param {Node} node + * @param {Number} level + */ + _processSassBlock(node, level) { + var value = this.value; + + node.eachFor('space', function(whitespaceNode) { + if (whitespaceNode.content === '\n') return; + + var spaces = whitespaceNode.content.replace(/[ \t]/gm, ''); + spaces += new Array(level + 2).join(value); + whitespaceNode.content = spaces; + }); + }, + + /** + * @param {Node} node + * @param {Number} level + */ + _processSpaceNode(node, level) { + var value = this.value; + + // Remove all whitespaces and tabs, leave only new lines: + var spaces = node.content.replace(/[ \t]/gm, ''); + + if (!spaces) return; + + spaces += new Array(level + 1).join(value); + node.content = spaces; + } }; + +module.exports = option; diff --git a/src/options/color-case.js b/src/options/color-case.js index 27fb1a15..bfaed417 100644 --- a/src/options/color-case.js +++ b/src/options/color-case.js @@ -1,42 +1,62 @@ -module.exports = { - name: 'color-case', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - string: /^lower|upper$/ - }, - - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - var value = this.value; - - ast.traverseByType('color', function(color) { - color.content = value === 'lower' ? - color.content.toLowerCase() : - color.content.toUpperCase(); - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - var detected = []; - - ast.traverseByType('color', function(color) { - if (color.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { - detected.push('lower'); - } else if (color.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { - detected.push('upper'); - } - }); - - return detected; - } +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'color-case'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + string: /^lower|upper$/ + }; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + var value = this.value; + + ast.traverseByType('color', function(color) { + color.content = value === 'lower' ? + color.content.toLowerCase() : + color.content.toUpperCase(); + }); + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + var detected = []; + + ast.traverseByType('color', function(color) { + if (color.content.match(/^[^A-F]*[a-f][^A-F]*$/)) { + detected.push('lower'); + } else if (color.content.match(/^[^a-f]*[A-F][^a-f]*$/)) { + detected.push('upper'); + } + }); + + return detected; + } }; + +module.exports = option; diff --git a/src/options/color-shorthand.js b/src/options/color-shorthand.js index 96433d38..f33f9edd 100644 --- a/src/options/color-shorthand.js +++ b/src/options/color-shorthand.js @@ -1,42 +1,62 @@ -module.exports = { - name: 'color-shorthand', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - boolean: [true, false] - }, - - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - var value = this.value; - - ast.traverseByType('color', function(color) { - color.content = value ? - color.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : - color.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - var detected = []; - - ast.traverseByType('color', function(color) { - if (color.content.match(/^\w{3}$/)) { - detected.push(true); - } else if (color.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { - detected.push(false); - } - }); - - return detected; - } +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'color-shorthand'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + boolean: [true, false] + }; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + var value = this.value; + + ast.traverseByType('color', function(color) { + color.content = value ? + color.content.replace(/(\w)\1(\w)\2(\w)\3/i, '$1$2$3') : + color.content.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3'); + }); + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + var detected = []; + + ast.traverseByType('color', function(color) { + if (color.content.match(/^\w{3}$/)) { + detected.push(true); + } else if (color.content.match(/^(\w)\1(\w)\2(\w)\3$/)) { + detected.push(false); + } + }); + + return detected; + } }; + +module.exports = option; diff --git a/src/options/element-case.js b/src/options/element-case.js index 5b416b05..152ce89a 100644 --- a/src/options/element-case.js +++ b/src/options/element-case.js @@ -1,54 +1,74 @@ -module.exports = { - name: 'element-case', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - string: /^lower|upper$/ - }, - - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - let value = this.value; - - ast.traverse(function(node) { - if (!node.is('selector') && !node.is('arguments')) return; - - node.forEach('simpleSelector', function(selector) { - selector.forEach('ident', function(ident) { - ident.content = value === 'lower' ? - ident.content.toLowerCase() : - ident.content.toUpperCase(); - }); - }); +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'element-case'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + string: /^lower|upper$/ + }; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + let value = this.value; + + ast.traverse((node) => { + if (!node.is('selector') && !node.is('arguments')) return; + + node.forEach('simpleSelector', (selector) => { + selector.forEach('ident', (ident) => { + ident.content = value === 'lower' ? + ident.content.toLowerCase() : + ident.content.toUpperCase(); }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverse(function(node) { - if (!node.is('selector') && !node.is('arguments')) return; - - node.forEach('simpleSelector', function(selector) { - selector.forEach('ident', function(ident) { - if (ident.content.match(/^[a-z]+$/)) { - detected.push('lower'); - } else if (ident.content.match(/^[A-Z]+$/)) { - detected.push('upper'); - } - }); - }); + }); + }); + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + let detected = []; + + ast.traverse((node) => { + if (!node.is('selector') && !node.is('arguments')) return; + + node.forEach('simpleSelector', (selector) => { + selector.forEach('ident', (ident) => { + if (ident.content.match(/^[a-z]+$/)) { + detected.push('lower'); + } else if (ident.content.match(/^[A-Z]+$/)) { + detected.push('upper'); + } }); + }); + }); - return detected; - } + return detected; + } }; + +module.exports = option; diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index 3e6163b0..8492e326 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -1,42 +1,62 @@ -var gonzales = require('../gonzales'); - -module.exports = { - name: 'eof-newline', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - boolean: [true, false] - }, - - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - var lastChild = ast.last(); - - if (!lastChild.is('space')) { - lastChild = gonzales.createNode({type: 'space', content: ''}); - ast.content.push(lastChild); - } - - lastChild.content = lastChild.content.replace(/\n$/, ''); - if (this.value) lastChild.content += '\n'; - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - var lastChild = ast.last(); - - if (lastChild.is('space') && lastChild.content.indexOf('\n') !== -1) { - return [true]; - } else { - return [false]; - } +let gonzales = require('../gonzales'); + +let option = { + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'eof-newline'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + boolean: [true, false] + }; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + var lastChild = ast.last(); + + if (!lastChild.is('space')) { + lastChild = gonzales.createNode({type: 'space', content: ''}); + ast.content.push(lastChild); } + + lastChild.content = lastChild.content.replace(/\n$/, ''); + if (this.value) lastChild.content += '\n'; + }, + + /** + * Detects the value of this option in ast. + * @param {Node} ast + * @return {Array} List of detected values + */ + detect(ast) { + var lastChild = ast.last(); + + if (lastChild.is('space') && lastChild.content.indexOf('\n') !== -1) { + return [true]; + } else { + return [false]; + } + } }; + +module.exports = option; diff --git a/src/options/leading-zero.js b/src/options/leading-zero.js index 5fb198a5..4aba1f4c 100644 --- a/src/options/leading-zero.js +++ b/src/options/leading-zero.js @@ -1,44 +1,44 @@ module.exports = { - name: 'leading-zero', + name: 'leading-zero', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - boolean: [true, false] - }, + accepts: { + boolean: [true, false] + }, - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('number', function(number) { - if (!value) { - number.content = number.content.replace(/^0+(?=\.)/, ''); - } else if (number.content[0] === '.') { - number.content = '0' + number.content; - } - }); - }, + ast.traverseByType('number', function(number) { + if (!value) { + number.content = number.content.replace(/^0+(?=\.)/, ''); + } else if (number.content[0] === '.') { + number.content = '0' + number.content; + } + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('number', function(number) { - if (number.content.match(/^\.[0-9]+/)) { - detected.push(false); - } else if (number.content.match(/^0\.[0-9]+/)) { - detected.push(true); - } - }); + ast.traverseByType('number', function(number) { + if (number.content.match(/^\.[0-9]+/)) { + detected.push(false); + } else if (number.content.match(/^0\.[0-9]+/)) { + detected.push(true); + } + }); - return detected; - } + return detected; + } }; diff --git a/src/options/quotes.js b/src/options/quotes.js index 153454ed..bc96d5f7 100644 --- a/src/options/quotes.js +++ b/src/options/quotes.js @@ -1,56 +1,56 @@ module.exports = { - name: 'quotes', + name: 'quotes', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - string: /^single|double$/ - }, + accepts: { + string: /^single|double$/ + }, - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('string', function(string) { - if (string.content[0] === '"' && value === 'single') { - string.content = string.content - // Unescape all escaped double quotes - .replace(/\\"/g, '"') - // Escape all the single quotes - .replace(/([^\\])'/g, '$1\\\'') - // Replace the first and the last quote - .replace(/^"|"$/g, '\''); - } else if (string.content[0] === '\'' && value === 'double') { - string.content = string.content - // Unescape all escaped single quotes - .replace(/\\'/g, '\'') - // Escape all the double quotes - .replace(/([^\\])"/g, '$1\\\"') - // Replace the first and the last quote - .replace(/^'|'$/g, '"'); - } - }); - }, + ast.traverseByType('string', function(string) { + if (string.content[0] === '"' && value === 'single') { + string.content = string.content + // Unescape all escaped double quotes + .replace(/\\"/g, '"') + // Escape all the single quotes + .replace(/([^\\])'/g, '$1\\\'') + // Replace the first and the last quote + .replace(/^"|"$/g, '\''); + } else if (string.content[0] === '\'' && value === 'double') { + string.content = string.content + // Unescape all escaped single quotes + .replace(/\\'/g, '\'') + // Escape all the double quotes + .replace(/([^\\])"/g, '$1\\\"') + // Replace the first and the last quote + .replace(/^'|'$/g, '"'); + } + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('string', function(string) { - if (string.content[0] === '"') { - detected.push('double'); - } else if (string.content[0] === '\'') { - detected.push('single'); - } - }); + ast.traverseByType('string', function(string) { + if (string.content[0] === '"') { + detected.push('double'); + } else if (string.content[0] === '\'') { + detected.push('single'); + } + }); - return detected; - } + return detected; + } }; diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index 29e63d53..cc7512ae 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -1,88 +1,88 @@ module.exports = (function() { - function processNode(node) { - removeEmptyRulesets(node); - mergeAdjacentWhitespace(node); - } + function processNode(node) { + removeEmptyRulesets(node); + mergeAdjacentWhitespace(node); + } - function removeEmptyRulesets(stylesheet) { - stylesheet.forEach('ruleset', function(ruleset, i) { - var block = ruleset.first('block'); - processNode(block); - if (isEmptyBlock(block)) stylesheet.remove(i); - }); - } + function removeEmptyRulesets(stylesheet) { + stylesheet.forEach('ruleset', function(ruleset, i) { + var block = ruleset.first('block'); + processNode(block); + if (isEmptyBlock(block)) stylesheet.remove(i); + }); + } - /** - * Removing ruleset nodes from tree may result in two adjacent whitespace - * nodes which is not correct AST: - * [space, ruleset, space] => [space, space] - * To ensure correctness of further processing we should merge such nodes - * into one: - * [space, space] => [space] - */ - function mergeAdjacentWhitespace(node) { - var i = node.content.length - 1; - while (i-- > 0) { - if (node.get(i).is('space') && node.get(i + 1).is('space')) { - node.get(i).content += node.get(i + 1).content; - node.remove(i + 1); - } - } + /** + * Removing ruleset nodes from tree may result in two adjacent whitespace + * nodes which is not correct AST: + * [space, ruleset, space] => [space, space] + * To ensure correctness of further processing we should merge such nodes + * into one: + * [space, space] => [space] + */ + function mergeAdjacentWhitespace(node) { + var i = node.content.length - 1; + while (i-- > 0) { + if (node.get(i).is('space') && node.get(i + 1).is('space')) { + node.get(i).content += node.get(i + 1).content; + node.remove(i + 1); + } } + } - /** - * Block is considered empty when it has nothing but spaces. - */ - function isEmptyBlock(node) { - if (!node.length) return true; + /** + * Block is considered empty when it has nothing but spaces. + */ + function isEmptyBlock(node) { + if (!node.length) return true; - return !node.content.some(function(node) { - return !node.is('space'); - }); - } + return !node.content.some(function(node) { + return !node.is('space'); + }); + } - return { - name: 'remove-empty-rulesets', + return { + name: 'remove-empty-rulesets', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - boolean: [true] - }, + accepts: { + boolean: [true] + }, - /** - * Remove rulesets with no declarations. - * - * @param {String} ast - */ - process: function(ast) { - processNode(ast); - }, - - detectDefault: true, + /** + * Remove rulesets with no declarations. + * + * @param {String} ast + */ + process: function(ast) { + processNode(ast); + }, - /** - * Detects the value of an option at the tree node. - * This option is treated as `true` by default, but any trailing space - * would invalidate it. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + detectDefault: true, - ast.traverse(function(node) { - if (!node.is('atrulers') && !node.is('block')) return; + /** + * Detects the value of an option at the tree node. + * This option is treated as `true` by default, but any trailing space + * would invalidate it. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - if (node.length === 0 || - (node.length === 1 && node.first().is('space'))) { - detected.push(false); - } - }); + ast.traverse(function(node) { + if (!node.is('atrulers') && !node.is('block')) return; - return detected; + if (node.length === 0 || + (node.length === 1 && node.first().is('space'))) { + detected.push(false); } - }; + }); + + return detected; + } + }; })(); diff --git a/src/options/sort-order-fallback.js b/src/options/sort-order-fallback.js index 6a4189b0..182c33af 100644 --- a/src/options/sort-order-fallback.js +++ b/src/options/sort-order-fallback.js @@ -1,9 +1,9 @@ module.exports = { - name: 'sort-order-fallback', + name: 'sort-order-fallback', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: {string: /^abc$/}, + accepts: {string: /^abc$/}, - process: function() {} + process: function() {} }; diff --git a/src/options/sort-order.js b/src/options/sort-order.js index a48d10ca..80e85b1b 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -1,419 +1,419 @@ var gonzales = require('../gonzales'); module.exports = { - get name() { - return 'sort-order'; - }, - - get runBefore() { - return 'space-before-closing-brace'; - }, - - get syntax() { - return ['css', 'less', 'sass', 'scss']; - }, - - /** - * @param {Array} value Option value - * @returns {Array} - */ - setValue(value) { - if (!Array.isArray(value)) - throw new Error('The option accepts only array of properties.'); - - var order = {}; - - if (typeof value[0] === 'string') { - // If there is only one group of properties. - value.forEach(function(prop, propIndex) { - order[prop] = {group: 0, prop: propIndex}; - }); - } else { - value.forEach(function(group, groupIndex) { - group.forEach(function(prop, propIndex) { - order[prop] = {group: groupIndex, prop: propIndex}; - }); - }); - } - - return order; - }, - - /** - * @param {node} ast - * @param {object} config - */ - process(ast, config) { - this._config = config; - // Sort properties only inside blocks. - ast.traverseByType('block', this._processBlock.bind(this)); - }, - - _cleanSassLinebreaks(node) { - let containsOnlyLinebreaks = true; - - node.forEach((space) => { - if (!space.is('space') || space.content !== '\n') { - containsOnlyLinebreaks = false; - return null; - } + get name() { + return 'sort-order'; + }, + + get runBefore() { + return 'space-before-closing-brace'; + }, + + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * @param {Array} value Option value + * @returns {Array} + */ + setValue(value) { + if (!Array.isArray(value)) + throw new Error('The option accepts only array of properties.'); + + var order = {}; + + if (typeof value[0] === 'string') { + // If there is only one group of properties. + value.forEach(function(prop, propIndex) { + order[prop] = {group: 0, prop: propIndex}; + }); + } else { + value.forEach(function(group, groupIndex) { + group.forEach(function(prop, propIndex) { + order[prop] = {group: groupIndex, prop: propIndex}; }); + }); + } - if (containsOnlyLinebreaks) - node.content = []; - }, - - _extendNode(block, i, spacesBefore) { - let nodesToDelete = [i]; - let node = block.get(i); - let extendedNode = {i: i, node: node}; - - let propertyName = this._getSortableName(node); - if (!propertyName) return null; - - // Check if current node's property name is in sort order. - let propertyIndex = this.value[propertyName]; - // If the declaration's property is in order's list, save its - // group and property indices. Otherwise set them to 10000, so - // declaration appears at the bottom of a sorted list: - extendedNode.groupIndex = propertyIndex && propertyIndex.group > -1 ? - propertyIndex.group : this._getLastGroupIndex(); - extendedNode.propertyIndex = propertyIndex && propertyIndex.prop > -1 ? - propertyIndex.prop : this._getLastPropertyIndex(); - - // Spaces before node. - nodesToDelete = nodesToDelete.concat(spacesBefore); - extendedNode.spacesBeforeNode = - this._getNodesByIndex(block, spacesBefore); - - // Spaces after node. - let spacesBeforeDelimiter = + return order; + }, + + /** + * @param {node} ast + * @param {object} config + */ + process(ast, config) { + this._config = config; + // Sort properties only inside blocks. + ast.traverseByType('block', this._processBlock.bind(this)); + }, + + _cleanSassLinebreaks(node) { + let containsOnlyLinebreaks = true; + + node.forEach((space) => { + if (!space.is('space') || space.content !== '\n') { + containsOnlyLinebreaks = false; + return null; + } + }); + + if (containsOnlyLinebreaks) + node.content = []; + }, + + _extendNode(block, i, spacesBefore) { + let nodesToDelete = [i]; + let node = block.get(i); + let extendedNode = {i: i, node: node}; + + let propertyName = this._getSortableName(node); + if (!propertyName) return null; + + // Check if current node's property name is in sort order. + let propertyIndex = this.value[propertyName]; + // If the declaration's property is in order's list, save its + // group and property indices. Otherwise set them to 10000, so + // declaration appears at the bottom of a sorted list: + extendedNode.groupIndex = propertyIndex && propertyIndex.group > -1 ? + propertyIndex.group : this._getLastGroupIndex(); + extendedNode.propertyIndex = propertyIndex && propertyIndex.prop > -1 ? + propertyIndex.prop : this._getLastPropertyIndex(); + + // Spaces before node. + nodesToDelete = nodesToDelete.concat(spacesBefore); + extendedNode.spacesBeforeNode = + this._getNodesByIndex(block, spacesBefore); + + // Spaces after node. + let spacesBeforeDelimiter = + this._getSpacesAndCommentsAfterNode(block, i); + nodesToDelete = nodesToDelete.concat(spacesBeforeDelimiter); + extendedNode.spacesBeforeDelimiter = + this._getNodesByIndex(block, spacesBeforeDelimiter); + + i += spacesBeforeDelimiter.length + 1; + node = block.get(i); + + // Spaces after delimiter. + // If there is `;` right after the declaration, save it with the + // declaration and mark it for removing from parent node: + if (node && node.is('declarationDelimiter')) { + nodesToDelete.push(i); + extendedNode.delim = node; + + if (node.syntax !== 'sass') { + // Save spaces and comments which follow right after + // the declaration and mark them for removing from parent node: + let spacesAfterDelimiter = this._getSpacesAndCommentsAfterNode(block, i); - nodesToDelete = nodesToDelete.concat(spacesBeforeDelimiter); - extendedNode.spacesBeforeDelimiter = - this._getNodesByIndex(block, spacesBeforeDelimiter); - - i += spacesBeforeDelimiter.length + 1; - node = block.get(i); - - // Spaces after delimiter. - // If there is `;` right after the declaration, save it with the - // declaration and mark it for removing from parent node: - if (node && node.is('declarationDelimiter')) { - nodesToDelete.push(i); - extendedNode.delim = node; - - if (node.syntax !== 'sass') { - // Save spaces and comments which follow right after - // the declaration and mark them for removing from parent node: - let spacesAfterDelimiter = - this._getSpacesAndCommentsAfterNode(block, i); - i += spacesAfterDelimiter.length; - nodesToDelete = nodesToDelete.concat(spacesAfterDelimiter); - extendedNode.spacesAfterDelimiter = - this._getNodesByIndex(block, spacesAfterDelimiter); - } - } - - extendedNode.endIndex = i; - // Remove all nodes, that were moved to `sortables` list, - // from block node: - extendedNode.nodesToDelete = nodesToDelete; - - return extendedNode; - }, - - _getLastGroupIndex() { - return this.value && this.value['...'] ? - this.value['...'].group : Infinity; - }, - - _getLastPropertyIndex() { - return this.value && this.value['...'] ? - this.value['...'].prop : Infinity; - }, - - _getNodesByIndex(block, index) { - return index.map((i) => block.get(i)); - }, - - _getSortableIncludeName(node) { - // Divide `include` into mixins with specific name - // (e. g. `$include breakpoint`), and the rest — `$include`. - let mixinName; - - // TODO(tonyganch): explain `first.first`. - if (node.syntax === 'less') - mixinName = node.first().first().content; - else if (node.syntax === 'sass' && node.first().content === '+') - mixinName = node.get(1).first().content; - else - mixinName = node.get(2).first().content; - - let includeMixinName = '$include ' + mixinName; - return this.value.hasOwnProperty(includeMixinName) ? - includeMixinName : - '$include'; - }, - - _getSortableName(node) { - if (node.is('extend')) return '$extend'; - if (node.is('include')) return this._getSortableIncludeName(node); - else return this._getSortablePropertyName(node); - }, - - _getSortablePropertyName(node) { - if (node.is('declaration')) { - let property = node.first('property').first(); - return property.is('variable') ? '$variable' : property.content; - } + i += spacesAfterDelimiter.length; + nodesToDelete = nodesToDelete.concat(spacesAfterDelimiter); + extendedNode.spacesAfterDelimiter = + this._getNodesByIndex(block, spacesAfterDelimiter); + } + } - let atkeyword = node.first('atkeyword'); - if (atkeyword && atkeyword.first().content === 'import') - return '$import'; - }, - - _getSpacesAndCommentsAfterNode(node, i) { - // List of start positions for nodes with spaces and comments: - let positions = []; - - // Skip node itself. - i++; - - for (let l = node.length; i < l; i++) { - let currentNode = node.get(i); - - // If node is nor spaces neither comment, stop. - if (!this._isSpaceOrComment(currentNode)) break; - - if (currentNode.is('multilineComment') || - currentNode.is('singlelineComment')) { - positions.push(i); - continue; - } - - // If there are any line breaks in a node with spaces, stop and - // split the node into two: one with spaces before line break - // and one with `\n` symbol and everything that goes after. - // Combine the first one with declaration/@-rule's node: - let linebreakIndex = currentNode.content.indexOf('\n'); - if (linebreakIndex !== -1) { - var s = currentNode.content.substring(0, linebreakIndex); - if (s === '') break; - var space = gonzales.createNode({type: 'space', content: s}); - node.insert(i + 1, space); - positions.push(i + 1); - currentNode.content = currentNode.content - .substring(linebreakIndex); - break; - } - - positions.push(i); - } + extendedNode.endIndex = i; + // Remove all nodes, that were moved to `sortables` list, + // from block node: + extendedNode.nodesToDelete = nodesToDelete; + + return extendedNode; + }, + + _getLastGroupIndex() { + return this.value && this.value['...'] ? + this.value['...'].group : Infinity; + }, + + _getLastPropertyIndex() { + return this.value && this.value['...'] ? + this.value['...'].prop : Infinity; + }, + + _getNodesByIndex(block, index) { + return index.map((i) => block.get(i)); + }, + + _getSortableIncludeName(node) { + // Divide `include` into mixins with specific name + // (e. g. `$include breakpoint`), and the rest — `$include`. + let mixinName; + + // TODO(tonyganch): explain `first.first`. + if (node.syntax === 'less') + mixinName = node.first().first().content; + else if (node.syntax === 'sass' && node.first().content === '+') + mixinName = node.get(1).first().content; + else + mixinName = node.get(2).first().content; + + let includeMixinName = '$include ' + mixinName; + return this.value.hasOwnProperty(includeMixinName) ? + includeMixinName : + '$include'; + }, + + _getSortableName(node) { + if (node.is('extend')) return '$extend'; + if (node.is('include')) return this._getSortableIncludeName(node); + else return this._getSortablePropertyName(node); + }, + + _getSortablePropertyName(node) { + if (node.is('declaration')) { + let property = node.first('property').first(); + return property.is('variable') ? '$variable' : property.content; + } - return positions; - }, - - /** - * Check if there are any comments or spaces before - * the declaration/@-rule. - * @param {Node} node - * @param {Number} i - * @returns {Array} List of nodes with spaces and comments - */ - _getSpacesAndCommentsBeforeNode(node, i) { - // List of start positions for nodes with spaces and comments: - let positions = []; - let sendPositions = false; - - for (let l = node.length; i < l; i++) { - let currentNode = node.get(i); - - // If the node is declaration or @-rule, stop and return all - // found nodes with spaces and comments (if there are any): - if (!this._isSpaceOrComment(currentNode)) { - sendPositions = true; - break; - } - - positions.push(i); - } + let atkeyword = node.first('atkeyword'); + if (atkeyword && atkeyword.first().content === 'import') + return '$import'; + }, + + _getSpacesAndCommentsAfterNode(node, i) { + // List of start positions for nodes with spaces and comments: + let positions = []; + + // Skip node itself. + i++; + + for (let l = node.length; i < l; i++) { + let currentNode = node.get(i); + + // If node is nor spaces neither comment, stop. + if (!this._isSpaceOrComment(currentNode)) break; + + if (currentNode.is('multilineComment') || + currentNode.is('singlelineComment')) { + positions.push(i); + continue; + } + + // If there are any line breaks in a node with spaces, stop and + // split the node into two: one with spaces before line break + // and one with `\n` symbol and everything that goes after. + // Combine the first one with declaration/@-rule's node: + let linebreakIndex = currentNode.content.indexOf('\n'); + if (linebreakIndex !== -1) { + var s = currentNode.content.substring(0, linebreakIndex); + if (s === '') break; + var space = gonzales.createNode({type: 'space', content: s}); + node.insert(i + 1, space); + positions.push(i + 1); + currentNode.content = currentNode.content + .substring(linebreakIndex); + break; + } + + positions.push(i); + } - return sendPositions ? positions : null; - }, - - _insertSortablesToBlock(nodesToSort, node) { - if (node.syntax === 'sass') - this._cleanSassLinebreaks(node); - - for (let i = nodesToSort.length - 1, l = -1; i > l; i--) { - let currentNode = nodesToSort[i]; - let prevNode = nodesToSort[i - 1]; - let spacesBeforeNode = currentNode.spacesBeforeNode || []; - let spacesBeforeDelimiter = currentNode.spacesBeforeDelimiter || []; - let spacesAfterDelimiter = currentNode.spacesAfterDelimiter || []; - - spacesBeforeNode.reverse().map(this._removeEmptyLines); - spacesBeforeDelimiter.reverse().map(this._removeEmptyLines); - spacesAfterDelimiter.reverse().map(this._removeEmptyLines); - - // Divide declarations from different groups with - // an empty line: - if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { - let space = spacesBeforeNode[0]; - if (space && space.is('space') && - (space.syntax === 'sass' || - space.content.match(/\n/g) && - space.content.match(/\n/g).length < 2)) { - space.content = '\n' + space.content; - } - } - - for (let j = 0, nl = spacesAfterDelimiter.length; j < nl; j++) { - node.content.unshift(spacesAfterDelimiter[j]); - } - - if (currentNode.delim) { - node.content.unshift(currentNode.delim); - } else if (i !== nodesToSort.length - 1 && - (currentNode.node.is('declaration') || - currentNode.node.is('extend'))) { - let delimiter = gonzales.createNode({ - type: 'declarationDelimiter', - content: currentNode.node.syntax === 'sass' ? '\n' : ';' - }); - node.content.unshift(delimiter); - } - - for (let j = 0, nl = spacesBeforeDelimiter.length; j < nl; j++) { - node.content.unshift(spacesBeforeDelimiter[j]); - } - - node.content.unshift(currentNode.node); - - for (let j = 0, nl = spacesBeforeNode.length; j < nl; j++) { - node.content.unshift(spacesBeforeNode[j]); - } - } - }, - - // Types of nodes that can be sorted. - _isAcceptableNode(node) { - const NODES = ['atruleb', 'atruler', 'atrules', - 'declaration', 'extend', 'include', - 'multilineComment', 'singlelineComment', 'space']; - return NODES.indexOf(node.type) !== -1; - }, - - // Spaces and comments. - _isSpaceOrComment(node) { - const SC = ['multilineComment', 'singlelineComment', 'space']; - return SC.indexOf(node.type) !== -1; - }, - - _processBlock(block) { - // Check every child node. - // If it is declaration (property-value pair, e.g. `color: tomato`), - // or @-rule (e.g. `@include nani`), - // combine it with spaces, semicolon and comments and move them from - // current node to a separate list for further sorting: - let nodesToSort = this._separateSortablesFromBlock(block); - this._sortNodes(nodesToSort); - this._insertSortablesToBlock(nodesToSort, block); - }, - - /** - * Remove empty lines in space node. - * @param {node} node Space node. - */ - _removeEmptyLines(node) { - node.content = node.content.replace(/\n[\s\t\n\r]*\n/, '\n'); - }, - - _separateSortablesFromBlock(block) { - let sortables = []; - let nodesToDelete = []; - - // Don't cache `block.length` since we may insert new nodes into it. - for (let i = 0; i < block.length; i++) { - let node = block.get(i); - if (!this._isAcceptableNode(node)) continue; - - // Save preceding spaces and comments, if there are any, - // and mark them for removing from parent node: - let spacesBeforeNode = - this._getSpacesAndCommentsBeforeNode(block, i); - if (!spacesBeforeNode) break; - - i += spacesBeforeNode.length; - node = block.get(i); - - let extendedNode = this._extendNode(block, i, spacesBeforeNode); - if (!extendedNode) continue; - - nodesToDelete = nodesToDelete.concat(extendedNode.nodesToDelete); - i = extendedNode.endIndex; - sortables.push(extendedNode); - } + return positions; + }, + + /** + * Check if there are any comments or spaces before + * the declaration/@-rule. + * @param {Node} node + * @param {Number} i + * @returns {Array} List of nodes with spaces and comments + */ + _getSpacesAndCommentsBeforeNode(node, i) { + // List of start positions for nodes with spaces and comments: + let positions = []; + let sendPositions = false; + + for (let l = node.length; i < l; i++) { + let currentNode = node.get(i); + + // If the node is declaration or @-rule, stop and return all + // found nodes with spaces and comments (if there are any): + if (!this._isSpaceOrComment(currentNode)) { + sendPositions = true; + break; + } + + positions.push(i); + } - nodesToDelete.sort((a, b) => a - b); - for (let x = nodesToDelete.length - 1; x > -1; x--) - block.remove(nodesToDelete[x]); - - return sortables; - }, - - _sortLeftovers(a, b) { - let prefixes = ['-webkit-', '-moz-', '-ms-', '-o-', '']; - let prefixesRegExp = /^(-webkit-|-moz-|-ms-|-o-)(.*)$/; - - // Get property name (i.e. `color`, `-o-animation`): - a = a.node.first().first().content; - b = b.node.first().first().content; - - // Get prefix and unprefixed part. For example: - // ['-o-animation', '-o-', 'animation'] - // ['color', '', 'color'] - a = a.match(prefixesRegExp) || [a, '', a]; - b = b.match(prefixesRegExp) || [b, '', b]; - - if (a[2] !== b[2]) { - // If unprefixed parts are different (i.e. `border` and - // `color`), compare them: - return a[2] < b[2] ? -1 : 1; - } else { - // If unprefixed parts are identical (i.e. `border` in - // `-moz-border` and `-o-border`), compare prefixes. - // They should go in the same order they are set - // in `prefixes` array. - return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; + return sendPositions ? positions : null; + }, + + _insertSortablesToBlock(nodesToSort, node) { + if (node.syntax === 'sass') + this._cleanSassLinebreaks(node); + + for (let i = nodesToSort.length - 1, l = -1; i > l; i--) { + let currentNode = nodesToSort[i]; + let prevNode = nodesToSort[i - 1]; + let spacesBeforeNode = currentNode.spacesBeforeNode || []; + let spacesBeforeDelimiter = currentNode.spacesBeforeDelimiter || []; + let spacesAfterDelimiter = currentNode.spacesAfterDelimiter || []; + + spacesBeforeNode.reverse().map(this._removeEmptyLines); + spacesBeforeDelimiter.reverse().map(this._removeEmptyLines); + spacesAfterDelimiter.reverse().map(this._removeEmptyLines); + + // Divide declarations from different groups with + // an empty line: + if (prevNode && currentNode.groupIndex > prevNode.groupIndex) { + let space = spacesBeforeNode[0]; + if (space && space.is('space') && + (space.syntax === 'sass' || + space.content.match(/\n/g) && + space.content.match(/\n/g).length < 2)) { + space.content = '\n' + space.content; } - }, - - _sortNodes(nodes) { - nodes.sort((a, b) => { - // If a's group index is higher than b's group index, in - // a sorted list a appears after b: - if (a.groupIndex !== b.groupIndex) - return a.groupIndex - b.groupIndex; - - // If a and b belong to leftovers and `sort-order-fallback` - // option is set to `abc`, sort properties alphabetically: - if (a.groupIndex === this._getLastGroupIndex() && - this._config['sort-order-fallback']) { - return this._sortLeftovers(a, b); - } - - // If a and b have the same group index, and a's property index - // is higher than b's property index, in a sorted list - // a appears after b: - if (a.propertyIndex !== b.propertyIndex) - return a.propertyIndex - b.propertyIndex; - - // If a and b have the same group index and the same property - // index, in a sorted list they appear in the same order - // they were in original array: - return a.i - b.i; + } + + for (let j = 0, nl = spacesAfterDelimiter.length; j < nl; j++) { + node.content.unshift(spacesAfterDelimiter[j]); + } + + if (currentNode.delim) { + node.content.unshift(currentNode.delim); + } else if (i !== nodesToSort.length - 1 && + (currentNode.node.is('declaration') || + currentNode.node.is('extend'))) { + let delimiter = gonzales.createNode({ + type: 'declarationDelimiter', + content: currentNode.node.syntax === 'sass' ? '\n' : ';' }); + node.content.unshift(delimiter); + } + + for (let j = 0, nl = spacesBeforeDelimiter.length; j < nl; j++) { + node.content.unshift(spacesBeforeDelimiter[j]); + } + + node.content.unshift(currentNode.node); + + for (let j = 0, nl = spacesBeforeNode.length; j < nl; j++) { + node.content.unshift(spacesBeforeNode[j]); + } + } + }, + + // Types of nodes that can be sorted. + _isAcceptableNode(node) { + const NODES = ['atruleb', 'atruler', 'atrules', + 'declaration', 'extend', 'include', + 'multilineComment', 'singlelineComment', 'space']; + return NODES.indexOf(node.type) !== -1; + }, + + // Spaces and comments. + _isSpaceOrComment(node) { + const SC = ['multilineComment', 'singlelineComment', 'space']; + return SC.indexOf(node.type) !== -1; + }, + + _processBlock(block) { + // Check every child node. + // If it is declaration (property-value pair, e.g. `color: tomato`), + // or @-rule (e.g. `@include nani`), + // combine it with spaces, semicolon and comments and move them from + // current node to a separate list for further sorting: + let nodesToSort = this._separateSortablesFromBlock(block); + this._sortNodes(nodesToSort); + this._insertSortablesToBlock(nodesToSort, block); + }, + + /** + * Remove empty lines in space node. + * @param {node} node Space node. + */ + _removeEmptyLines(node) { + node.content = node.content.replace(/\n[\s\t\n\r]*\n/, '\n'); + }, + + _separateSortablesFromBlock(block) { + let sortables = []; + let nodesToDelete = []; + + // Don't cache `block.length` since we may insert new nodes into it. + for (let i = 0; i < block.length; i++) { + let node = block.get(i); + if (!this._isAcceptableNode(node)) continue; + + // Save preceding spaces and comments, if there are any, + // and mark them for removing from parent node: + let spacesBeforeNode = + this._getSpacesAndCommentsBeforeNode(block, i); + if (!spacesBeforeNode) break; + + i += spacesBeforeNode.length; + node = block.get(i); + + let extendedNode = this._extendNode(block, i, spacesBeforeNode); + if (!extendedNode) continue; + + nodesToDelete = nodesToDelete.concat(extendedNode.nodesToDelete); + i = extendedNode.endIndex; + sortables.push(extendedNode); + } + + nodesToDelete.sort((a, b) => a - b); + for (let x = nodesToDelete.length - 1; x > -1; x--) + block.remove(nodesToDelete[x]); + + return sortables; + }, + + _sortLeftovers(a, b) { + let prefixes = ['-webkit-', '-moz-', '-ms-', '-o-', '']; + let prefixesRegExp = /^(-webkit-|-moz-|-ms-|-o-)(.*)$/; + + // Get property name (i.e. `color`, `-o-animation`): + a = a.node.first().first().content; + b = b.node.first().first().content; + + // Get prefix and unprefixed part. For example: + // ['-o-animation', '-o-', 'animation'] + // ['color', '', 'color'] + a = a.match(prefixesRegExp) || [a, '', a]; + b = b.match(prefixesRegExp) || [b, '', b]; + + if (a[2] !== b[2]) { + // If unprefixed parts are different (i.e. `border` and + // `color`), compare them: + return a[2] < b[2] ? -1 : 1; + } else { + // If unprefixed parts are identical (i.e. `border` in + // `-moz-border` and `-o-border`), compare prefixes. + // They should go in the same order they are set + // in `prefixes` array. + return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; } + }, + + _sortNodes(nodes) { + nodes.sort((a, b) => { + // If a's group index is higher than b's group index, in + // a sorted list a appears after b: + if (a.groupIndex !== b.groupIndex) + return a.groupIndex - b.groupIndex; + + // If a and b belong to leftovers and `sort-order-fallback` + // option is set to `abc`, sort properties alphabetically: + if (a.groupIndex === this._getLastGroupIndex() && + this._config['sort-order-fallback']) { + return this._sortLeftovers(a, b); + } + + // If a and b have the same group index, and a's property index + // is higher than b's property index, in a sorted list + // a appears after b: + if (a.propertyIndex !== b.propertyIndex) + return a.propertyIndex - b.propertyIndex; + + // If a and b have the same group index and the same property + // index, in a sorted list they appear in the same order + // they were in original array: + return a.i - b.i; + }); + } }; diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 1342ea97..88125d54 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -1,65 +1,65 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-after-colon', + name: 'space-after-colon', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('declaration', function(declaration) { - declaration.eachFor('propertyDelimiter', function(delimiter, i) { - if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) - return null; + ast.traverseByType('declaration', function(declaration) { + declaration.eachFor('propertyDelimiter', function(delimiter, i) { + if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) + return null; - // Remove any spaces after colon: - if (declaration.get(i + 1).is('space')) - declaration.remove(i + 1); - // If the value set in config is not empty, add spaces: - if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - declaration.insert(i + 1, space); - } + // Remove any spaces after colon: + if (declaration.get(i + 1).is('space')) + declaration.remove(i + 1); + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + declaration.insert(i + 1, space); + } - return null; - }); - }); - }, + return null; + }); + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('declaration', function(declaration) { - declaration.eachFor('propertyDelimiter', function(delimiter, i) { - if (declaration.get(i + 1).is('space')) { - detected.push(declaration.get(i + 1).content); - } else { - detected.push(''); - } - }); - }); + ast.traverseByType('declaration', function(declaration) { + declaration.eachFor('propertyDelimiter', function(delimiter, i) { + if (declaration.get(i + 1).is('space')) { + detected.push(declaration.get(i + 1).content); + } else { + detected.push(''); + } + }); + }); - return detected; - } + return detected; + } }; diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index b4cf8332..a57def74 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -1,64 +1,63 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-after-combinator', - - runBefore: 'block-indent', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, - - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; - - // TODO(tonyganch): Can this be replaced with one `traverse`? - ast.traverseByType('selector', function(selector) { - selector.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - simpleSelector.get(i + 1).content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - simpleSelector.insert(i + 1, space); - } - }); + name: 'space-after-combinator', + + runBefore: 'block-indent', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, + + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; + + // TODO(tonyganch): Can this be replaced with one `traverse`? + ast.traverseByType('selector', function(selector) { + selector.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + simpleSelector.get(i + 1).content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value }); + simpleSelector.insert(i + 1, space); + } }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverseByType('selector', function(selector) { - selector.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - detected.push(simpleSelector.get(i + 1).content); - } else { - detected.push(''); - } - }); - }); + }); + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; + + ast.traverseByType('selector', function(selector) { + selector.forEach('simpleSelector', function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i + 1).is('space')) { + detected.push(simpleSelector.get(i + 1).content); + } else { + detected.push(''); + } }); + }); + }); - return detected; - } + return detected; + } }; - diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index 91279433..de7571f6 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -1,60 +1,60 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-after-opening-brace', - - runBefore: 'block-indent', - - syntax: ['css', 'less', 'scss'], - - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, - - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; - - ast.traverse(function(node) { - // If found block node stop at the next one for space check - if (!node.is('block') && !node.is('atrulers')) return; - - if (node.first() && - node.first().is('space')) { - node.first().content = value; - } else if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - node.insert(0, space); - } + name: 'space-after-opening-brace', + + runBefore: 'block-indent', + + syntax: ['css', 'less', 'scss'], + + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, + + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; + + ast.traverse(function(node) { + // If found block node stop at the next one for space check + if (!node.is('block') && !node.is('atrulers')) return; + + if (node.first() && + node.first().is('space')) { + node.first().content = value; + } else if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverse(function(node) { - if (!node.is('block') && !node.is('atrulers')) return; - - if (node.first().is('space')) { - detected.push(node.first().content); - } else { - detected.push(''); - } - }); - - return detected; - } + node.insert(0, space); + } + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; + + ast.traverse(function(node) { + if (!node.is('block') && !node.is('atrulers')) return; + + if (node.first().is('space')) { + detected.push(node.first().content); + } else { + detected.push(''); + } + }); + + return detected; + } }; diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index e5bacd76..089b58a7 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -1,66 +1,66 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-after-selector-delimiter', + name: 'space-after-selector-delimiter', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delimiter, i) { - var nextNode = selector.get(i + 1); + ast.traverseByType('selector', function(selector) { + selector.forEach('delimiter', function(delimiter, i) { + var nextNode = selector.get(i + 1); - if (nextNode.is('space')) { - nextNode.content = value; - } else if (nextNode.first().is('space')) { - nextNode.first().content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - nextNode.insert(0, space); - } - }); - }); - }, + if (nextNode.is('space')) { + nextNode.content = value; + } else if (nextNode.first().is('space')) { + nextNode.first().content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + nextNode.insert(0, space); + } + }); + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delimiter, i) { - var nextNode = selector.get(i + 1); + ast.traverseByType('selector', function(selector) { + selector.forEach('delimiter', function(delimiter, i) { + var nextNode = selector.get(i + 1); - if (nextNode && nextNode.is('space')) { - detected.push(nextNode.content); - } else if (nextNode.first() && nextNode.first().is('space')) { - detected.push(nextNode.first().content); - } else { - detected.push(''); - } - }); - }); + if (nextNode && nextNode.is('space')) { + detected.push(nextNode.content); + } else if (nextNode.first() && nextNode.first().is('space')) { + detected.push(nextNode.first().content); + } else { + detected.push(''); + } + }); + }); - return detected; - } + return detected; + } }; diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index 4a41f54d..e0b6f507 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -1,103 +1,102 @@ var gonzales = require('../gonzales'); module.exports = (function() { - var valueFromSettings; - var blockIndent; + var valueFromSettings; + var blockIndent; - function getLastWhitespaceNode(node) { - var lastNode = node.last(); + function getLastWhitespaceNode(node) { + var lastNode = node.last(); - if (!lastNode || !lastNode.content) return null; + if (!lastNode || !lastNode.content) return null; - if (lastNode.is('block')) return null; - if (lastNode.is('space')) return lastNode; + if (lastNode.is('block')) return null; + if (lastNode.is('space')) return lastNode; - return getLastWhitespaceNode(lastNode); - } + return getLastWhitespaceNode(lastNode); + } - function processBlock(x, level) { - level = level || 0; - - x.forEach(function(node) { - if (!node.is('block') && - !node.is('atrulers')) return processBlock(node, level); - - level++; - - var value = valueFromSettings; - if (value.indexOf('\n') > -1) { - // TODO: Check that it works for '' block indent value - if (blockIndent) { - value += new Array(level).join(blockIndent); - } - } - - // If found block node stop at the next one for space check - // For the pre-block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node); - - // If it's spaces, modify this node - // If it's something different from spaces, add a space node - // to the end - if (whitespaceNode) { - whitespaceNode.content = value; - } else if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - node.content.push(space); - } - - processBlock(node, level); - }); - } + function processBlock(x, level) { + level = level || 0; + x.forEach(function(node) { + if (!node.is('block') && + !node.is('atrulers')) return processBlock(node, level); - return { - name: 'space-before-closing-brace', - - runBefore: 'tab-size', - - syntax: ['css', 'less', 'scss'], - - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, - - /** - * Processes tree node. - * @param {node} ast - * @param {Object} config - */ - process: function(ast, config) { - valueFromSettings = this.value; - blockIndent = config['block-indent']; - - processBlock(ast); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverseByTypes(['block', 'atrulers'], function(node) { - // For the block node, find its last (the deepest) child - var whitespaceNode = getLastWhitespaceNode(node); - if (whitespaceNode) { - detected.push(whitespaceNode.content); - } else { - detected.push(''); - } - }); - - return detected; + level++; + + var value = valueFromSettings; + if (value.indexOf('\n') > -1) { + // TODO: Check that it works for '' block indent value + if (blockIndent) { + value += new Array(level).join(blockIndent); } - }; -})(); + } + + // If found block node stop at the next one for space check + // For the pre-block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); + + // If it's spaces, modify this node + // If it's something different from spaces, add a space node + // to the end + if (whitespaceNode) { + whitespaceNode.content = value; + } else if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + node.content.push(space); + } + + processBlock(node, level); + }); + } + + + return { + name: 'space-before-closing-brace', + + runBefore: 'tab-size', + + syntax: ['css', 'less', 'scss'], + + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, + + /** + * Processes tree node. + * @param {node} ast + * @param {Object} config + */ + process: function(ast, config) { + valueFromSettings = this.value; + blockIndent = config['block-indent']; + + processBlock(ast); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; + + ast.traverseByTypes(['block', 'atrulers'], function(node) { + // For the block node, find its last (the deepest) child + var whitespaceNode = getLastWhitespaceNode(node); + if (whitespaceNode) { + detected.push(whitespaceNode.content); + } else { + detected.push(''); + } + }); + return detected; + } + }; +})(); diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 9b8bc2b1..0df08bdd 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -1,65 +1,65 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-before-colon', + name: 'space-before-colon', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('declaration', function(declaration) { - declaration.forEach('propertyDelimiter', function(delimiter, i) { - if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) - return; + ast.traverseByType('declaration', function(declaration) { + declaration.forEach('propertyDelimiter', function(delimiter, i) { + if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) + return; - // Remove any spaces before colon: - if (declaration.get(i - 1).is('space')) { - declaration.remove(--i); - } + // Remove any spaces before colon: + if (declaration.get(i - 1).is('space')) { + declaration.remove(--i); + } - // If the value set in config is not empty, add spaces: - if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - declaration.insert(i, space); - } - }); - }); - }, + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + declaration.insert(i, space); + } + }); + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('declaration', function(declaration) { - declaration.forEach('propertyDelimiter', function(delimiter, i) { - if (declaration.get(i - 1).is('space')) { - detected.push(declaration.get(i - 1).content); - } else { - detected.push(''); - } - }); - }); + ast.traverseByType('declaration', function(declaration) { + declaration.forEach('propertyDelimiter', function(delimiter, i) { + if (declaration.get(i - 1).is('space')) { + detected.push(declaration.get(i - 1).content); + } else { + detected.push(''); + } + }); + }); - return detected; - } + return detected; + } }; diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 4caedebe..d0cf9d64 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -1,71 +1,70 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-before-combinator', + name: 'space-before-combinator', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('selector', function(selector) { - selector.forEach(function(simpleSelector) { - var notFirst = false; + ast.traverseByType('selector', function(selector) { + selector.forEach(function(simpleSelector) { + var notFirst = false; - simpleSelector.forEach(function(n, i) { - if (!n.is('space') && !n.is('combinator')) notFirst = true; + simpleSelector.forEach(function(n, i) { + if (!n.is('space') && !n.is('combinator')) notFirst = true; - // If combinator is the first thing in selector, - // do not add extra spaces: - if (!n.is('combinator') || !notFirst) return; + // If combinator is the first thing in selector, + // do not add extra spaces: + if (!n.is('combinator') || !notFirst) return; - if (simpleSelector.get(i - 1).is('space')) { - simpleSelector.get(i - 1).content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - simpleSelector.insert(i, space); - } - }); + if (simpleSelector.get(i - 1).is('space')) { + simpleSelector.get(i - 1).content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value }); + simpleSelector.insert(i, space); + } }); - }, + }); + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach(function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i - 1).is('space')) { - detected.push(simpleSelector.get(i - 1).content); - } else { - detected.push(''); - } - }); - }); + ast.traverseByType('selector', function(selector) { + selector.forEach(function(simpleSelector) { + simpleSelector.forEach('combinator', function(combinator, i) { + if (simpleSelector.get(i - 1).is('space')) { + detected.push(simpleSelector.get(i - 1).content); + } else { + detected.push(''); + } }); + }); + }); - return detected; - } + return detected; + } }; - diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index 1fb123db..5a9bc19e 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -1,93 +1,91 @@ var gonzales = require('../gonzales'); module.exports = (function() { - /** - * Gets the last (the deepest) whitespace node. - * - * @param {node} node - * @returns {node|undefined} If no whitespace node is found, returns - * `undefined` - */ - function getLastWhitespaceNode(node) { - if (typeof node !== 'object') return; - if (node.is('space')) return node; + /** + * Gets the last (the deepest) whitespace node. + * + * @param {node} node + * @returns {node|undefined} If no whitespace node is found, returns + * `undefined` + */ + function getLastWhitespaceNode(node) { + if (typeof node !== 'object') return; + if (node.is('space')) return node; - return getLastWhitespaceNode(node.last()); - } + return getLastWhitespaceNode(node.last()); + } - return { - name: 'space-before-opening-brace', + return { + name: 'space-before-opening-brace', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'scss'], + syntax: ['css', 'less', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; - - // If found block node stop at the next one for space check. - ast.traverseByTypes(['block', 'atrulers'], - function(block, i, parent) { - // For the pre-block node, find its last (the deepest) child: - // TODO: Exclude nodes with braces (for example, arguments) - var previousNode = parent.get(i - 1); - var whitespaceNode = getLastWhitespaceNode(previousNode); + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - // If it's spaces, modify this node. - // If it's something different from spaces, add a space node to - // the end: - if (whitespaceNode) { - whitespaceNode.content = value; - } else if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - if (previousNode && previousNode.is('atrulerq')) { - previousNode.content.push(space); - } else { - parent.insert(i, space); - } - } - }); - }, + // If found block node stop at the next one for space check. + ast.traverseByTypes(['block', 'atrulers'], function(block, i, parent) { + // For the pre-block node, find its last (the deepest) child: + // TODO: Exclude nodes with braces (for example, arguments) + var previousNode = parent.get(i - 1); + var whitespaceNode = getLastWhitespaceNode(previousNode); - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - var detected = []; + // If it's spaces, modify this node. + // If it's something different from spaces, add a space node to + // the end: + if (whitespaceNode) { + whitespaceNode.content = value; + } else if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + if (previousNode && previousNode.is('atrulerq')) { + previousNode.content.push(space); + } else { + parent.insert(i, space); + } + } + }); + }, - ast.traverseByTypes(['block', 'atrulers'], - function(block, i, parent) { - // For the pre-block node, find its last (the deepest) child: - // TODO: Exclude nodes with braces (for example, arguments) - var previousNode = parent.get(i - 1); - var whitespaceNode = getLastWhitespaceNode(previousNode); + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + var detected = []; - // If it's spaces, modify this node. - // If it's something different from spaces, add a space node to - // the end: - if (whitespaceNode) { - detected.push(whitespaceNode.content); - } else { - detected.push(''); - } - }); + ast.traverseByTypes(['block', 'atrulers'], function(block, i, parent) { + // For the pre-block node, find its last (the deepest) child: + // TODO: Exclude nodes with braces (for example, arguments) + var previousNode = parent.get(i - 1); + var whitespaceNode = getLastWhitespaceNode(previousNode); - return detected; + // If it's spaces, modify this node. + // If it's something different from spaces, add a space node to + // the end: + if (whitespaceNode) { + detected.push(whitespaceNode.content); + } else { + detected.push(''); } - }; + }); + + return detected; + } + }; })(); diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 24f9d0ce..8c5f7cf7 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -1,60 +1,60 @@ var gonzales = require('../gonzales'); module.exports = { - name: 'space-before-selector-delimiter', - - runBefore: 'block-indent', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, - - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; - - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delim, i) { - var previousNode = selector.get(i - 1); - if (previousNode.last().is('space')) { - previousNode.last().content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - previousNode.content.push(space); - } - }); - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delim, i) { - var previousNode = selector.get(i - 1); - if (previousNode.last().is('space')) { - detected.push(previousNode.last().content); - } else { - detected.push(''); - } - }); - }); - - return detected; - } + name: 'space-before-selector-delimiter', + + runBefore: 'block-indent', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, + + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; + + ast.traverseByType('selector', function(selector) { + selector.forEach('delimiter', function(delim, i) { + var previousNode = selector.get(i - 1); + if (previousNode.last().is('space')) { + previousNode.last().content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + previousNode.content.push(space); + } + }); + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; + + ast.traverseByType('selector', function(selector) { + selector.forEach('delimiter', function(delim, i) { + var previousNode = selector.get(i - 1); + if (previousNode.last().is('space')) { + detected.push(previousNode.last().content); + } else { + detected.push(''); + } + }); + }); + + return detected; + } }; diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index a3222ae0..8aa817b7 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -1,96 +1,95 @@ var gonzales = require('../gonzales'); module.exports = (function() { - function getDeclarationEnd(node, i) { - for (; i < node.length; i++) { - if (!node.get(i + 1) || typeof node.get(i + 1) === 'string') { - return 0; - } else if (node.get(i + 1).is('space')) { - if (node.get(i + 1).content.indexOf('\n') > -1) { - if (node.get(i + 2) && node.get(i + 2).is('declaration')) { - return i; - } else { - return 0; - } - } else if (node.get(i + 2) && - node.get(i + 2).is('multilineComment')) { - if (node.get(i + 3) && node.get(i + 3).is('declaration')) { - return i + 2; - } else if (node.get(i + 3) && node.get(i + 3).is('space')) { - if (node.get(i + 4) && - node.get(i + 4).is('declaration')) { - return i + 2; - } else { - return 0; - } - } else { - return 0; - } - } else if (node.get(i + 2) && - node.get(i + 2).is('declaration')) { - return i; - } - } else if (node.get(i + 1).is('declaration')) { - return i; - } else if (node.get(i + 1).is('multilineComment')) { - if (node.get(i + 2) && node.get(i + 2).is('declaration')) { - return i + 1; - } else if (node.get(i + 2) && node.get(i + 2).is('space')) { - if (node.get(i + 3) && node.get(i + 3).is('declaration')) { - return i + 1; - } - } else { - return 0; - } + function getDeclarationEnd(node, i) { + for (; i < node.length; i++) { + if (!node.get(i + 1) || typeof node.get(i + 1) === 'string') { + return 0; + } else if (node.get(i + 1).is('space')) { + if (node.get(i + 1).content.indexOf('\n') > -1) { + if (node.get(i + 2) && node.get(i + 2).is('declaration')) { + return i; + } else { + return 0; + } + } else if (node.get(i + 2) && + node.get(i + 2).is('multilineComment')) { + if (node.get(i + 3) && node.get(i + 3).is('declaration')) { + return i + 2; + } else if (node.get(i + 3) && node.get(i + 3).is('space')) { + if (node.get(i + 4) && + node.get(i + 4).is('declaration')) { + return i + 2; } else { - return 0; + return 0; } + } else { + return 0; + } + } else if (node.get(i + 2) && + node.get(i + 2).is('declaration')) { + return i; } + } else if (node.get(i + 1).is('declaration')) { + return i; + } else if (node.get(i + 1).is('multilineComment')) { + if (node.get(i + 2) && node.get(i + 2).is('declaration')) { + return i + 1; + } else if (node.get(i + 2) && node.get(i + 2).is('space')) { + if (node.get(i + 3) && node.get(i + 3).is('declaration')) { + return i + 1; + } + } else { + return 0; + } + } else { + return 0; + } } + } - return { - name: 'space-between-declarations', + return { + name: 'space-between-declarations', - runBefore: 'block-indent', + runBefore: 'block-indent', - syntax: ['css', 'less', 'scss'], + syntax: ['css', 'less', 'scss'], - accepts: { - number: true, - string: /^[ \t\n]*$/ - }, + accepts: { + number: true, + string: /^[ \t\n]*$/ + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('declarationDelimiter', - function(delimiter, i, parent) { - // Grom user's point of view "declaration" includes semicolons - // and comments placed on the same line. - // So group those things together: - var declarationEnd = getDeclarationEnd(parent, i); - if (!declarationEnd) { - return; - } else { - i = declarationEnd; - } + ast.traverseByType('declarationDelimiter', (delimiter, i, parent) => { + // Grom user's point of view "declaration" includes semicolons + // and comments placed on the same line. + // So group those things together: + var declarationEnd = getDeclarationEnd(parent, i); + if (!declarationEnd) { + return; + } else { + i = declarationEnd; + } - var nextNode = parent.get(i + 1); - if (nextNode.is('space')) { - nextNode.content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - parent.insert(i + 1, space); - } - }); + var nextNode = parent.get(i + 1); + if (nextNode.is('space')) { + nextNode.content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + parent.insert(i + 1, space); } - }; + }); + } + }; })(); diff --git a/src/options/strip-spaces.js b/src/options/strip-spaces.js index b6d0bdcc..ebc647f3 100644 --- a/src/options/strip-spaces.js +++ b/src/options/strip-spaces.js @@ -1,64 +1,64 @@ module.exports = (function() { - /** - * Trim trailing spaces on each line. - * @private - * @param {String} string Spaceful string - * @returns {String} - */ - function trim(string) { - return string.replace(/[ \t]+\n/g, '\n'); - } + /** + * Trim trailing spaces on each line. + * @private + * @param {String} string Spaceful string + * @returns {String} + */ + function trim(string) { + return string.replace(/[ \t]+\n/g, '\n'); + } - return { - name: 'strip-spaces', + return { + name: 'strip-spaces', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - boolean: [true] - }, + accepts: { + boolean: [true] + }, - /** - * Processes tree node. - * @param {node} ast - */ - process: function(ast) { - var lastChild = ast.last(); - if (lastChild.is('space')) { - lastChild.content = trim(lastChild.content) - .replace(/[ \t]+$/, '') - .replace(/[\n]+/g, '\n'); - } + /** + * Processes tree node. + * @param {node} ast + */ + process: function(ast) { + var lastChild = ast.last(); + if (lastChild.is('space')) { + lastChild.content = trim(lastChild.content) + .replace(/[ \t]+$/, '') + .replace(/[\n]+/g, '\n'); + } - ast.traverseByType('space', function(space) { - space.content = trim(space.content); - }); - }, + ast.traverseByType('space', function(space) { + space.content = trim(space.content); + }); + }, - detectDefault: true, + detectDefault: true, - /** - * Detects the value of an option at the tree node. - * This option is treated as `true` by default, but any trailing - * space would invalidate it. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * This option is treated as `true` by default, but any trailing + * space would invalidate it. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - var lastChild = ast.last(); - if (lastChild.is('space') && - lastChild.content !== '\n' && - lastChild.content.match(/^[ \n\t]+$/)) { - detected.push(false); - } + var lastChild = ast.last(); + if (lastChild.is('space') && + lastChild.content !== '\n' && + lastChild.content.match(/^[ \n\t]+$/)) { + detected.push(false); + } - ast.traverseByType('space', function(space) { - if (space.content.match(/[ \t]\n/)) detected.push(false); - }); + ast.traverseByType('space', function(space) { + if (space.content.match(/[ \t]\n/)) detected.push(false); + }); - return detected; - } - }; + return detected; + } + }; })(); diff --git a/src/options/tab-size.js b/src/options/tab-size.js index ce2dbfcc..e5b9e77d 100644 --- a/src/options/tab-size.js +++ b/src/options/tab-size.js @@ -1,24 +1,24 @@ module.exports = { - name: 'tab-size', + name: 'tab-size', - runBefore: 'vendor-prefix-align', + runBefore: 'vendor-prefix-align', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - number: true - }, + accepts: { + number: true + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - let value = this.value; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + let value = this.value; - ast.traverseByType('space', function(space) { - space.content = space.content.replace(/\t/, value); - }); - } + ast.traverseByType('space', function(space) { + space.content = space.content.replace(/\t/, value); + }); + } }; diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index 45b08698..a69a5013 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -1,75 +1,76 @@ module.exports = { - name: 'unitless-zero', + name: 'unitless-zero', - syntax: ['css', 'less', 'sass', 'scss'], + syntax: ['css', 'less', 'sass', 'scss'], - accepts: { - boolean: [true] - }, + accepts: { + boolean: [true] + }, - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; + /** + * Processes tree node. + * + * @param {node} ast + */ + process: function(ast) { + var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - ast.traverseByTypes(['value', 'parentheses'], function(node) { - node.forEach(function(value) { - if (typeof value === 'string') return; + ast.traverseByTypes(['value', 'parentheses'], function(node) { + node.forEach(function(value) { + if (typeof value === 'string') return; - if (value.is('dimension')) { - var unit = value.first('ident').content; - if (value.first('number').content[0] === '0' && - UNITS.indexOf(unit) !== -1) { - value.remove(1); - } - } else if (value.is('percentage')) { - var number = value.first('number').content; - if (number[0] === '0') { - value.type = 'number'; - value.content = number; - } - } - }); - }); - }, + if (value.is('dimension')) { + var unit = value.first('ident').content; + if (value.first('number').content[0] === '0' && + UNITS.indexOf(unit) !== -1) { + value.remove(1); + } + } else if (value.is('percentage')) { + var number = value.first('number').content; + if (number[0] === '0') { + value.type = 'number'; + value.content = number; + } + } + }); + }); + }, - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; + /** + * Detects the value of an option at the tree node. + * + * @param {node} ast + */ + detect: function(ast) { + let detected = []; - ast.traverse(function(node, i, parent) { - // If we see a zero with unit and it is not degree, - // then we don’t have an option - if (node.is('percentage') && - node.first('number').content[1] === '0') { - detected.push(false); - return; - } + ast.traverse(function(node, params) { + // If we see a zero with unit and it is not degree, + // then we don’t have an option + if (node.is('percentage') && + node.first('number').content[1] === '0') { + detected.push(false); + return; + } - if (node.is('dimension') && - node.first('number').content[0] === '0' && - node.first('ident').content !== 'deg') { - detected.push(false); - return; - } + if (node.is('dimension') && + node.first('number').content[0] === '0' && + node.first('ident').content !== 'deg') { + detected.push(false); + return; + } - // If we see a zero and previous node is not percentage - // or dimension, then we have an option - if (node.is('number') && - node.content[0] === '0' && - !parent.is('percentage') && - !parent.is('dimension')) { - detected.push(true); - } - }); + // If we see a zero and previous node is not percentage + // or dimension, then we have an option + let parent = params.parent; + if (node.is('number') && + node.content[0] === '0' && + !parent.is('percentage') && + !parent.is('dimension')) { + detected.push(true); + } + }); - return detected; - } + return detected; + } }; diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index d2c77d03..31914712 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -1,472 +1,472 @@ var gonzales = require('../gonzales'); module.exports = (function() { - // Vendor prefixes list: - var PREFIXES = [ - 'webkit', - 'khtml', - 'moz', - 'ms', - 'o' - ]; + // Vendor prefixes list: + var PREFIXES = [ + 'webkit', + 'khtml', + 'moz', + 'ms', + 'o' + ]; + + var oneline; + + /** + * Makes namespace from property name. + * + * @param {String} propertyName + * @returns {String|undefined} + */ + function makeNamespace(propertyName) { + var info = getPrefixInfo(propertyName); + return info && info.baseName; + } + + /** + * Creates object which contains info about vendor prefix used + * in propertyName. + * + * @param {String} propertyName property name + * @param {String} [namespace=''] namespace name + * @param {Number} [extraSymbols=0] extra symbols count + * @returns {Object|undefined} + */ + function getPrefixInfo(propertyName, namespace, extraSymbols) { + var baseName = propertyName; + var prefixLength = 0; + + namespace = namespace || ''; + extraSymbols = extraSymbols || 0; + + if (!propertyName) return; + + PREFIXES.some(function(prefix) { + prefix = '-' + prefix + '-'; + if (propertyName.indexOf(prefix) !== 0) return; + + baseName = baseName.substr(prefix.length); + prefixLength = prefix.length; + + return true; + }); - var oneline; + return { + id: namespace + baseName, + baseName: baseName, + prefixLength: prefixLength, + extra: extraSymbols + }; + } + + /** + * Returns extra indent for item in arguments + * + * @param {Array} nodes nodes to process + * @returns {Number|undefined} + */ + function extraIndent(nodes) { + if (!nodes || !nodes.length) return; + + var node; + var crPos; + var tabPos; + var result = 0; + + for (var i = nodes.length; i--;) { + node = nodes[i]; + + if (!node.content) { + crPos = -1; + } else { + crPos = node.content.lastIndexOf('\n'); + tabPos = node.content.lastIndexOf('\t'); + if (tabPos > crPos) crPos = tabPos; + } + + if (crPos !== -1) + oneline = false; + + if (node.is('space')) { + result += node.content.length - crPos - 1; + if (crPos !== -1) + break; + } + if (node.is('multilineComment')) { + if (crPos === -1) { + // Comment symbols length + let offset = 4; + result += node.content.length + offset; + } else { + // Only last comment symbols length - 1 (not count \n) + let offset = crPos - 1; + result += node.content.length - offset; + break; + } + } + } - /** - * Makes namespace from property name. - * - * @param {String} propertyName - * @returns {String|undefined} - */ - function makeNamespace(propertyName) { - var info = getPrefixInfo(propertyName); - return info && info.baseName; + return result; + } + + /** + * Wrapper for extra indent function for `property` node. + * + * @param {Array} nodes all nodes + * @param {Number} i position in nodes array + */ + function extraIndentProperty(nodes, i) { + var subset = []; + while (i--) { + if (!nodes.get(i) || nodes.get(i).is('declarationDelimiter')) + break; + subset.unshift(nodes.get(i)); + } + return extraIndent(subset); + } + + /** + * Wrapper for extra indent function for val-node. + * + * @param {Array} nodes all nodes + * @param {Number} i position in nodes array + */ + function extraIndentVal(nodes, i) { + var subset = []; + var declaration = nodes.get(i); + if (!declaration.is('declaration')) return; + + for (var x = declaration.length; x--;) { + if (!declaration.get(x).is('value')) continue; + + x--; + + while (!declaration.get(x).is('propertyDelimiter')) { + subset.push(declaration.get(x)); + x--; + } + + break; } + return extraIndent(subset); + } + + /** + * Walks across nodes, and call payload for every node that pass + * selector check. + * + * @param {Object} args arguments in form of: + * { + * node: {object} current node, + * selector: {function} propertyName selector + * payload: {function} work to do with gathered info + * namespaceSelector: {function} selector for namespace + * getExtraSymbols: {Number} extra symbols count + * } + */ + function walk(args) { + args.node.forEach(function(item, i) { + var name = args.selector(item); + var namespace = args.namespaceSelector && + makeNamespace(args.namespaceSelector(item)); + var extraSymbols = args.getExtraSymbols(args.node, i); + + var info = name && getPrefixInfo(name, namespace, extraSymbols); + if (!info) return; + args.payload(info, i); + }); + } + + /** + * Returns property name. + * e.g. + * for: 'color: #fff' + * returns string: 'color' + * + * @param {node} node + * @returns {String|undefined} + */ + function getPropertyName(node) { + if (!node.is('declaration')) return; + // TODO: Check that it's not a variable + return node.get(0).get(0).content; + } + + /** + * Returns property value name. + * e.g. + * for: '-webkit-transition: -webkit-transform 150ms linear' + * returns string: '-webkit-transform', and + * for: 'background: -webkit-linear-gradient(...)' + * returns string: '-webkit-linear-gradient' + * + * @param {node} node + * @returns {String|undefined} + */ + function getValName(node) { + if (!node.is('declaration')) return; + + var value = node.first('value'); + if (value.get(0).is('ident')) return value.get(0).content; + if (value.get(0).is('function')) return value.get(0).get(0).content; + } + + /** + * Updates dict which contains info about items align. + * + * @param {Object} info, + * @param {Object} dict, + */ + function updateDict(info, dict) { + if (info.prefixLength === 0 && info.extra === 0) return; + + var indent = dict[info.id] || {prefixLength: 0, extra: 0}; + + let indentLength = indent.prefixLength + indent.extra; + let infoLength = info.prefixLength + info.extra; + if (indentLength > infoLength) { + dict[info.id] = indent; + } else { + dict[info.id] = { + prefixLength: info.prefixLength, + extra: info.extra + }; + } + } + + /** + * Returns string with correct number of spaces for info.baseName property. + * + * @param {Object} info, + * @param {Object} dict, + * @param {String} whitespaceNode + * @returns {String} + */ + function updateIndent(info, dict, whitespaceNode) { + var item = dict[info.id]; + if (!item) + return whitespaceNode; + + var crPos = whitespaceNode.lastIndexOf('\n'); + var tabPos = whitespaceNode.lastIndexOf('\t'); + if (tabPos > crPos) crPos = tabPos; + + var firstPart = whitespaceNode.substr(0, crPos + 1); + var extraIndent = new Array( + (item.prefixLength - info.prefixLength) + + (item.extra - info.extra) + + whitespaceNode.length - firstPart.length + + 1).join(' '); + + return firstPart.concat(extraIndent); + } + + return { + name: 'vendor-prefix-align', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { + boolean: [true] + }, /** - * Creates object which contains info about vendor prefix used - * in propertyName. + * Processes tree node. * - * @param {String} propertyName property name - * @param {String} [namespace=''] namespace name - * @param {Number} [extraSymbols=0] extra symbols count - * @returns {Object|undefined} + * @param {node} ast */ - function getPrefixInfo(propertyName, namespace, extraSymbols) { - var baseName = propertyName; - var prefixLength = 0; - - namespace = namespace || ''; - extraSymbols = extraSymbols || 0; + process: function(ast) { + ast.traverseByType('block', function(node) { + oneline = true; + + var dict = {}; + + // Gathering Info + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info) { + updateDict(info, dict); + } + }); - if (!propertyName) return; + walk({ + node: node, + selector: getValName, + namespaceSelector: getPropertyName, + getExtraSymbols: extraIndentVal, + payload: function(info) { + updateDict(info, dict); + } + }); - PREFIXES.some(function(prefix) { - prefix = '-' + prefix + '-'; - if (propertyName.indexOf(prefix) !== 0) return; + if (oneline && ast.syntax !== 'sass') return; + + // Update nodes + walk({ + node: node, + selector: getValName, + namespaceSelector: getPropertyName, + getExtraSymbols: extraIndentVal, + payload: function(info, i) { + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; + } - baseName = baseName.substr(prefix.length); - prefixLength = prefix.length; + let prevNode = node.get(i).get(x - 1); + if (!prevNode.is('space')) { + var space = gonzales.createNode({ + type: 'space', + content: '' + }); + node.get(i).insert(x, space); + ++x; + } - return true; + let content = node.get(i).get(x - 1).content; + let updatedIndent = updateIndent(info, dict, content); + node.get(i).get(x - 1).content = updatedIndent; + } }); - return { - id: namespace + baseName, - baseName: baseName, - prefixLength: prefixLength, - extra: extraSymbols - }; - } + if (ast.syntax === 'sass') return; + + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info, i) { + // `node.get(i - 1)` can be either space or comment: + var whitespaceNode = node.get(i - 1); + if (!whitespaceNode) return; + // If it's a comment, insert an empty space node: + if (!whitespaceNode.is('space')) { + whitespaceNode = gonzales.createNode({ + type: 'space', + content: '' + }); + node.insert(i - 1, whitespaceNode); + } + let content = whitespaceNode.content; + let updatedContent = updateIndent(info, dict, content); + whitespaceNode.content = updatedContent; + } + }); + }); + }, /** - * Returns extra indent for item in arguments + * Detects the value of an option at the tree node. * - * @param {Array} nodes nodes to process - * @returns {Number|undefined} + * @param {node} ast */ - function extraIndent(nodes) { - if (!nodes || !nodes.length) return; + detect: function(ast) { + let detected = []; - var node; - var crPos; - var tabPos; - var result = 0; - - for (var i = nodes.length; i--;) { - node = nodes[i]; + ast.traverseByType('block', function(node) { + var result = { + true: 0, + false: 0 + }; - if (!node.content) { - crPos = -1; + var maybePrefix = false; + var prevPrefixLength = false; + var prevProp; + var prevSum; + var partialResult = null; + + var getResult = function(options) { + let {node, sum, info, i} = options; + var prop = info.baseName; + + // If this is the last item in a row and we have a result, + // then catch it + if (prop !== prevProp && partialResult !== null) { + if (partialResult) { + result.true++; } else { - crPos = node.content.lastIndexOf('\n'); - tabPos = node.content.lastIndexOf('\t'); - if (tabPos > crPos) crPos = tabPos; - } - - if (crPos !== -1) - oneline = false; - - if (node.is('space')) { - result += node.content.length - crPos - 1; - if (crPos !== -1) - break; + result.false++; } - if (node.is('multilineComment')) { - if (crPos === -1) { - // Comment symbols length - let offset = 4; - result += node.content.length + offset; - } else { - // Only last comment symbols length - 1 (not count \n) - let offset = crPos - 1; - result += node.content.length - offset; - break; - } + partialResult = null; + } + + if (prop === prevProp && + info.prefixLength !== prevPrefixLength) { + maybePrefix = true; + } else { + maybePrefix = false; + } + + if (maybePrefix && partialResult !== false) { + // If there is prefixed prop, check if the prefixes are + // aligned, but only if we hadn't already catched + // that it is false + if (sum === prevSum) { + partialResult = true; + } else { + partialResult = false; } - } - - return result; - } - - /** - * Wrapper for extra indent function for `property` node. - * - * @param {Array} nodes all nodes - * @param {Number} i position in nodes array - */ - function extraIndentProperty(nodes, i) { - var subset = []; - while (i--) { - if (!nodes.get(i) || nodes.get(i).is('declarationDelimiter')) - break; - subset.unshift(nodes.get(i)); - } - return extraIndent(subset); - } - - /** - * Wrapper for extra indent function for val-node. - * - * @param {Array} nodes all nodes - * @param {Number} i position in nodes array - */ - function extraIndentVal(nodes, i) { - var subset = []; - var declaration = nodes.get(i); - if (!declaration.is('declaration')) return; - - for (var x = declaration.length; x--;) { - if (!declaration.get(x).is('value')) continue; + } - x--; - - while (!declaration.get(x).is('propertyDelimiter')) { - subset.push(declaration.get(x)); - x--; + if (node.length === i + 3 && partialResult !== null) { + // If we're at the last property and have a result, + // catch it + if (partialResult) { + result.true++; + } else { + result.false++; } + } - break; - } - return extraIndent(subset); - } + prevPrefixLength = info.prefixLength; + prevProp = prop; + prevSum = sum; + }; - /** - * Walks across nodes, and call payload for every node that pass - * selector check. - * - * @param {Object} args arguments in form of: - * { - * node: {object} current node, - * selector: {function} propertyName selector - * payload: {function} work to do with gathered info - * namespaceSelector: {function} selector for namespace - * getExtraSymbols: {Number} extra symbols count - * } - */ - function walk(args) { - args.node.forEach(function(item, i) { - var name = args.selector(item); - var namespace = args.namespaceSelector && - makeNamespace(args.namespaceSelector(item)); - var extraSymbols = args.getExtraSymbols(args.node, i); - - var info = name && getPrefixInfo(name, namespace, extraSymbols); - if (!info) return; - args.payload(info, i); + // Gathering Info + walk({ + node: node, + selector: getPropertyName, + getExtraSymbols: extraIndentProperty, + payload: function(info, i) { + if (node.get(i - 1) && node.get(i - 1).content) { + let nodeLength = node.get(i - 1).content + .replace(/^[ \t]*\n+/, '').length; + var sum = nodeLength + info.prefixLength; + getResult({node: node, sum: sum, info: info, i: i}); + } + } }); - } - - /** - * Returns property name. - * e.g. - * for: 'color: #fff' - * returns string: 'color' - * - * @param {node} node - * @returns {String|undefined} - */ - function getPropertyName(node) { - if (!node.is('declaration')) return; - // TODO: Check that it's not a variable - return node.get(0).get(0).content; - } - - /** - * Returns property value name. - * e.g. - * for: '-webkit-transition: -webkit-transform 150ms linear' - * returns string: '-webkit-transform', and - * for: 'background: -webkit-linear-gradient(...)' - * returns string: '-webkit-linear-gradient' - * - * @param {node} node - * @returns {String|undefined} - */ - function getValName(node) { - if (!node.is('declaration')) return; - - var value = node.first('value'); - if (value.get(0).is('ident')) return value.get(0).content; - if (value.get(0).is('function')) return value.get(0).get(0).content; - } - /** - * Updates dict which contains info about items align. - * - * @param {Object} info, - * @param {Object} dict, - */ - function updateDict(info, dict) { - if (info.prefixLength === 0 && info.extra === 0) return; + walk({ + node: node, + selector: getValName, + getExtraSymbols: extraIndentVal, + payload: function(info, i) { + for (var x = node.get(i).length; x--;) { + if (node.get(i).get(x).is('value')) break; + } - var indent = dict[info.id] || {prefixLength: 0, extra: 0}; + if (node.get(i).get(x - 1)) { + let nodeLength = node.get(i).get(x - 1).content + .replace(/^[ \t]*\n+/, '').length; + var sum = nodeLength + info.prefixLength; + getResult({node: node, sum: sum, info: info, i: i}); + } + } + }); - let indentLength = indent.prefixLength + indent.extra; - let infoLength = info.prefixLength + info.extra; - if (indentLength > infoLength) { - dict[info.id] = indent; - } else { - dict[info.id] = { - prefixLength: info.prefixLength, - extra: info.extra - }; + if (result.true > 0 || result.false > 0) { + if (result.true >= result.false) { + detected.push(true); + } else { + detected.push(false); + } } - } - - /** - * Returns string with correct number of spaces for info.baseName property. - * - * @param {Object} info, - * @param {Object} dict, - * @param {String} whitespaceNode - * @returns {String} - */ - function updateIndent(info, dict, whitespaceNode) { - var item = dict[info.id]; - if (!item) - return whitespaceNode; - - var crPos = whitespaceNode.lastIndexOf('\n'); - var tabPos = whitespaceNode.lastIndexOf('\t'); - if (tabPos > crPos) crPos = tabPos; + }); - var firstPart = whitespaceNode.substr(0, crPos + 1); - var extraIndent = new Array( - (item.prefixLength - info.prefixLength) + - (item.extra - info.extra) + - whitespaceNode.length - firstPart.length + - 1).join(' '); - - return firstPart.concat(extraIndent); + return detected; } - - return { - name: 'vendor-prefix-align', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { - boolean: [true] - }, - - /** - * Processes tree node. - * - * @param {node} ast - */ - process: function(ast) { - ast.traverseByType('block', function(node) { - oneline = true; - - var dict = {}; - - // Gathering Info - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info) { - updateDict(info, dict); - } - }); - - walk({ - node: node, - selector: getValName, - namespaceSelector: getPropertyName, - getExtraSymbols: extraIndentVal, - payload: function(info) { - updateDict(info, dict); - } - }); - - if (oneline && ast.syntax !== 'sass') return; - - // Update nodes - walk({ - node: node, - selector: getValName, - namespaceSelector: getPropertyName, - getExtraSymbols: extraIndentVal, - payload: function(info, i) { - for (var x = node.get(i).length; x--;) { - if (node.get(i).get(x).is('value')) break; - } - - let prevNode = node.get(i).get(x - 1); - if (!prevNode.is('space')) { - var space = gonzales.createNode({ - type: 'space', - content: '' - }); - node.get(i).insert(x, space); - ++x; - } - - let content = node.get(i).get(x - 1).content; - let updatedIndent = updateIndent(info, dict, content); - node.get(i).get(x - 1).content = updatedIndent; - } - }); - - if (ast.syntax === 'sass') return; - - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info, i) { - // `node.get(i - 1)` can be either space or comment: - var whitespaceNode = node.get(i - 1); - if (!whitespaceNode) return; - // If it's a comment, insert an empty space node: - if (!whitespaceNode.is('space')) { - whitespaceNode = gonzales.createNode({ - type: 'space', - content: '' - }); - node.insert(i - 1, whitespaceNode); - } - let content = whitespaceNode.content; - let updatedContent = updateIndent(info, dict, content); - whitespaceNode.content = updatedContent; - } - }); - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} ast - */ - detect: function(ast) { - let detected = []; - - ast.traverseByType('block', function(node) { - var result = { - true: 0, - false: 0 - }; - - var maybePrefix = false; - var prevPrefixLength = false; - var prevProp; - var prevSum; - var partialResult = null; - - var getResult = function(options) { - let {node, sum, info, i} = options; - var prop = info.baseName; - - // If this is the last item in a row and we have a result, - // then catch it - if (prop !== prevProp && partialResult !== null) { - if (partialResult) { - result.true++; - } else { - result.false++; - } - partialResult = null; - } - - if (prop === prevProp && - info.prefixLength !== prevPrefixLength) { - maybePrefix = true; - } else { - maybePrefix = false; - } - - if (maybePrefix && partialResult !== false) { - // If there is prefixed prop, check if the prefixes are - // aligned, but only if we hadn't already catched - // that it is false - if (sum === prevSum) { - partialResult = true; - } else { - partialResult = false; - } - } - - if (node.length === i + 3 && partialResult !== null) { - // If we're at the last property and have a result, - // catch it - if (partialResult) { - result.true++; - } else { - result.false++; - } - } - - prevPrefixLength = info.prefixLength; - prevProp = prop; - prevSum = sum; - }; - - // Gathering Info - walk({ - node: node, - selector: getPropertyName, - getExtraSymbols: extraIndentProperty, - payload: function(info, i) { - if (node.get(i - 1) && node.get(i - 1).content) { - let nodeLength = node.get(i - 1).content. - replace(/^[ \t]*\n+/, '').length; - var sum = nodeLength + info.prefixLength; - getResult({node: node, sum: sum, info: info, i: i}); - } - } - }); - - walk({ - node: node, - selector: getValName, - getExtraSymbols: extraIndentVal, - payload: function(info, i) { - for (var x = node.get(i).length; x--;) { - if (node.get(i).get(x).is('value')) break; - } - - if (node.get(i).get(x - 1)) { - let nodeLength = node.get(i).get(x - 1).content - .replace(/^[ \t]*\n+/, '').length; - var sum = nodeLength + info.prefixLength; - getResult({node: node, sum: sum, info: info, i: i}); - } - } - }); - - if (result.true > 0 || result.false > 0) { - if (result.true >= result.false) { - detected.push(true); - } else { - detected.push(false); - } - } - }); - - return detected; - } - }; + }; })(); From 4f68f39b4dd286caa0347b563c368b9ed23dbdcb Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 23 Aug 2015 21:32:14 +0300 Subject: [PATCH 108/184] Refactor --- .jscs.json | 15 +++++--- .jshint-groups.js | 36 ------------------- .jshintrc | 5 ++- package.json | 2 +- scripts/test.sh | 2 +- src/cli.js | 2 ++ src/csscomb.js | 2 ++ src/format.js | 2 ++ src/gonzales.js | 5 ++- src/options/always-semicolon.js | 7 ++-- src/options/block-indent.js | 2 ++ src/options/color-case.js | 2 ++ src/options/color-shorthand.js | 2 ++ src/options/element-case.js | 2 ++ src/options/eof-newline.js | 2 ++ src/options/leading-zero.js | 2 ++ src/options/quotes.js | 2 ++ src/options/remove-empty-rulesets.js | 2 ++ src/options/sort-order-fallback.js | 2 ++ src/options/sort-order.js | 2 ++ src/options/space-after-colon.js | 2 ++ src/options/space-after-combinator.js | 2 ++ src/options/space-after-opening-brace.js | 2 ++ src/options/space-after-selector-delimiter.js | 2 ++ src/options/space-before-closing-brace.js | 2 ++ src/options/space-before-colon.js | 2 ++ src/options/space-before-combinator.js | 2 ++ src/options/space-before-opening-brace.js | 2 ++ .../space-before-selector-delimiter.js | 2 ++ src/options/space-between-declarations.js | 2 ++ src/options/strip-spaces.js | 2 ++ src/options/tab-size.js | 2 ++ src/options/unitless-zero.js | 2 ++ src/options/vendor-prefix-align.js | 10 +++--- 34 files changed, 83 insertions(+), 51 deletions(-) delete mode 100644 .jshint-groups.js diff --git a/.jscs.json b/.jscs.json index c78d27a0..f34264ce 100644 --- a/.jscs.json +++ b/.jscs.json @@ -48,13 +48,18 @@ "requireSpaceBetweenArguments": true, "requireSpacesInForStatement": true, "validateIndentation": 2, - "validateJSDoc": { - "checkParamNames": true, - "checkRedundantParams": true, - "requireParamTypes": true - }, "validateQuoteMarks": { "mark": "'", "escape": true + }, + "jsDoc": { + "checkAnnotations": "closurecompiler", + "checkParamNames": true, + "checkRedundantParams": true, + "checkRedundantReturns": true, + "checkReturnTypes": true, + "checkTypes": true, + "requireParamTypes": true, + "requireReturnTypes": true } } diff --git a/.jshint-groups.js b/.jshint-groups.js deleted file mode 100644 index 14e491ee..00000000 --- a/.jshint-groups.js +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = { - options: { - globals: { - afterEach: false, - beforeEach: false, - describe: false, - it: false - }, - eqeqeq: true, - esnext: true, - expr: true, - forin: true, - maxdepth: 5, - maxparams: 3, - noarg: true, - nonew: true, - trailing: true, - undef: true, - unused: true - }, - groups: { - src: { - options: { - node: true - }, - includes: ['src/**/*.js'] - }, - test: { - options: { - node: true, - predef: ['afterEach', 'beforeEach', 'describe', 'it'] - }, - includes: ['test/**/*.js'] - } - } -}; diff --git a/.jshintrc b/.jshintrc index b8833b04..4b3b2959 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,12 +1,15 @@ { + "eqeqeq": true, + "esnext": true, + "freeze": true, "globals": { "afterEach": false, "beforeEach": false, "describe": false, "it": false }, - "esnext": true, "node": true, + "strict": true, "undef": true, "unused": true, "-W084": true diff --git a/package.json b/package.json index d0c2b3fe..cac71a85 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "devDependencies": { "babel": "^5.5.3", - "jscs": "1.13.1", + "jscs": "2.1.0", "jshint": "2.8.0", "mocha": "1.20.1" }, diff --git a/scripts/test.sh b/scripts/test.sh index 5597cc23..c118a2e6 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -14,7 +14,7 @@ printf "\n\ ----------------\n\ Running JSHint\n\ ----------------\n\n" -test ./node_modules/.bin/jshint-groups +test ./node_modules/.bin/jshint ./src printf "\n\ --------------\n\ diff --git a/src/cli.js b/src/cli.js index 0fdb3199..904b003e 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Command line implementation for CSSComb * diff --git a/src/csscomb.js b/src/csscomb.js index f490c024..69cd25d3 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -1,3 +1,5 @@ +'use strict'; + let Comb = require('csscomb-core'); let gonzales = require('./gonzales'); let fs = require('fs'); diff --git a/src/format.js b/src/format.js index f2f8b376..261df4c4 100644 --- a/src/format.js +++ b/src/format.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = function(string) { return string.replace(/\n\s+/gm, ' '); }; diff --git a/src/gonzales.js b/src/gonzales.js index d046b0ba..4398d483 100644 --- a/src/gonzales.js +++ b/src/gonzales.js @@ -1,2 +1,5 @@ -// jscs:disable +// jscs:disable maximumLineLength + +'use strict'; + module.exports = require('../node_modules/csscomb-core/node_modules/gonzales-pe'); diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index d6aec939..f719a38e 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); let option = { @@ -29,8 +31,9 @@ let option = { /** * Checks ast for code style errors. + * * @param {Node} ast - * @return {Array} List of found errors. + * @return {Array?} List of found errors. */ lint(ast) { var errors = []; @@ -120,7 +123,7 @@ let option = { /** * Detects the value of this option in ast. * @param {Node} ast - * @return {Array} List of detected values + * @return {Array?} List of detected values */ detect(ast) { var detected = []; diff --git a/src/options/block-indent.js b/src/options/block-indent.js index 3da174ac..b5f473fb 100644 --- a/src/options/block-indent.js +++ b/src/options/block-indent.js @@ -1,3 +1,5 @@ +'use strict'; + let option = { /** * Option's name as it's used in config. diff --git a/src/options/color-case.js b/src/options/color-case.js index bfaed417..b29ca12b 100644 --- a/src/options/color-case.js +++ b/src/options/color-case.js @@ -1,3 +1,5 @@ +'use strict'; + let option = { /** * Option's name as it's used in config. diff --git a/src/options/color-shorthand.js b/src/options/color-shorthand.js index f33f9edd..5abbfdca 100644 --- a/src/options/color-shorthand.js +++ b/src/options/color-shorthand.js @@ -1,3 +1,5 @@ +'use strict'; + let option = { /** * Option's name as it's used in config. diff --git a/src/options/element-case.js b/src/options/element-case.js index 152ce89a..1f8622e1 100644 --- a/src/options/element-case.js +++ b/src/options/element-case.js @@ -1,3 +1,5 @@ +'use strict'; + let option = { /** * Option's name as it's used in config. diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index 8492e326..70442729 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -1,3 +1,5 @@ +'use strict'; + let gonzales = require('../gonzales'); let option = { diff --git a/src/options/leading-zero.js b/src/options/leading-zero.js index 4aba1f4c..77381c39 100644 --- a/src/options/leading-zero.js +++ b/src/options/leading-zero.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { name: 'leading-zero', diff --git a/src/options/quotes.js b/src/options/quotes.js index bc96d5f7..3e591783 100644 --- a/src/options/quotes.js +++ b/src/options/quotes.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { name: 'quotes', diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index cc7512ae..a7b7f76b 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = (function() { function processNode(node) { removeEmptyRulesets(node); diff --git a/src/options/sort-order-fallback.js b/src/options/sort-order-fallback.js index 182c33af..80d9dc27 100644 --- a/src/options/sort-order-fallback.js +++ b/src/options/sort-order-fallback.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { name: 'sort-order-fallback', diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 80e85b1b..d3a599f7 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 88125d54..1dc0d75f 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index a57def74..a2a1c33e 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index de7571f6..a5b3fdf6 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index 089b58a7..12939e69 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index e0b6f507..dccfe5f1 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = (function() { diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 0df08bdd..016601b3 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index d0cf9d64..6f42e58a 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index 5a9bc19e..a514fc2a 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = (function() { diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 8c5f7cf7..5b6719b3 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = { diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 8aa817b7..d83ad072 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = (function() { diff --git a/src/options/strip-spaces.js b/src/options/strip-spaces.js index ebc647f3..50ea4ae9 100644 --- a/src/options/strip-spaces.js +++ b/src/options/strip-spaces.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = (function() { /** * Trim trailing spaces on each line. diff --git a/src/options/tab-size.js b/src/options/tab-size.js index e5b9e77d..d9a4b753 100644 --- a/src/options/tab-size.js +++ b/src/options/tab-size.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { name: 'tab-size', diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index a69a5013..6079c4a9 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = { name: 'unitless-zero', diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index 31914712..a1d5e0f1 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -1,3 +1,5 @@ +'use strict'; + var gonzales = require('../gonzales'); module.exports = (function() { @@ -214,8 +216,8 @@ module.exports = (function() { /** * Updates dict which contains info about items align. * - * @param {Object} info, - * @param {Object} dict, + * @param {Object} info + * @param {Object} dict */ function updateDict(info, dict) { if (info.prefixLength === 0 && info.extra === 0) return; @@ -237,8 +239,8 @@ module.exports = (function() { /** * Returns string with correct number of spaces for info.baseName property. * - * @param {Object} info, - * @param {Object} dict, + * @param {Object} info + * @param {Object} dict * @param {String} whitespaceNode * @returns {String} */ From f1d9147aefd57d344074502f4e6dad2aa6856042 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 16 Oct 2015 23:43:14 +0200 Subject: [PATCH 109/184] [gpe] Update GPE to v3.0 --- src/options/space-after-colon.js | 48 ++++++++--------- src/options/space-after-combinator.js | 39 ++++++-------- src/options/space-after-selector-delimiter.js | 52 +++++++++---------- src/options/space-before-colon.js | 50 ++++++++---------- src/options/space-before-combinator.js | 46 ++++++---------- src/options/space-before-opening-brace.js | 44 +++++----------- .../space-before-selector-delimiter.js | 44 ++++++++-------- src/options/unitless-zero.js | 5 +- 8 files changed, 138 insertions(+), 190 deletions(-) diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 1dc0d75f..42767462 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -22,25 +22,23 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverseByType('declaration', function(declaration) { - declaration.eachFor('propertyDelimiter', function(delimiter, i) { - if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) - return null; - - // Remove any spaces after colon: - if (declaration.get(i + 1).is('space')) - declaration.remove(i + 1); - // If the value set in config is not empty, add spaces: - if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - declaration.insert(i + 1, space); - } - + ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { + if (delimiter.syntax === 'sass' && !parent.get(i - 1)) return null; - }); + + // Remove any spaces after colon: + if (parent.get(i + 1).is('space')) + parent.removeChild(i + 1); + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + parent.insert(i + 1, space); + } + + return null; }); }, @@ -52,14 +50,12 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('declaration', function(declaration) { - declaration.eachFor('propertyDelimiter', function(delimiter, i) { - if (declaration.get(i + 1).is('space')) { - detected.push(declaration.get(i + 1).content); - } else { - detected.push(''); - } - }); + ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { + if (parent.get(i + 1).is('space')) { + detected.push(parent.get(i + 1).content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index a2a1c33e..e999d4fe 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -22,21 +22,16 @@ module.exports = { process: function(ast) { let value = this.value; - // TODO(tonyganch): Can this be replaced with one `traverse`? - ast.traverseByType('selector', function(selector) { - selector.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - simpleSelector.get(i + 1).content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - simpleSelector.insert(i + 1, space); - } + ast.traverseByType('combinator', function(combinator, i, parent) { + if (parent.get(i + 1).is('space')) { + parent.get(i + 1).content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value }); - }); + parent.insert(i + 1, space); + } }); }, @@ -48,16 +43,12 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach('simpleSelector', function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i + 1).is('space')) { - detected.push(simpleSelector.get(i + 1).content); - } else { - detected.push(''); - } - }); - }); + ast.traverseByType('combinator', function(combinator, i, parent) { + if (parent.get(i + 1).is('space')) { + detected.push(parent.get(i + 1).content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index 12939e69..bbb82574 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -22,22 +22,22 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delimiter, i) { - var nextNode = selector.get(i + 1); + ast.traverseByType('delimiter', function(delimiter, i, parent) { + if (parent.is('arguments')) return; - if (nextNode.is('space')) { - nextNode.content = value; - } else if (nextNode.first().is('space')) { - nextNode.first().content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - nextNode.insert(0, space); - } - }); + var nextNode = parent.get(i + 1); + + if (nextNode.is('space')) { + nextNode.content = value; + } else if (nextNode.first().is('space')) { + nextNode.first().content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + nextNode.insert(0, space); + } }); }, @@ -49,18 +49,18 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delimiter, i) { - var nextNode = selector.get(i + 1); + ast.traverseByType('delimiter', function(delimiter, i, parent) { + if (parent.is('arguments')) return; + + var nextNode = parent.get(i + 1); - if (nextNode && nextNode.is('space')) { - detected.push(nextNode.content); - } else if (nextNode.first() && nextNode.first().is('space')) { - detected.push(nextNode.first().content); - } else { - detected.push(''); - } - }); + if (nextNode && nextNode.is('space')) { + detected.push(nextNode.content); + } else if (nextNode.first() && nextNode.first().is('space')) { + detected.push(nextNode.first().content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index 016601b3..fc1064cf 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -22,25 +22,23 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverseByType('declaration', function(declaration) { - declaration.forEach('propertyDelimiter', function(delimiter, i) { - if (delimiter.syntax === 'sass' && !declaration.get(i - 1)) - return; - - // Remove any spaces before colon: - if (declaration.get(i - 1).is('space')) { - declaration.remove(--i); - } - - // If the value set in config is not empty, add spaces: - if (value !== '') { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - declaration.insert(i, space); - } - }); + ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { + if (delimiter.syntax === 'sass' && !parent.get(i - 1)) + return; + + // Remove any spaces before colon: + if (parent.get(i - 1).is('space')) { + parent.removeChild(--i); + } + + // If the value set in config is not empty, add spaces: + if (value !== '') { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + parent.insert(i, space); + } }); }, @@ -52,14 +50,12 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('declaration', function(declaration) { - declaration.forEach('propertyDelimiter', function(delimiter, i) { - if (declaration.get(i - 1).is('space')) { - detected.push(declaration.get(i - 1).content); - } else { - detected.push(''); - } - }); + ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { + if (parent.get(i - 1).is('space')) { + detected.push(parent.get(i - 1).content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 6f42e58a..3baceb35 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -22,28 +22,16 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverseByType('selector', function(selector) { - selector.forEach(function(simpleSelector) { - var notFirst = false; - - simpleSelector.forEach(function(n, i) { - if (!n.is('space') && !n.is('combinator')) notFirst = true; - - // If combinator is the first thing in selector, - // do not add extra spaces: - if (!n.is('combinator') || !notFirst) return; - - if (simpleSelector.get(i - 1).is('space')) { - simpleSelector.get(i - 1).content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - simpleSelector.insert(i, space); - } + ast.traverseByType('combinator', function(combinator, i, parent) { + if (parent.get(i - 1).is('space')) { + parent.get(i - 1).content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value }); - }); + parent.insert(i, space); + } }); }, @@ -55,16 +43,12 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach(function(simpleSelector) { - simpleSelector.forEach('combinator', function(combinator, i) { - if (simpleSelector.get(i - 1).is('space')) { - detected.push(simpleSelector.get(i - 1).content); - } else { - detected.push(''); - } - }); - }); + ast.traverseByType('combinator', function(combinator, i, parent) { + if (parent.get(i - 1).is('space')) { + detected.push(parent.get(i - 1).content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index a514fc2a..d43b33e4 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -3,20 +3,6 @@ var gonzales = require('../gonzales'); module.exports = (function() { - /** - * Gets the last (the deepest) whitespace node. - * - * @param {node} node - * @returns {node|undefined} If no whitespace node is found, returns - * `undefined` - */ - function getLastWhitespaceNode(node) { - if (typeof node !== 'object') return; - if (node.is('space')) return node; - - return getLastWhitespaceNode(node.last()); - } - return { name: 'space-before-opening-brace', @@ -38,27 +24,23 @@ module.exports = (function() { let value = this.value; // If found block node stop at the next one for space check. - ast.traverseByTypes(['block', 'atrulers'], function(block, i, parent) { - // For the pre-block node, find its last (the deepest) child: - // TODO: Exclude nodes with braces (for example, arguments) + ast.traverseByTypes(['block', 'value'], function(block, i, parent) { + if (block.is('value') && !block.first().is('block')) return; + var previousNode = parent.get(i - 1); - var whitespaceNode = getLastWhitespaceNode(previousNode); + if (!previousNode) return; // If it's spaces, modify this node. // If it's something different from spaces, add a space node to // the end: - if (whitespaceNode) { - whitespaceNode.content = value; + if (previousNode.is('space')) { + previousNode.content = value; } else if (value !== '') { var space = gonzales.createNode({ type: 'space', content: value }); - if (previousNode && previousNode.is('atrulerq')) { - previousNode.content.push(space); - } else { - parent.insert(i, space); - } + parent.insert(i, space); } }); }, @@ -71,17 +53,17 @@ module.exports = (function() { detect: function(ast) { var detected = []; - ast.traverseByTypes(['block', 'atrulers'], function(block, i, parent) { - // For the pre-block node, find its last (the deepest) child: - // TODO: Exclude nodes with braces (for example, arguments) + ast.traverseByTypes(['block', 'value'], function(block, i, parent) { + if (block.is('value') && !block.first().is('block')) return; + var previousNode = parent.get(i - 1); - var whitespaceNode = getLastWhitespaceNode(previousNode); + if (!previousNode) return; // If it's spaces, modify this node. // If it's something different from spaces, add a space node to // the end: - if (whitespaceNode) { - detected.push(whitespaceNode.content); + if (previousNode.is('space')) { + detected.push(previousNode.content); } else { detected.push(''); } diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index 5b6719b3..eb960d1f 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -22,19 +22,19 @@ module.exports = { process: function(ast) { let value = this.value; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delim, i) { - var previousNode = selector.get(i - 1); - if (previousNode.last().is('space')) { - previousNode.last().content = value; - } else { - var space = gonzales.createNode({ - type: 'space', - content: value - }); - previousNode.content.push(space); - } - }); + ast.traverseByType('delimiter', function(delimiter, i, parent) { + if (parent.is('arguments')) return; + + var previousNode = parent.get(i - 1); + if (previousNode.is('space')) { + previousNode.content = value; + } else { + var space = gonzales.createNode({ + type: 'space', + content: value + }); + parent.insert(i, space); + } }); }, @@ -46,15 +46,15 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverseByType('selector', function(selector) { - selector.forEach('delimiter', function(delim, i) { - var previousNode = selector.get(i - 1); - if (previousNode.last().is('space')) { - detected.push(previousNode.last().content); - } else { - detected.push(''); - } - }); + ast.traverseByType('delimiter', function(delimiter, i, parent) { + if (parent.is('arguments')) return; + + var previousNode = parent.get(i - 1); + if (previousNode.is('space')) { + detected.push(previousNode.content); + } else { + detected.push(''); + } }); return detected; diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index 6079c4a9..0d5ce213 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -25,7 +25,7 @@ module.exports = { var unit = value.first('ident').content; if (value.first('number').content[0] === '0' && UNITS.indexOf(unit) !== -1) { - value.remove(1); + value.removeChild(1); } } else if (value.is('percentage')) { var number = value.first('number').content; @@ -46,7 +46,7 @@ module.exports = { detect: function(ast) { let detected = []; - ast.traverse(function(node, params) { + ast.traverse(function(node, index, parent) { // If we see a zero with unit and it is not degree, // then we don’t have an option if (node.is('percentage') && @@ -64,7 +64,6 @@ module.exports = { // If we see a zero and previous node is not percentage // or dimension, then we have an option - let parent = params.parent; if (node.is('number') && node.content[0] === '0' && !parent.is('percentage') && From 7ab889bae93aa34d453faea15ed3c8df0e6d9baa Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 9 Nov 2015 11:35:13 +0100 Subject: [PATCH 110/184] :cherry: --- src/options/sort-order.js | 24 +++++++++++-------- test/options/sort-order/process/test.js | 8 +++---- .../space-before-combinator/process/test.js | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/options/sort-order.js b/src/options/sort-order.js index d3a599f7..77d9e183 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -144,13 +144,18 @@ module.exports = { // (e. g. `$include breakpoint`), and the rest — `$include`. let mixinName; - // TODO(tonyganch): explain `first.first`. - if (node.syntax === 'less') - mixinName = node.first().first().content; - else if (node.syntax === 'sass' && node.first().content === '+') - mixinName = node.get(1).first().content; - else - mixinName = node.get(2).first().content; + console.log(node); + if (node.syntax === 'less') { + // `node.first()` is class and `node.first().first()` is ident. + mixinName = node.first().first().content; + } else if (node.syntax === 'sass' && node.first().content === '+') { + // `node.first()` is `+` and `node.get(1)` is ident. + mixinName = node.get(1).content; + } else { + // `node.first()` is @-keyword, `node.get(1)` is space and + // `node.get(2)` is ident. + mixinName = node.get(2).content; + } let includeMixinName = '$include ' + mixinName; return this.value.hasOwnProperty(includeMixinName) ? @@ -301,8 +306,7 @@ module.exports = { // Types of nodes that can be sorted. _isAcceptableNode(node) { - const NODES = ['atruleb', 'atruler', 'atrules', - 'declaration', 'extend', 'include', + const NODES = ['atrule', 'declaration', 'extend', 'include', 'multilineComment', 'singlelineComment', 'space']; return NODES.indexOf(node.type) !== -1; }, @@ -360,7 +364,7 @@ module.exports = { nodesToDelete.sort((a, b) => a - b); for (let x = nodesToDelete.length - 1; x > -1; x--) - block.remove(nodesToDelete[x]); + block.removeChild(nodesToDelete[x]); return sortables; }, diff --git a/test/options/sort-order/process/test.js b/test/options/sort-order/process/test.js index 6d95c827..dc3e5642 100644 --- a/test/options/sort-order/process/test.js +++ b/test/options/sort-order/process/test.js @@ -291,7 +291,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('import.sass', 'import.expected.sass'); }); - it('Should sort @include-s', function() { + it.skip('Should sort @include-s', function() { let test = new Test(this, { 'sort-order': [['$include', 'color']] }); @@ -420,7 +420,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('import.scss', 'import.expected.scss'); }); - it('Should sort @include-s', function() { + it.skip('Should sort @include-s', function() { let test = new Test(this, { 'sort-order': [['$include', 'color']] }); @@ -462,7 +462,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('condition.scss', 'condition.expected.scss'); }); - it('Should sort complex case with leftovers', function() { + it.skip('Should sort complex case with leftovers', function() { let test = new Test(this, { 'sort-order': [ ['$variable'], @@ -475,7 +475,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); }); - it('Issue 317', function() { + it.skip('Issue 317', function() { let test = new Test(this, {'sort-order': ['...']}); return test.shouldBeEqual('issue-317.scss'); }); diff --git a/test/options/space-before-combinator/process/test.js b/test/options/space-before-combinator/process/test.js index aec191c0..dc9909be 100644 --- a/test/options/space-before-combinator/process/test.js +++ b/test/options/space-before-combinator/process/test.js @@ -32,7 +32,7 @@ describe('Option `space-before-combinator`, process', function() { return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); - it('Issue 381', function() { + it.skip('Issue 381', function() { let test = new Test(this, {'space-before-combinator': ' '}); return test.shouldBeEqual('issue-381.css'); }); From 3b3eafad252f1e3f432416af757a401aa934acbc Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:00:44 +0300 Subject: [PATCH 111/184] Hotfix for #389 --- lib/options/unitless-zero.js | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lib/options/unitless-zero.js diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js new file mode 100644 index 00000000..62bb9a0c --- /dev/null +++ b/lib/options/unitless-zero.js @@ -0,0 +1,82 @@ +module.exports = { + name: 'unitless-zero', + + syntax: ['css', 'less', 'sass', 'scss'], + + accepts: { boolean: [true] }, + + /** + * Processes tree node. + * + * @param {node} node + */ + process: function(node) { + var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; + + if (!node.is('value') && !node.is('braces')) return; + + node.forEach(function(value) { + if (typeof value === 'string') return; + + if (value.is('dimension')) { + var unit = value.first('ident').content; + if (value.first('number').content[0] === '0' && + UNITS.indexOf(unit) !== -1) { + value.remove(1); + } + } else if (value.is('percentage')) { + // XXX(tonyganch): There is a bug in Gonzales when in Less, + // percentage's content is not wrapped as an array but actually + // type of node's content is object. This bug has already been + // fixed in newer versions of Gonzales so the issue should be + // gone after update of dependencies and csscomb@4.0 release. + // This hack is here as a hotfix for csscomb@3.1 and must be + // removed once csscom@4.0 is released. See #389. + var number; + if (!Array.isArray(value.content) && + value.content.is('number')) { + number = value.content; + } else { + number = value.first('number').content; + } + + if (number[0] === '0') { + value.type = 'number'; + value.content = number; + } + } + }); + }, + + /** + * Detects the value of an option at the tree node. + * + * @param {node} node + */ + detect: function(node) { + var result; + + // If we see a zero with unit and it is not degree, then we don’t have an option + + if (node.is('percentage') && node.first('number').content[1] === '0') { + result = false; + } else if (node.is('dimension') && + node.first('number').content[0] === '0' && + node.first('ident').content !== 'deg') { + result = false; + } + + // If we see a zero and previous node is not percentage or dimension, then we have an option + if (node.is('number') && + node.content[0] === '0' && + this._prev !== 'percentage' && + this._prev !== 'dimension') { + result = true; + } + + // Store the previous nodeType + this._prev = node.type; + + return result; + } +}; From da18af60b56e5ce068429dfb6b4f3a1ce560a030 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 9 Jun 2015 23:16:46 +0300 Subject: [PATCH 112/184] Fix #394: unitless-zero vs fractions Don't remove units from values starting from zero, like `0.5em` --- lib/options/unitless-zero.js | 82 -------------------- test/options/unitless-zero/test.js | 115 +++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 82 deletions(-) delete mode 100644 lib/options/unitless-zero.js create mode 100644 test/options/unitless-zero/test.js diff --git a/lib/options/unitless-zero.js b/lib/options/unitless-zero.js deleted file mode 100644 index 62bb9a0c..00000000 --- a/lib/options/unitless-zero.js +++ /dev/null @@ -1,82 +0,0 @@ -module.exports = { - name: 'unitless-zero', - - syntax: ['css', 'less', 'sass', 'scss'], - - accepts: { boolean: [true] }, - - /** - * Processes tree node. - * - * @param {node} node - */ - process: function(node) { - var UNITS = ['cm', 'em', 'ex', 'pt', 'px']; - - if (!node.is('value') && !node.is('braces')) return; - - node.forEach(function(value) { - if (typeof value === 'string') return; - - if (value.is('dimension')) { - var unit = value.first('ident').content; - if (value.first('number').content[0] === '0' && - UNITS.indexOf(unit) !== -1) { - value.remove(1); - } - } else if (value.is('percentage')) { - // XXX(tonyganch): There is a bug in Gonzales when in Less, - // percentage's content is not wrapped as an array but actually - // type of node's content is object. This bug has already been - // fixed in newer versions of Gonzales so the issue should be - // gone after update of dependencies and csscomb@4.0 release. - // This hack is here as a hotfix for csscomb@3.1 and must be - // removed once csscom@4.0 is released. See #389. - var number; - if (!Array.isArray(value.content) && - value.content.is('number')) { - number = value.content; - } else { - number = value.first('number').content; - } - - if (number[0] === '0') { - value.type = 'number'; - value.content = number; - } - } - }); - }, - - /** - * Detects the value of an option at the tree node. - * - * @param {node} node - */ - detect: function(node) { - var result; - - // If we see a zero with unit and it is not degree, then we don’t have an option - - if (node.is('percentage') && node.first('number').content[1] === '0') { - result = false; - } else if (node.is('dimension') && - node.first('number').content[0] === '0' && - node.first('ident').content !== 'deg') { - result = false; - } - - // If we see a zero and previous node is not percentage or dimension, then we have an option - if (node.is('number') && - node.content[0] === '0' && - this._prev !== 'percentage' && - this._prev !== 'dimension') { - result = true; - } - - // Store the previous nodeType - this._prev = node.type; - - return result; - } -}; diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js new file mode 100644 index 00000000..871405dd --- /dev/null +++ b/test/options/unitless-zero/test.js @@ -0,0 +1,115 @@ +var assert = require('assert'); + +describe('options/unitless-zero', function() { + describe('process', function() { + it('Should remove units in zero-valued dimensions', function() { + this.comb.configure({ 'unitless-zero': true }); + return this.comb.processString( + 'div { margin: 0em; padding: 0px }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0; padding: 0 }'); + }); + }); + + it('Should remove units in zero-valued dimensions, test 2', function() { + this.comb.configure({ 'unitless-zero': true }); + return this.comb.processString( + 'div { margin: 0% }' + ).then(function(actual) { + assert.equal(actual, 'div { margin: 0 }'); + }); + }); + + it('Should remove units in zero-valued media-query params', function() { + this.comb.configure({ 'unitless-zero': true }); + return this.comb.processString( + '@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }' + ).then(function(actual) { + assert.equal(actual, '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }'); + }); + }); + + it('Should not remove units (degs) in rotate property', function() { + this.comb.configure({ 'unitless-zero': true }); + return this.comb.processString( + 'div { -webkit-transform: rotate(0deg); }' + ).then(function(actual) { + assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); + }); + }); + + it('Issue 394', function() { + this.comb.configure({ 'unitless-zero': true }); + this.shouldBeEqual('issue-394.css', 'issue-394.expected.css'); + }); + }); + + describe('detect', function() { + it('Should detect unitless zero option', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { width: 0 }', + { + 'unitless-zero': true + } + ); + }); + + + it('Should detect zero with unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { width: 0px }', + { + 'unitless-zero': false + } + ); + }); + + it('Should detect unitless zero option with multiple values', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0 }', + { + 'unitless-zero': true + } + ); + }); + + it('Should detect zero with unit and multiple values', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0px 0 0em }', + { + 'unitless-zero': false + } + ); + }); + + it('Shouldn’t detect unitless zero option if there is no unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { color: red }', + {} + ); + }); + + it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { transform: rotate(0deg) }', + {} + ); + }); + + it('Should detect unitless zero option with percents', function() { + this.shouldDetect( + ['unitless-zero'], + 'a { padding: 0% 0 0 }', + { + 'unitless-zero': true + } + ); + }); + }); +}); From 02192d2b219e3e56e52ac57cbebfd13e75b5282f Mon Sep 17 00:00:00 2001 From: sodatea Date: Mon, 18 Jan 2016 13:40:37 +0800 Subject: [PATCH 113/184] [tests] Use valid less syntax --- .../always-semicolon/process/less/condition-multiline.less | 2 +- test/options/always-semicolon/process/less/condition.less | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/options/always-semicolon/process/less/condition-multiline.less b/test/options/always-semicolon/process/less/condition-multiline.less index b3071171..e4213d2f 100644 --- a/test/options/always-semicolon/process/less/condition-multiline.less +++ b/test/options/always-semicolon/process/less/condition-multiline.less @@ -1,6 +1,6 @@ div { @color: tomato; - when (@color = tomato) { + div when (@color = tomato) { top: 0; } } diff --git a/test/options/always-semicolon/process/less/condition.less b/test/options/always-semicolon/process/less/condition.less index c0c4950f..5608abdc 100644 --- a/test/options/always-semicolon/process/less/condition.less +++ b/test/options/always-semicolon/process/less/condition.less @@ -1 +1 @@ -div { @color: tomato; when (@color = tomato) { top: 0; } } +div { @color: tomato; div when (@color = tomato) { top: 0; } } From 2bc6281da03ce016cb6d3659c759d462eb1a2479 Mon Sep 17 00:00:00 2001 From: sodatea Date: Mon, 18 Jan 2016 14:11:40 +0800 Subject: [PATCH 114/184] [tests] Re-add tests for #389 & #394 --- test/options/unitless-zero-less/test.js | 6 ------ .../unitless-zero/{ => process/css}/issue-394.css | 0 .../{ => process/css}/issue-394.expected.css | 0 .../process/less}/issue-389.less | 0 test/options/unitless-zero/process/test.js | 12 ++++++++++++ 5 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 test/options/unitless-zero-less/test.js rename test/options/unitless-zero/{ => process/css}/issue-394.css (100%) rename test/options/unitless-zero/{ => process/css}/issue-394.expected.css (100%) rename test/options/{unitless-zero-less => unitless-zero/process/less}/issue-389.less (100%) diff --git a/test/options/unitless-zero-less/test.js b/test/options/unitless-zero-less/test.js deleted file mode 100644 index 942206b9..00000000 --- a/test/options/unitless-zero-less/test.js +++ /dev/null @@ -1,6 +0,0 @@ -describe('options/unitless-zero (less)', function() { - it('Issue 389', function() { - this.comb.configure({ 'unitless-zero': true }); - this.shouldBeEqual('issue-389.less'); - }); -}); diff --git a/test/options/unitless-zero/issue-394.css b/test/options/unitless-zero/process/css/issue-394.css similarity index 100% rename from test/options/unitless-zero/issue-394.css rename to test/options/unitless-zero/process/css/issue-394.css diff --git a/test/options/unitless-zero/issue-394.expected.css b/test/options/unitless-zero/process/css/issue-394.expected.css similarity index 100% rename from test/options/unitless-zero/issue-394.expected.css rename to test/options/unitless-zero/process/css/issue-394.expected.css diff --git a/test/options/unitless-zero-less/issue-389.less b/test/options/unitless-zero/process/less/issue-389.less similarity index 100% rename from test/options/unitless-zero-less/issue-389.less rename to test/options/unitless-zero/process/less/issue-389.less diff --git a/test/options/unitless-zero/process/test.js b/test/options/unitless-zero/process/test.js index 5c879de3..1f2057aa 100644 --- a/test/options/unitless-zero/process/test.js +++ b/test/options/unitless-zero/process/test.js @@ -38,5 +38,17 @@ describe('Option `unitless-zero`, process', function() { assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); }); }); + + it('Issue 394', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.shouldBeEqual('issue-394.css', 'issue-394.expected.css'); + }); + }); + + describe('less', function() { + it('Issue 389', function() { + let test = new Test(this, {'unitless-zero': true}); + return test.shouldBeEqual('issue-389.less'); + }); }); }); From 1d6771f04114835352403ebd69effbf54f44b1c3 Mon Sep 17 00:00:00 2001 From: sodatea Date: Mon, 18 Jan 2016 14:13:16 +0800 Subject: [PATCH 115/184] [options] Reapply hotfix for #389 --- src/options/unitless-zero.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/options/unitless-zero.js b/src/options/unitless-zero.js index 0d5ce213..467db682 100644 --- a/src/options/unitless-zero.js +++ b/src/options/unitless-zero.js @@ -23,13 +23,13 @@ module.exports = { if (value.is('dimension')) { var unit = value.first('ident').content; - if (value.first('number').content[0] === '0' && + if (value.first('number').content === '0' && UNITS.indexOf(unit) !== -1) { value.removeChild(1); } } else if (value.is('percentage')) { var number = value.first('number').content; - if (number[0] === '0') { + if (number === '0') { value.type = 'number'; value.content = number; } @@ -56,7 +56,7 @@ module.exports = { } if (node.is('dimension') && - node.first('number').content[0] === '0' && + node.first('number').content === '0' && node.first('ident').content !== 'deg') { detected.push(false); return; @@ -65,7 +65,7 @@ module.exports = { // If we see a zero and previous node is not percentage // or dimension, then we have an option if (node.is('number') && - node.content[0] === '0' && + node.content === '0' && !parent.is('percentage') && !parent.is('dimension')) { detected.push(true); From 3e6e5a11d81d7dd7436517692bb21368886a3727 Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 13:07:46 +0800 Subject: [PATCH 116/184] [tests] Fix typo --- test/options/element-case/detect/test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/options/element-case/detect/test.js b/test/options/element-case/detect/test.js index 909eb18e..22cc8bbf 100644 --- a/test/options/element-case/detect/test.js +++ b/test/options/element-case/detect/test.js @@ -1,6 +1,6 @@ let Test = require('../../option_test'); -describe('Option `element-case`, process', function() { +describe('Option `element-case`, detect', function() { describe('css', function() { it('Should detect lowercase elements', function() { let test = new Test(this); @@ -57,4 +57,3 @@ describe('Option `element-case`, process', function() { }); }); }); - From 14a65b5bb2a1a3fae9162703c8d9cca8973ec433 Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 13:08:08 +0800 Subject: [PATCH 117/184] [options] Fix element-case detecting & processing --- src/options/element-case.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options/element-case.js b/src/options/element-case.js index 1f8622e1..3bd7a50c 100644 --- a/src/options/element-case.js +++ b/src/options/element-case.js @@ -37,7 +37,7 @@ let option = { ast.traverse((node) => { if (!node.is('selector') && !node.is('arguments')) return; - node.forEach('simpleSelector', (selector) => { + node.forEach('typeSelector', (selector) => { selector.forEach('ident', (ident) => { ident.content = value === 'lower' ? ident.content.toLowerCase() : @@ -58,7 +58,7 @@ let option = { ast.traverse((node) => { if (!node.is('selector') && !node.is('arguments')) return; - node.forEach('simpleSelector', (selector) => { + node.forEach('typeSelector', (selector) => { selector.forEach('ident', (ident) => { if (ident.content.match(/^[a-z]+$/)) { detected.push('lower'); From e4c43d97f721eeb515db8c0f3bd5ded71330d7d6 Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 13:23:41 +0800 Subject: [PATCH 118/184] [options] Add placeholder detect functions for sort-order & sort-order-fallback --- src/options/sort-order-fallback.js | 4 +++- src/options/sort-order.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/options/sort-order-fallback.js b/src/options/sort-order-fallback.js index 80d9dc27..318094db 100644 --- a/src/options/sort-order-fallback.js +++ b/src/options/sort-order-fallback.js @@ -7,5 +7,7 @@ module.exports = { accepts: {string: /^abc$/}, - process: function() {} + process: function() {}, + + detect: () => [] }; diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 77d9e183..f5f3ab98 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -144,7 +144,6 @@ module.exports = { // (e. g. `$include breakpoint`), and the rest — `$include`. let mixinName; - console.log(node); if (node.syntax === 'less') { // `node.first()` is class and `node.first().first()` is ident. mixinName = node.first().first().content; @@ -421,5 +420,7 @@ module.exports = { // they were in original array: return a.i - b.i; }); - } + }, + + detect: () => [] }; From 5be0e4f7cfc4cb4ff13d1578406b5fc3ecb74945 Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 13:24:12 +0800 Subject: [PATCH 119/184] [options] Fix remove-empty-rulesets --- src/options/remove-empty-rulesets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index a7b7f76b..923d86e8 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -10,7 +10,7 @@ module.exports = (function() { stylesheet.forEach('ruleset', function(ruleset, i) { var block = ruleset.first('block'); processNode(block); - if (isEmptyBlock(block)) stylesheet.remove(i); + if (isEmptyBlock(block)) stylesheet.removeChild(i); }); } @@ -27,7 +27,7 @@ module.exports = (function() { while (i-- > 0) { if (node.get(i).is('space') && node.get(i + 1).is('space')) { node.get(i).content += node.get(i + 1).content; - node.remove(i + 1); + node.removeChild(i + 1); } } } From 8aaa5d1b52a9386f7c4e2930a6e9afe5d2973d5c Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 15:20:28 +0800 Subject: [PATCH 120/184] [tools] Fix travis workflow by using npm link for dev branches --- .travis.yml | 9 +++++++-- package.json | 1 - scripts/beforeinstall.sh | 6 ++++++ scripts/postinstall.sh | 1 - 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100755 scripts/beforeinstall.sh delete mode 100755 scripts/postinstall.sh diff --git a/.travis.yml b/.travis.yml index 650c6dfb..07b89d56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,15 @@ language: node_js node_js: - - "iojs" - "0.10" - - "0.11" - "0.12" + - "1.8" + - "2.5" + - "3.3" + - "4.2" + +before_install: + - ./scripts/beforeinstall.sh matrix: allow_failures: diff --git a/package.json b/package.json index cac71a85..8a6c2693 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", - "postinstall": "./scripts/postinstall.sh", "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } diff --git a/scripts/beforeinstall.sh b/scripts/beforeinstall.sh new file mode 100755 index 00000000..4597a2f8 --- /dev/null +++ b/scripts/beforeinstall.sh @@ -0,0 +1,6 @@ +git clone https://github.com/tonyganch/gonzales-pe.git +cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. +git clone https://github.com/csscomb/core.git csscomb-core +cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. +npm link gonzales-pe +npm link csscomb-core diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh deleted file mode 100755 index 3c932c0f..00000000 --- a/scripts/postinstall.sh +++ /dev/null @@ -1 +0,0 @@ -cd ./node_modules/csscomb-core && npm i && npm run build && cd - From 112d7b6e0a8d1a23be44ccd025e388ffa7447f7d Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 19 Jan 2016 15:34:00 +0800 Subject: [PATCH 121/184] [tools] Use a fork of gonzales-pe for dev purpose --- scripts/beforeinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/beforeinstall.sh b/scripts/beforeinstall.sh index 4597a2f8..a8f0235f 100755 --- a/scripts/beforeinstall.sh +++ b/scripts/beforeinstall.sh @@ -1,4 +1,4 @@ -git clone https://github.com/tonyganch/gonzales-pe.git +git clone https://github.com/sodatea/gonzales-pe.git cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. git clone https://github.com/csscomb/core.git csscomb-core cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. From 3176badc8e3bc929b9063cb1b8ac122760a74ce9 Mon Sep 17 00:00:00 2001 From: sodatea Date: Tue, 26 Jan 2016 00:17:46 +0800 Subject: [PATCH 122/184] [docs] Extend the example to avoid misleading --- doc/options.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/options.md b/doc/options.md index f4c64efe..c480e420 100644 --- a/doc/options.md +++ b/doc/options.md @@ -41,7 +41,7 @@ Following options are ignored while processing `*.sass` files: ## always-semicolon -Whether to add a semicolon after the last value/mixin. +Whether to add a semicolon after the *last* value/mixin. Acceptable value: `true`. @@ -49,10 +49,10 @@ Example: `{ "always-semicolon": true }` ```css /* before */ -a { color: red } +a { color: red; text-decoration: underline } /* after */ -a { color: red; } +a { color: red; text-decoration: underline; } ``` ### always-semicolon vs. preprocessors From e38930eecba1307e4ab9762687bdcab03b0e6d40 Mon Sep 17 00:00:00 2001 From: sodatea Date: Sat, 30 Jan 2016 23:24:46 +0800 Subject: [PATCH 123/184] [options] sort-order: properties of the same name should stay in the same order --- src/options/sort-order.js | 4 ++-- .../sort-order-fallback/process/css/same-property.css | 4 ++++ test/options/sort-order-fallback/process/test.js | 10 +++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 test/options/sort-order-fallback/process/css/same-property.css diff --git a/src/options/sort-order.js b/src/options/sort-order.js index f5f3ab98..ef49b9e5 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -385,13 +385,13 @@ module.exports = { if (a[2] !== b[2]) { // If unprefixed parts are different (i.e. `border` and // `color`), compare them: - return a[2] < b[2] ? -1 : 1; + return a[2] <= b[2] ? -1 : 1; } else { // If unprefixed parts are identical (i.e. `border` in // `-moz-border` and `-o-border`), compare prefixes. // They should go in the same order they are set // in `prefixes` array. - return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1; + return prefixes.indexOf(a[1]) <= prefixes.indexOf(b[1]) ? -1 : 1; } }, diff --git a/test/options/sort-order-fallback/process/css/same-property.css b/test/options/sort-order-fallback/process/css/same-property.css new file mode 100644 index 00000000..8af2a139 --- /dev/null +++ b/test/options/sort-order-fallback/process/css/same-property.css @@ -0,0 +1,4 @@ +button { + outline: 1px dotted; + outline: 5px auto -webkit-focus-ring-color; +} diff --git a/test/options/sort-order-fallback/process/test.js b/test/options/sort-order-fallback/process/test.js index 0514b387..9127d943 100644 --- a/test/options/sort-order-fallback/process/test.js +++ b/test/options/sort-order-fallback/process/test.js @@ -24,6 +24,15 @@ describe('Option `sort-order-fallback`, process', function() { return test.shouldBeEqual('test.css', 'test-2.expected.css'); }); + it('Properties of the same name should stay in the same order', function() { + let config = { + 'sort-order': ['...'], + 'sort-order-fallback': 'abc' + }; + let test = new Test(this, config); + return test.shouldBeEqual('same-property.css'); + }); + it('Should leave leftovers as is if `sort-order-fallback` is not set', function() { let config = { 'sort-order': ['top', 'left'] @@ -33,4 +42,3 @@ describe('Option `sort-order-fallback`, process', function() { }); }); }); - From 2833797e4b8848f6a71ee651dc43495068e7003a Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 3 Feb 2016 01:01:24 +0800 Subject: [PATCH 124/184] [tools] Fix npm install issues This is done by moving beforeinstall.sh from .travis.yml to the preinstall field of package.json --- .travis.yml | 12 +++++------- package.json | 1 + scripts/{beforeinstall.sh => preinstall.sh} | 0 3 files changed, 6 insertions(+), 7 deletions(-) rename scripts/{beforeinstall.sh => preinstall.sh} (100%) diff --git a/.travis.yml b/.travis.yml index 07b89d56..5b8cacce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,11 @@ language: node_js node_js: - "0.10" - "0.12" - - "1.8" - - "2.5" - - "3.3" - - "4.2" - -before_install: - - ./scripts/beforeinstall.sh + - "1" + - "2" + - "3" + - "4" + - "5" matrix: allow_failures: diff --git a/package.json b/package.json index 8a6c2693..cee4988f 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "csscomb": "./bin/csscomb" }, "scripts": { + "preinstall": "./scripts/preinstall.sh", "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", "test": "./scripts/build.sh && ./scripts/test.sh", diff --git a/scripts/beforeinstall.sh b/scripts/preinstall.sh similarity index 100% rename from scripts/beforeinstall.sh rename to scripts/preinstall.sh From 9fc42c20ddce5be8213c029a1613ce7b43fa8a33 Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 3 Feb 2016 22:39:28 +0800 Subject: [PATCH 125/184] [tools] Add csscomb-core & .idea to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c7d5d95c..4df8dcc3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ lib-cov node_modules test/test-coverage.html +csscomb-core/ + .idea *.iml From 3f1db8e4e7e0f2e126ace8c1ad43f9dc5f8add54 Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 3 Feb 2016 22:40:04 +0800 Subject: [PATCH 126/184] [tools] Simplify the preinstall script --- scripts/preinstall.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/preinstall.sh b/scripts/preinstall.sh index a8f0235f..4e01e9d2 100755 --- a/scripts/preinstall.sh +++ b/scripts/preinstall.sh @@ -1,6 +1,3 @@ -git clone https://github.com/sodatea/gonzales-pe.git -cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. git clone https://github.com/csscomb/core.git csscomb-core -cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. -npm link gonzales-pe +cd csscomb-core && git checkout dev && npm i && npm run build && npm link && cd .. npm link csscomb-core From dcafc228d9c68e1d8d4ff00ca50ec9d4ce9c0e6c Mon Sep 17 00:00:00 2001 From: sodatea Date: Wed, 3 Feb 2016 23:32:43 +0800 Subject: [PATCH 127/184] [deps] Do not manually share the same GPE version with csscomb-core It is no longer necessary in npm@3 --- package.json | 4 ++-- src/csscomb.js | 2 +- src/gonzales.js | 5 ----- src/options/always-semicolon.js | 2 +- src/options/eof-newline.js | 2 +- src/options/sort-order.js | 2 +- src/options/space-after-colon.js | 2 +- src/options/space-after-combinator.js | 2 +- src/options/space-after-opening-brace.js | 2 +- src/options/space-after-selector-delimiter.js | 2 +- src/options/space-before-closing-brace.js | 2 +- src/options/space-before-colon.js | 2 +- src/options/space-before-combinator.js | 2 +- src/options/space-before-opening-brace.js | 2 +- src/options/space-before-selector-delimiter.js | 2 +- src/options/space-between-declarations.js | 2 +- src/options/vendor-prefix-align.js | 2 +- 17 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 src/gonzales.js diff --git a/package.json b/package.json index cee4988f..4fa26ecc 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "glob": "latest", "minimist": "1.1.x", - "csscomb-core": "csscomb/core#build-dev", + "csscomb-core": "csscomb/core#dev", + "gonzales-pe": "sodatea/gonzales-pe#dev", "vow": "0.4.4" }, "devDependencies": { @@ -60,7 +61,6 @@ "csscomb": "./bin/csscomb" }, "scripts": { - "preinstall": "./scripts/preinstall.sh", "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", "test": "./scripts/build.sh && ./scripts/test.sh", diff --git a/src/csscomb.js b/src/csscomb.js index 69cd25d3..e80b8e2f 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -1,7 +1,7 @@ 'use strict'; let Comb = require('csscomb-core'); -let gonzales = require('./gonzales'); +let gonzales = require('gonzales-pe'); let fs = require('fs'); let format = require('./format'); let path = require('path'); diff --git a/src/gonzales.js b/src/gonzales.js deleted file mode 100644 index 4398d483..00000000 --- a/src/gonzales.js +++ /dev/null @@ -1,5 +0,0 @@ -// jscs:disable maximumLineLength - -'use strict'; - -module.exports = require('../node_modules/csscomb-core/node_modules/gonzales-pe'); diff --git a/src/options/always-semicolon.js b/src/options/always-semicolon.js index f719a38e..32628216 100644 --- a/src/options/always-semicolon.js +++ b/src/options/always-semicolon.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); let option = { /** diff --git a/src/options/eof-newline.js b/src/options/eof-newline.js index 70442729..29196cd4 100644 --- a/src/options/eof-newline.js +++ b/src/options/eof-newline.js @@ -1,6 +1,6 @@ 'use strict'; -let gonzales = require('../gonzales'); +let gonzales = require('gonzales-pe'); let option = { /** diff --git a/src/options/sort-order.js b/src/options/sort-order.js index ef49b9e5..731f30b5 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { get name() { diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index 42767462..e962d526 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-after-colon', diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index e999d4fe..a951b26a 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-after-combinator', diff --git a/src/options/space-after-opening-brace.js b/src/options/space-after-opening-brace.js index a5b3fdf6..ed04b1f3 100644 --- a/src/options/space-after-opening-brace.js +++ b/src/options/space-after-opening-brace.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-after-opening-brace', diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index bbb82574..636f7606 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-after-selector-delimiter', diff --git a/src/options/space-before-closing-brace.js b/src/options/space-before-closing-brace.js index dccfe5f1..1cd276e2 100644 --- a/src/options/space-before-closing-brace.js +++ b/src/options/space-before-closing-brace.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = (function() { var valueFromSettings; diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index fc1064cf..a62bb25f 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-before-colon', diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 3baceb35..2a91c098 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-before-combinator', diff --git a/src/options/space-before-opening-brace.js b/src/options/space-before-opening-brace.js index d43b33e4..e3eca162 100644 --- a/src/options/space-before-opening-brace.js +++ b/src/options/space-before-opening-brace.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = (function() { return { diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index eb960d1f..a116c6af 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = { name: 'space-before-selector-delimiter', diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index d83ad072..91e970e4 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = (function() { function getDeclarationEnd(node, i) { diff --git a/src/options/vendor-prefix-align.js b/src/options/vendor-prefix-align.js index a1d5e0f1..a816340e 100644 --- a/src/options/vendor-prefix-align.js +++ b/src/options/vendor-prefix-align.js @@ -1,6 +1,6 @@ 'use strict'; -var gonzales = require('../gonzales'); +var gonzales = require('gonzales-pe'); module.exports = (function() { // Vendor prefixes list: From 11898864d5fc6bc79e5ab76f8ea46d224634c434 Mon Sep 17 00:00:00 2001 From: sodatea Date: Sun, 14 Feb 2016 17:48:31 +0800 Subject: [PATCH 128/184] [cli] Output a more reasonable error message when the configuration file is not valid JSON, fixes #326 --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 904b003e..36aee135 100644 --- a/src/cli.js +++ b/src/cli.js @@ -117,7 +117,7 @@ function getConfig(options) { } if (!config) { - let message = `Configuration file ${configPath} was not found.`; + let message = `Error parsing configuration file ${configPath}.`; process.stderr.write(format(message)); process.exit(1); } From e06678e4e8544bb7c479eaa08f03c09f23846f60 Mon Sep 17 00:00:00 2001 From: Richa Avasthi Date: Sun, 5 Jul 2015 08:49:47 +0100 Subject: [PATCH 129/184] Add `lines-between-rulesets` option. Why: Allow users to specify a new option, `lines-between-rulesets`, to separate rulesets and @rules from each other by the specified number of newlines. This change addresses the need by: Inserting newlines between rulesets and @rules for all syntaxes. Intelligently handles: * When the ruleset is the first in the file, don't insert newlines before it. * When there are comments in front of the ruleset; insert the newlines before the comments so that the ruleset and the comments stay together. --- doc/options.md | 55 +++- src/options/lines-between-rulesets.js | 250 ++++++++++++++++++ test/core/use/test.js | 1 + .../css/2-lines-between-rulesets.expected.css | 7 + .../process/css/lines-between-rulesets.css | 1 + .../css/lines-between-rulesets.expected.css | 5 + .../2-lines-between-rulesets.expected.less | 40 +++ .../less/lines-between-rulesets.expected.less | 35 +++ .../process/less/lines-between-rulesets.less | 28 ++ .../2-lines-between-rulesets.expected.sass | 32 +++ .../sass/lines-between-rulesets.expected.sass | 27 ++ .../process/sass/lines-between-rulesets.sass | 22 ++ .../2-lines-between-rulesets.expected.scss | 40 +++ .../scss/lines-between-rulesets.expected.scss | 35 +++ .../process/scss/lines-between-rulesets.scss | 28 ++ .../lines-between-rulesets/process/test.js | 93 +++++++ 16 files changed, 696 insertions(+), 3 deletions(-) create mode 100644 src/options/lines-between-rulesets.js create mode 100644 test/options/lines-between-rulesets/process/css/2-lines-between-rulesets.expected.css create mode 100644 test/options/lines-between-rulesets/process/css/lines-between-rulesets.css create mode 100644 test/options/lines-between-rulesets/process/css/lines-between-rulesets.expected.css create mode 100644 test/options/lines-between-rulesets/process/less/2-lines-between-rulesets.expected.less create mode 100644 test/options/lines-between-rulesets/process/less/lines-between-rulesets.expected.less create mode 100644 test/options/lines-between-rulesets/process/less/lines-between-rulesets.less create mode 100644 test/options/lines-between-rulesets/process/sass/2-lines-between-rulesets.expected.sass create mode 100644 test/options/lines-between-rulesets/process/sass/lines-between-rulesets.expected.sass create mode 100644 test/options/lines-between-rulesets/process/sass/lines-between-rulesets.sass create mode 100644 test/options/lines-between-rulesets/process/scss/2-lines-between-rulesets.expected.scss create mode 100644 test/options/lines-between-rulesets/process/scss/lines-between-rulesets.expected.scss create mode 100644 test/options/lines-between-rulesets/process/scss/lines-between-rulesets.scss create mode 100644 test/options/lines-between-rulesets/process/test.js diff --git a/doc/options.md b/doc/options.md index c480e420..959e9291 100644 --- a/doc/options.md +++ b/doc/options.md @@ -1,7 +1,7 @@ # Configuration options There are a number of options you can use, all of them are switched off by -default. +default. Here is a full list in the same order they are applied while processing css: - [always-semicolon](#always-semicolon) @@ -29,6 +29,7 @@ Here is a full list in the same order they are applied while processing css: - [unitless-zero](#unitless-zero) - [tab-size](#tab-size) - [vendor-prefix-align](#vendor-prefix-align) +- [lines-between-rulesets](#lines-between-rulesets) Following options are ignored while processing `*.sass` files: @@ -397,8 +398,8 @@ everything would go into five groups: variables, then group with `position`, the ## sort-order-fallback Apply a special sort order for properties that are not specified in `sort-order` -list. -Works great with [leftovers](#sort-order-vs-leftovers). +list. +Works great with [leftovers](#sort-order-vs-leftovers). **Note:** This option is applied only if [sort order](#sort-order) list is provided. @@ -905,6 +906,54 @@ a } ``` +## lines-between-rulesets + +Number of line breaks between rulesets or @rules. + +Acceptable values: + +* `{Number}` — number of newlines; + +Example: `{ "lines-between-rulesets": 1}` + +```scss +// Before: +.foo { + @include border-radius(5px); + background: red; + .baz { + .test { + height: 50px; + } + } +}.bar { + border: 1px solid red; + @media (min-width: 500px) { + width: 50px; + } +} + +// After: +.foo { + @include border-radius(5px); + background: red; + + .baz { + .test { + height: 50px; + } + } +} + +.bar { + border: 1px solid red; + + @media (min-width: 500px) { + width: 50px; + } +} +``` + ## verbose Whether to use `--verbose` option in CLI. diff --git a/src/options/lines-between-rulesets.js b/src/options/lines-between-rulesets.js new file mode 100644 index 00000000..15d99203 --- /dev/null +++ b/src/options/lines-between-rulesets.js @@ -0,0 +1,250 @@ +'use strict'; + +let gonzales = require('gonzales-pe'); + +let option = { + newLinesString: '', + newLinesNode: null, + + /** + * Option's name as it's used in config. + * @type {String} + */ + get name() { + return 'lines-between-rulesets'; + }, + + /** + * Name of option that must run after this option. + * @type {String} + */ + get runBefore() { + return 'block-indent'; + }, + + /** + * List of syntaxes that are supported by this option. + * @type {Array} + */ + get syntax() { + return ['css', 'less', 'sass', 'scss']; + }, + + /** + * Types of values this option accepts in config. + * @type {Object} + */ + get accepts() { + return { + number: true + }; + }, + + /** + * @param {number} value + * @returns {number} + */ + /* + ** Still need to override, as the core implementation of setValue doesn't + ** pass numbers through, but creates a string of spaces of the same length. + */ + setValue(value) { + let valueType = typeof value; + + if (valueType !== 'number') { + throw new Error('Value must be a number.'); + } + + return value; + }, + + buildSpacing(syntax) { + let spacing = ''; + let numNewLines = 0; + let newLinesOffset = 1; + + if (syntax === 'sass') { + newLinesOffset = 0; + } + + numNewLines = Math.round(this.value) + newLinesOffset; + + for (var i = 0; i < numNewLines; i++) { + spacing += '\n'; + } + + return spacing; + }, + + /** + * Processes ast and fixes found code style errors. + * @param {Node} ast + */ + process(ast) { + this.newLinesString = this.buildSpacing(ast.syntax); + this.newLinesNode = gonzales.createNode({ + type: 'space', + content: this.newLinesString + }); + this.processBlock(ast); + }, + + processBlock(x) { + if (x.is('stylesheet')) { + // Check all @rules + this.processAtRules(x); + + // Check all rulesets + this.processRuleSets(x); + } + + x.forEach((node) => { + if (!node.is('block')) { + return this.processBlock(node); + } + + // Check all @rules + this.processAtRules(node); + + // Check all rulesets + this.processRuleSets(node); + + this.processBlock(node); + }); + }, + + processAtRules(node) { + node.forEach('atrule', (atRuleNode, index) => { + this.insertNewlines(node, index); + }); + }, + + processRuleSets(node) { + node.forEach('ruleset', (ruleSetNode, index) => { + this.insertNewlines(node, index); + }); + }, + + isComment(node) { + if (!node) { + return false; + } + return (node.is('singlelineComment') || node.is('multilineComment')); + }, + + isNewline(node) { + if (!node) { + return false; + } + return (node.content === '\n'); + }, + + prevLineIsComment(parent, index) { + let indexThreshold = 2; + let prevChild; + let prevMinusOneChild; + let prevMinusTwoChild; + let parentSyntax = parent ? parent.syntax : null; + + // Sass is troublesome because newlines are counted as separate nodes + if (parentSyntax === 'sass') { + indexThreshold = 3; + } + + if (!parent || index < indexThreshold) { + return false; + } + + prevChild = parent.get(index - 1); + prevMinusOneChild = parent.get(index - 2); + + if (parentSyntax === 'sass') { + prevMinusTwoChild = parent.get(index - 3); + return ( + this.isComment(prevMinusTwoChild) && + this.isNewline(prevMinusOneChild) && + prevChild.is('space') + ); + } + + return (this.isComment(prevMinusOneChild) && prevChild.is('space')); + }, + + /* + ** Find the latest previous child that isn't a comment, and return its index. + */ + findLatestNonCommentNode(parent, index) { + let prevChild; + let lastNonCommentIndex = -1; + let currentIndex = index; + let jumpSize = 2; + + if (parent.syntax === 'sass') { + jumpSize = 3; + } + + while (currentIndex >= 0) { + if (this.prevLineIsComment(parent, currentIndex)) { + currentIndex -= jumpSize; + continue; + } + + prevChild = parent.get(currentIndex - 1); + + if (!this.isComment(prevChild)) { + lastNonCommentIndex = currentIndex - 1; + break; + } + + currentIndex--; + } + + return lastNonCommentIndex; + }, + + insertNewlinesAsString(node) { + let content = node.content; + let lastNewline = content.lastIndexOf('\n'); + let newContent; + + if (lastNewline > -1) { + content = content.substring(lastNewline + 1); + } + + newContent = this.newLinesString + content; + node.content = newContent; + }, + + insertNewlinesAsNode(node) { + node.insert(node.length, this.newLinesNode); + }, + + insertNewlines(node, index) { + let prevChild = node.get(index - 1); + let shouldInsert = false; + + // Check for previous nodes that are not a space + // Do not insert if the ruleset is the first item + for (var i = 0; i < index; i++) { + if (!node.get(i).is('space')) { + shouldInsert = true; + break; + } + } + + if (prevChild && shouldInsert) { + if (this.prevLineIsComment(node, index) || this.isComment(prevChild)) { + let lastNonCommentIndex = this.findLatestNonCommentNode(node, index); + prevChild = node.get(lastNonCommentIndex); + } + + if (prevChild.is('space')) { + this.insertNewlinesAsString(prevChild); + } else { + this.insertNewlinesAsNode(prevChild); + } + } + } +}; + +module.exports = option; diff --git a/test/core/use/test.js b/test/core/use/test.js index 37ad23c2..78c85fac 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -9,6 +9,7 @@ describe.skip('.use()', function() { }); var expected = [ 'always-semicolon', + 'lines-between-rulesets', 'remove-empty-rulesets', 'color-case', 'color-shorthand', diff --git a/test/options/lines-between-rulesets/process/css/2-lines-between-rulesets.expected.css b/test/options/lines-between-rulesets/process/css/2-lines-between-rulesets.expected.css new file mode 100644 index 00000000..58bbdff5 --- /dev/null +++ b/test/options/lines-between-rulesets/process/css/2-lines-between-rulesets.expected.css @@ -0,0 +1,7 @@ +.foo {background: red;} + + +/*comment*/.bar{border: 1px solid red;} + + +.baz{color: #fff;} diff --git a/test/options/lines-between-rulesets/process/css/lines-between-rulesets.css b/test/options/lines-between-rulesets/process/css/lines-between-rulesets.css new file mode 100644 index 00000000..30f35c39 --- /dev/null +++ b/test/options/lines-between-rulesets/process/css/lines-between-rulesets.css @@ -0,0 +1 @@ +.foo {background: red;}/*comment*/.bar{border: 1px solid red;}.baz{color: #fff;} diff --git a/test/options/lines-between-rulesets/process/css/lines-between-rulesets.expected.css b/test/options/lines-between-rulesets/process/css/lines-between-rulesets.expected.css new file mode 100644 index 00000000..ad0651d5 --- /dev/null +++ b/test/options/lines-between-rulesets/process/css/lines-between-rulesets.expected.css @@ -0,0 +1,5 @@ +.foo {background: red;} + +/*comment*/.bar{border: 1px solid red;} + +.baz{color: #fff;} diff --git a/test/options/lines-between-rulesets/process/less/2-lines-between-rulesets.expected.less b/test/options/lines-between-rulesets/process/less/2-lines-between-rulesets.expected.less new file mode 100644 index 00000000..7e8b5e9e --- /dev/null +++ b/test/options/lines-between-rulesets/process/less/2-lines-between-rulesets.expected.less @@ -0,0 +1,40 @@ +.foo { + .border-radius(5px); + background: red; + + + /* comment */ + .omg { + .test { + height: 50px; + } + } +} + + +.bar { + border: 1px solid red; + + + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +} + + +.baz { + @grey: #ccc; + + + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: @grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/less/lines-between-rulesets.expected.less b/test/options/lines-between-rulesets/process/less/lines-between-rulesets.expected.less new file mode 100644 index 00000000..ef3a7ef3 --- /dev/null +++ b/test/options/lines-between-rulesets/process/less/lines-between-rulesets.expected.less @@ -0,0 +1,35 @@ +.foo { + .border-radius(5px); + background: red; + + /* comment */ + .omg { + .test { + height: 50px; + } + } +} + +.bar { + border: 1px solid red; + + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +} + +.baz { + @grey: #ccc; + + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: @grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/less/lines-between-rulesets.less b/test/options/lines-between-rulesets/process/less/lines-between-rulesets.less new file mode 100644 index 00000000..544895b5 --- /dev/null +++ b/test/options/lines-between-rulesets/process/less/lines-between-rulesets.less @@ -0,0 +1,28 @@ +.foo { + .border-radius(5px); + background: red; + /* comment */ + .omg { + .test { + height: 50px; + } + } +}.bar { + border: 1px solid red; + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +}.baz { + @grey: #ccc; + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: @grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/sass/2-lines-between-rulesets.expected.sass b/test/options/lines-between-rulesets/process/sass/2-lines-between-rulesets.expected.sass new file mode 100644 index 00000000..b35b9173 --- /dev/null +++ b/test/options/lines-between-rulesets/process/sass/2-lines-between-rulesets.expected.sass @@ -0,0 +1,32 @@ +.foo + +border-radius(5px) + background: red + + + // comment + .omg + .test + height: 50px + + +.bar + border: 1px solid red + + + /* + * another comment + * spanning multiple lines + */ + @media (min-width: 500px) + width: 50px + + +.baz + $grey: #ccc + + + // a single-line comment + // another single-line comment + .wtf + @media only screen + background-color: $grey diff --git a/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.expected.sass b/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.expected.sass new file mode 100644 index 00000000..31a2a3d8 --- /dev/null +++ b/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.expected.sass @@ -0,0 +1,27 @@ +.foo + +border-radius(5px) + background: red + + // comment + .omg + .test + height: 50px + +.bar + border: 1px solid red + + /* + * another comment + * spanning multiple lines + */ + @media (min-width: 500px) + width: 50px + +.baz + $grey: #ccc + + // a single-line comment + // another single-line comment + .wtf + @media only screen + background-color: $grey diff --git a/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.sass b/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.sass new file mode 100644 index 00000000..10ee7156 --- /dev/null +++ b/test/options/lines-between-rulesets/process/sass/lines-between-rulesets.sass @@ -0,0 +1,22 @@ +.foo + +border-radius(5px) + background: red + // comment + .omg + .test + height: 50px +.bar + border: 1px solid red + /* + * another comment + * spanning multiple lines + */ + @media (min-width: 500px) + width: 50px +.baz + $grey: #ccc + // a single-line comment + // another single-line comment + .wtf + @media only screen + background-color: $grey diff --git a/test/options/lines-between-rulesets/process/scss/2-lines-between-rulesets.expected.scss b/test/options/lines-between-rulesets/process/scss/2-lines-between-rulesets.expected.scss new file mode 100644 index 00000000..386fbb18 --- /dev/null +++ b/test/options/lines-between-rulesets/process/scss/2-lines-between-rulesets.expected.scss @@ -0,0 +1,40 @@ +.foo { + @include border-radius(5px); + background: red; + + + /* comment */ + .omg { + .test { + height: 50px; + } + } +} + + +.bar { + border: 1px solid red; + + + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +} + + +.baz { + $grey: #ccc; + + + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: $grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.expected.scss b/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.expected.scss new file mode 100644 index 00000000..db92922e --- /dev/null +++ b/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.expected.scss @@ -0,0 +1,35 @@ +.foo { + @include border-radius(5px); + background: red; + + /* comment */ + .omg { + .test { + height: 50px; + } + } +} + +.bar { + border: 1px solid red; + + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +} + +.baz { + $grey: #ccc; + + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: $grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.scss b/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.scss new file mode 100644 index 00000000..efa5b90f --- /dev/null +++ b/test/options/lines-between-rulesets/process/scss/lines-between-rulesets.scss @@ -0,0 +1,28 @@ +.foo { + @include border-radius(5px); + background: red; + /* comment */ + .omg { + .test { + height: 50px; + } + } +}.bar { + border: 1px solid red; + /* + ** another comment + ** spanning multiple lines + */ + @media (min-width: 500px) { + width: 50px; + } +}.baz { + $grey: #ccc; + // a single-line comment + // another single-line comment + .wtf { + @media only screen { + background-color: $grey; + } + } +} diff --git a/test/options/lines-between-rulesets/process/test.js b/test/options/lines-between-rulesets/process/test.js new file mode 100644 index 00000000..b6f935ca --- /dev/null +++ b/test/options/lines-between-rulesets/process/test.js @@ -0,0 +1,93 @@ +'use strict'; + +let Test = require('../../option_test'); + +describe('Option `lines-between-rulesets`, process', function() { + describe('css', function() { + it('Numeric value => should insert 1 newline between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 1 }); + return test.shouldBeEqual('lines-between-rulesets.css', 'lines-between-rulesets.expected.css'); + }); + + it('Numeric value => should insert multiple newlines between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 2 }); + return test.shouldBeEqual('lines-between-rulesets.css', '2-lines-between-rulesets.expected.css'); + }); + + it('Invalid string value => should should not change anything', function() { + let test = new Test(this, { 'lines-between-rulesets': '\n' }); + return test.shouldBeEqual('lines-between-rulesets.css'); + }); + + it('Float number value => should be rounded', function() { + let test = new Test(this, { 'lines-between-rulesets': 0.5 }); + return test.shouldBeEqual('lines-between-rulesets.css', 'lines-between-rulesets.expected.css'); + }); + }); + + describe('less', function() { + it('Numeric value => should insert 1 newline between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 1 }); + return test.shouldBeEqual('lines-between-rulesets.less', 'lines-between-rulesets.expected.less'); + }); + + it('Numeric value => should insert multiple newlines between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 2 }); + return test.shouldBeEqual('lines-between-rulesets.less', '2-lines-between-rulesets.expected.less'); + }); + + it('Invalid string value => should should not change anything', function() { + let test = new Test(this, { 'lines-between-rulesets': '\n' }); + return test.shouldBeEqual('lines-between-rulesets.less'); + }); + + it('Float number value => should be rounded', function() { + let test = new Test(this, { 'lines-between-rulesets': 0.5 }); + return test.shouldBeEqual('lines-between-rulesets.less', 'lines-between-rulesets.expected.less'); + }); + }); + + describe('scss', function() { + it('Numeric value => should insert 1 newline between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 1 }); + return test.shouldBeEqual('lines-between-rulesets.scss', 'lines-between-rulesets.expected.scss'); + }); + + it('Numeric value => should insert multiple newlines between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 2 }); + return test.shouldBeEqual('lines-between-rulesets.scss', '2-lines-between-rulesets.expected.scss'); + }); + + it('Invalid string value => should should not change anything', function() { + let test = new Test(this, { 'lines-between-rulesets': '\n' }); + return test.shouldBeEqual('lines-between-rulesets.scss'); + }); + + it('Float number value => should be rounded', function() { + let test = new Test(this, { 'lines-between-rulesets': 0.5 }); + return test.shouldBeEqual('lines-between-rulesets.scss', 'lines-between-rulesets.expected.scss'); + }); + }); + + describe('sass', function() { + it('Numeric value => should insert 1 newline between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 1 }); + return test.shouldBeEqual('lines-between-rulesets.sass', 'lines-between-rulesets.expected.sass'); + }); + + it('Numeric value => should insert multiple newlines between rulesets', function() { + let test = new Test(this, { 'lines-between-rulesets': 2 }); + return test.shouldBeEqual('lines-between-rulesets.sass', '2-lines-between-rulesets.expected.sass'); + }); + + it('Invalid string value => should should not change anything', function() { + let test = new Test(this, { 'lines-between-rulesets': '\n' }); + return test.shouldBeEqual('lines-between-rulesets.sass'); + }); + + it('Float number value => should be rounded', function() { + let test = new Test(this, { 'lines-between-rulesets': 0.5 }); + return test.shouldBeEqual('lines-between-rulesets.sass', 'lines-between-rulesets.expected.sass'); + }); + }); +}); From fba3bcd20aba58869d24056cfc34341ee89b6abb Mon Sep 17 00:00:00 2001 From: sodatea Date: Mon, 15 Feb 2016 11:25:37 +0800 Subject: [PATCH 130/184] [tools] Fix EditorConfig for markdown files, etc. --- .editorconfig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 5b42e032..b656be27 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,5 +2,16 @@ root = true [*] -indent_style = space +charset = utf-8 indent_size = 2 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[{.gitignore,.npmignore}] +end_of_line = +trim_trailing_whitespace = false + +[*.md] +trim_trailing_whitespace = false From 0d1f3929b581b21059e0ed0dd8396578bf4bf3c4 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 13:24:49 +0200 Subject: [PATCH 131/184] Revert "[tools] Simplify the preinstall script" This reverts commit a59652938ae073affc579166522b0d25f6950f68. --- scripts/preinstall.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/preinstall.sh b/scripts/preinstall.sh index 4e01e9d2..a8f0235f 100755 --- a/scripts/preinstall.sh +++ b/scripts/preinstall.sh @@ -1,3 +1,6 @@ +git clone https://github.com/sodatea/gonzales-pe.git +cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. git clone https://github.com/csscomb/core.git csscomb-core -cd csscomb-core && git checkout dev && npm i && npm run build && npm link && cd .. +cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. +npm link gonzales-pe npm link csscomb-core From d6628888d2952fe74acca9a90549b8ffc4e83d2a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 13:25:11 +0200 Subject: [PATCH 132/184] Revert "[tools] Add csscomb-core & .idea to .gitignore" This reverts commit 39a372078397b203fb22939e22ce1c251cc42857. --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4df8dcc3..c7d5d95c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,6 @@ lib-cov node_modules test/test-coverage.html -csscomb-core/ - .idea *.iml From a2665533a2d1f104bfa2582a38dbd317b4231504 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 13:26:04 +0200 Subject: [PATCH 133/184] Revert "[tools] Fix npm install issues" This reverts commit 8885c2164546a4b4fa5889ea7af0c17f86fe50d2. --- .travis.yml | 12 +++++++----- scripts/{preinstall.sh => beforeinstall.sh} | 0 2 files changed, 7 insertions(+), 5 deletions(-) rename scripts/{preinstall.sh => beforeinstall.sh} (100%) diff --git a/.travis.yml b/.travis.yml index 5b8cacce..07b89d56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,13 @@ language: node_js node_js: - "0.10" - "0.12" - - "1" - - "2" - - "3" - - "4" - - "5" + - "1.8" + - "2.5" + - "3.3" + - "4.2" + +before_install: + - ./scripts/beforeinstall.sh matrix: allow_failures: diff --git a/scripts/preinstall.sh b/scripts/beforeinstall.sh similarity index 100% rename from scripts/preinstall.sh rename to scripts/beforeinstall.sh From 87412dd6d74dff01e190203c83fd1f99ad091a34 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 13:27:06 +0200 Subject: [PATCH 134/184] Revert "[tools] Use a fork of gonzales-pe for dev purpose" This reverts commit e1368e115ce91d11462a2db8f7f81a0773fd99fb. --- scripts/beforeinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/beforeinstall.sh b/scripts/beforeinstall.sh index a8f0235f..4597a2f8 100755 --- a/scripts/beforeinstall.sh +++ b/scripts/beforeinstall.sh @@ -1,4 +1,4 @@ -git clone https://github.com/sodatea/gonzales-pe.git +git clone https://github.com/tonyganch/gonzales-pe.git cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. git clone https://github.com/csscomb/core.git csscomb-core cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. From bc9ca2c9092cdff433f0ad84242e530d3b067863 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 13:27:40 +0200 Subject: [PATCH 135/184] Revert "[tools] Fix travis workflow by using npm link for dev branches" This reverts commit 7a00e17a44cc0da5a58f9db1d69aa22f2535e439. --- .travis.yml | 9 ++------- package.json | 1 + scripts/beforeinstall.sh | 6 ------ scripts/postinstall.sh | 1 + 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100755 scripts/beforeinstall.sh create mode 100755 scripts/postinstall.sh diff --git a/.travis.yml b/.travis.yml index 07b89d56..650c6dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,10 @@ language: node_js node_js: + - "iojs" - "0.10" + - "0.11" - "0.12" - - "1.8" - - "2.5" - - "3.3" - - "4.2" - -before_install: - - ./scripts/beforeinstall.sh matrix: allow_failures: diff --git a/package.json b/package.json index 4fa26ecc..2a957686 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", + "postinstall": "./scripts/postinstall.sh", "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } diff --git a/scripts/beforeinstall.sh b/scripts/beforeinstall.sh deleted file mode 100755 index 4597a2f8..00000000 --- a/scripts/beforeinstall.sh +++ /dev/null @@ -1,6 +0,0 @@ -git clone https://github.com/tonyganch/gonzales-pe.git -cd gonzales-pe && git checkout dev && npm i && npm run build && npm link && cd .. -git clone https://github.com/csscomb/core.git csscomb-core -cd csscomb-core && git checkout dev && npm link gonzales-pe && npm i && npm run build && npm link && cd .. -npm link gonzales-pe -npm link csscomb-core diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh new file mode 100755 index 00000000..3c932c0f --- /dev/null +++ b/scripts/postinstall.sh @@ -0,0 +1 @@ +cd ./node_modules/csscomb-core && npm i && npm run build && cd - From 75e0e9e4fb20b60cb0be9663eb0de25427576646 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 11 Jul 2016 14:49:26 +0200 Subject: [PATCH 136/184] Fix tests --- src/options/sort-order.js | 12 +- test/core/configure/test.js | 47 +++---- test/core/core_test.js | 54 ++++++++ test/core/get-config/test.js | 30 ++-- test/core/less/test.js | 51 +++++-- test/core/scss/test.js | 131 ++++++++++++++---- test/core/use/test.js | 10 +- test/options/always-semicolon/process/test.js | 4 +- .../{css => sass}/issue-252.expected.sass | 0 .../process/{css => sass}/issue-252.sass | 0 test/options/integral/process/test.js | 10 +- .../sass/include-specified-1.expected.sass | 2 - .../sass/include-specified-2.expected.sass | 2 - .../process/sass/include.expected.sass | 2 +- .../sort-order/process/sass/include.sass | 2 +- .../process/sass/issue-332.expected.sass | 1 - .../process/scss/include.expected.scss | 2 +- .../sort-order/process/scss/include.scss | 2 +- .../process/scss/leftovers.expected.scss | 6 +- .../sort-order/process/scss/leftovers.scss | 6 +- test/options/sort-order/process/test.js | 16 +-- .../process/css/issue-381.css | 5 - .../space-before-combinator/process/test.js | 5 - 23 files changed, 279 insertions(+), 121 deletions(-) create mode 100644 test/core/core_test.js rename test/options/integral/process/{css => sass}/issue-252.expected.sass (100%) rename test/options/integral/process/{css => sass}/issue-252.sass (100%) delete mode 100644 test/options/space-before-combinator/process/css/issue-381.css diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 731f30b5..27a2198a 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -95,13 +95,14 @@ module.exports = { extendedNode.spacesBeforeDelimiter = this._getNodesByIndex(block, spacesBeforeDelimiter); - i += spacesBeforeDelimiter.length + 1; - node = block.get(i); + i += spacesBeforeDelimiter.length; // Spaces after delimiter. // If there is `;` right after the declaration, save it with the // declaration and mark it for removing from parent node: - if (node && node.is('declarationDelimiter')) { + if (block.get(i + 1) && block.get(i + 1).is('declarationDelimiter')) { + i += 1; + node = block.get(i); nodesToDelete.push(i); extendedNode.delim = node; @@ -259,6 +260,11 @@ module.exports = { let spacesBeforeDelimiter = currentNode.spacesBeforeDelimiter || []; let spacesAfterDelimiter = currentNode.spacesAfterDelimiter || []; + if (node.syntax === 'sass' && spacesBeforeNode.length) { + let space = spacesBeforeNode[0]; + space.content = space.content.replace(/\n/, ''); + } + spacesBeforeNode.reverse().map(this._removeEmptyLines); spacesBeforeDelimiter.reverse().map(this._removeEmptyLines); spacesAfterDelimiter.reverse().map(this._removeEmptyLines); diff --git a/test/core/configure/test.js b/test/core/configure/test.js index d116c0c3..4743df40 100644 --- a/test/core/configure/test.js +++ b/test/core/configure/test.js @@ -4,44 +4,43 @@ let Comb = process.env.TEST_COV ? let assert = require('assert'); describe('CSScomb#configure', function() { - it.skip('Passing no config to constructor should not configure anything', function() { + it('Passing no config to constructor should not configure anything', function() { let comb = new Comb(); assert.equal(undefined, comb._handlers); }); - it.skip('Passing valid config name to constructor should configure using correct config', function() { + it('Passing valid config name to constructor should configure using correct config', function() { let comb = new Comb('zen'); let input = 'a { color: tomato; top: 0; }'; let expected = 'a {top: 0; color: tomato; }'; - let output = comb.processString(input); - - assert.equal(expected, output); + return comb.processString(input).then(function(output) { + assert.equal(expected, output); + }); }); - it.skip('Passing config object to constructor should configure using that object', function() { - comb = new Comb({ 'always-semicolon': true }); - input = 'a { color: tomato }'; - expected = 'a { color: tomato; }'; - return comb.processString(input) - .then(function(actual) { - assert.equal(actual, expected); - }); + it('Passing config object to constructor should configure using that object', function() { + let comb = new Comb({ 'always-semicolon': true }); + let input = 'a { color: tomato }'; + let expected = 'a { color: tomato; }'; + return comb.processString(input).then(function(actual) { + assert.equal(actual, expected); + }); }); - it.skip('new Comb() should be chainable', function() { - input = 'a { color: tomato; top: 0; }'; - expected = 'a {top: 0; color: tomato; }'; - output = new Comb('zen').processString(input); - - assert.equal(expected, output); + it('new Comb() should be chainable', function() { + let input = 'a { color: tomato; top: 0; }'; + let expected = 'a {top: 0; color: tomato; }'; + return (new Comb('zen')).processString(input).then(output => { + assert.equal(expected, output); + }); }); - it.skip('configure() should be chainable', function() { - input = 'a { color: tomato }'; - expected = 'a { color: tomato; }'; - return new Comb().configure({ 'always-semicolon': true }) + it('configure() should be chainable', function() { + let input = 'a { color: tomato }'; + let expected = 'a { color: tomato; }'; + return (new Comb()).configure({ 'always-semicolon': true }) .processString(input) - .then(function(actual) { + .then(actual => { assert.equal(actual, expected); }); }); diff --git a/test/core/core_test.js b/test/core/core_test.js new file mode 100644 index 00000000..4384753d --- /dev/null +++ b/test/core/core_test.js @@ -0,0 +1,54 @@ +let assert = require('assert'); +let fs = require('fs'); +let path = require('path'); + +let Comb = require('../../lib/csscomb'); + +class CoreTest { + constructor(context, config) { + this.file = context.test.file; + this.syntax = context.test.parent.title; + + this.Comb = Comb; + this.comb = new Comb(); + if (config) this.comb.configure(config); + } + + useConfig(name) { + let config = Comb.getConfig(name); + this.comb.configure(config); + } + + getErrors(filename) { + let input = this.readFile(filename); + return this.comb.lintString(input, {syntax: this.syntax}); + } + + shouldBeEqual(inputFile, expectedFile) { + let input = this.readFile(inputFile); + let expected = expectedFile ? this.readFile(expectedFile) : input; + + return this.comb.processString(input, {syntax: this.syntax}) + .then(string => assert.equal(string, expected)); + } + + /** + * Detect options in a file and compare result with expected. + * File names should be relative to test suite's folder. + * @param {Array} options List of options that should be detected + * @param {String} input Name of template file + * @param {Object} expected Expected config with detected options + */ + shouldDetect(options, input, expected) { + let detectedConfig = Comb.detectInString(input, options); + assert.deepEqual(detectedConfig, expected); + } + + readFile(filename) { + let dirname = path.dirname(this.file); + let filePath = path.join(dirname, filename); + return fs.readFileSync(filePath, 'utf8'); + } +} + +module.exports = CoreTest; diff --git a/test/core/get-config/test.js b/test/core/get-config/test.js index 23ec2377..8db70a2f 100644 --- a/test/core/get-config/test.js +++ b/test/core/get-config/test.js @@ -1,51 +1,63 @@ var assert = require('assert'); +let Test = require('../core_test'); -describe.skip('csscomb methods', function() { +describe('csscomb methods', function() { it('getConfig()', function() { + let test = new Test(this); var config = require('../../../config/csscomb.json'); - assert.equal(this.Comb.getConfig(), config); + assert.equal(test.Comb.getConfig(), config); }); it('getConfig(number)', function() { + let test = new Test(this); + assert.throws(function() { - this.Comb.getConfig(16); + test.Comb.getConfig(16); }); }); it('getConfig(boolean)', function() { + let test = new Test(this); + assert.throws(function() { - this.Comb.getConfig(true); + test.Comb.getConfig(true); }); }); it('getConfig(empty string)', function() { + let test = new Test(this); var config = require('../../../config/csscomb.json'); - assert.equal(this.Comb.getConfig(''), config); + assert.equal(test.Comb.getConfig(''), config); }); it('getConfig(invalid string)', function() { + let test = new Test(this); + assert.throws(function() { - this.Comb.getConfig('nani'); + test.Comb.getConfig('nani'); }); }); it('getConfig(csscomb)', function() { + let test = new Test(this); var config = require('../../../config/csscomb.json'); - assert.equal(this.Comb.getConfig('csscomb'), config); + assert.equal(test.Comb.getConfig('csscomb'), config); }); it('getConfig(zen)', function() { + let test = new Test(this); var config = require('../../../config/zen.json'); - assert.equal(this.Comb.getConfig('zen'), config); + assert.equal(test.Comb.getConfig('zen'), config); }); it('getConfig(yandex)', function() { + let test = new Test(this); var config = require('../../../config/yandex.json'); - assert.equal(this.Comb.getConfig('yandex'), config); + assert.equal(test.Comb.getConfig('yandex'), config); }); }); diff --git a/test/core/less/test.js b/test/core/less/test.js index 06688ab3..72a54eb4 100644 --- a/test/core/less/test.js +++ b/test/core/less/test.js @@ -1,41 +1,66 @@ -describe.skip('LESS', function() { - beforeEach(function() { - this.comb.configure({}); - }); +let Test = require('../core_test'); +describe('less', function() { it('Should parse nested rules', function() { - this.shouldBeEqual('nested-rule.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('nested-rule.less'); }); it('Should parse operations', function() { - this.shouldBeEqual('operation.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('operation.less'); }); it('Should parse parent selector &', function() { - this.shouldBeEqual('parent-selector.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('parent-selector.less'); }); it('Should parse variables', function() { - this.shouldBeEqual('variable.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('variable.less'); }); it('Should parse interpolated variables inside selectors', function() { - this.shouldBeEqual('interpolated-variable-1.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('interpolated-variable-1.less'); }); it('Should parse interpolated variables inside values', function() { - this.shouldBeEqual('interpolated-variable-2.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('interpolated-variable-2.less'); }); it('Should parse @import', function() { - this.shouldBeEqual('import.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('import.less'); }); it('Should parse included mixins', function() { - this.shouldBeEqual('mixin.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('mixin.less'); }); it('Should parse nested @media', function() { - this.shouldBeEqual('nested-media.less'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('nested-media.less'); }); }); diff --git a/test/core/scss/test.js b/test/core/scss/test.js index eda05b50..66782d7f 100644 --- a/test/core/scss/test.js +++ b/test/core/scss/test.js @@ -1,106 +1,179 @@ -describe.skip('SCSS', function() { - beforeEach(function() { - this.comb.configure({}); - }); +let Test = require('../core_test'); +describe('scss', function() { it('Should parse nested rules', function() { - this.shouldBeEqual('nested-rule.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('nested-rule.scss'); }); it('Should parse parent selector &', function() { - this.shouldBeEqual('parent-selector.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('parent-selector.scss'); }); it('Should parse nested properties', function() { - this.shouldBeEqual('nested-property.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('nested-property.scss'); }); it('Should parse variables', function() { - this.shouldBeEqual('variable.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('variable.scss'); }); it('Should parse interpolated variables inside selectors', function() { - this.shouldBeEqual('interpolated-variable-1.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('interpolated-variable-1.scss'); }); it('Should parse interpolated variables inside values', function() { - this.shouldBeEqual('interpolated-variable-2.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('interpolated-variable-2.scss'); }); it('Should parse defaults', function() { - this.shouldBeEqual('default.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('default.scss'); }); it('Should parse @import', function() { - this.shouldBeEqual('import.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('import.scss'); }); it('Should parse @include', function() { - this.shouldBeEqual('include.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('include.scss'); }); it('Should parse nested @media', function() { - this.shouldBeEqual('nested-media.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('nested-media.scss'); }); it('Should parse @extend with classes', function() { - this.shouldBeEqual('extend-1.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('extend-1.scss'); }); it('Should parse @extend with placeholders', function() { - this.shouldBeEqual('extend-2.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('extend-2.scss'); }); it('Should parse @warn', function() { - this.shouldBeEqual('warn.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('warn.scss'); }); it('Should parse @if', function() { - this.shouldBeEqual('if.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('if.scss'); }); it('Should parse @if and @else', function() { - this.shouldBeEqual('if-else.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('if-else.scss'); }); it('Should parse @if and @else if', function() { - this.shouldBeEqual('if-else-if.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('if-else-if.scss'); }); it('Should parse @for', function() { - this.shouldBeEqual('for.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('for.scss'); }); it('Should parse @each', function() { - this.shouldBeEqual('each.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('each.scss'); }); it('Should parse @while', function() { - this.shouldBeEqual('while.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('while.scss'); }); it('Should parse mixins', function() { - this.shouldBeEqual('mixin-1.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('mixin-1.scss'); }); it('Should parse passing several variables to a mixin', function() { - this.shouldBeEqual('mixin-2.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('mixin-2.scss'); }); it('Should parse passing a list of variables to a mixin', function() { - this.shouldBeEqual('mixin-3.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('mixin-3.scss'); }); it('Should parse passing a content block to a mixin', function() { - this.shouldBeEqual('mixin-4.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('mixin-4.scss'); }); it('Should parse @content', function() { - this.shouldBeEqual('content.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('content.scss'); }); it('Should parse functions', function() { - this.shouldBeEqual('function.scss'); + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('function.scss'); }); }); diff --git a/test/core/use/test.js b/test/core/use/test.js index 78c85fac..1d3a9aa7 100644 --- a/test/core/use/test.js +++ b/test/core/use/test.js @@ -1,10 +1,12 @@ var assert = require('assert'); +let Test = require('../core_test'); -describe.skip('.use()', function() { +describe('.use()', function() { it('Should set predefined options in correct order', function() { - var config = this.Comb.getConfig('csscomb'); - this.comb.configure(config); - var options = this.comb.plugins.map(function(plugin) { + let test = new Test(this); + var config = test.Comb.getConfig('csscomb'); + test.comb.configure(config); + var options = test.comb.plugins.map(function(plugin) { return plugin.name; }); var expected = [ diff --git a/test/options/always-semicolon/process/test.js b/test/options/always-semicolon/process/test.js index 99415b36..7860c44c 100644 --- a/test/options/always-semicolon/process/test.js +++ b/test/options/always-semicolon/process/test.js @@ -29,12 +29,12 @@ describe('Option `always-semicolon`, process', function() { }); describe('less', function() { - it('Should not add semicolon to condition (single-line style)', function() { + it.skip('Should not add semicolon to condition (single-line style)', function() { let test = new Test(this, {'always-semicolon': true}); return test.shouldBeEqual('condition.less'); }); - it('Should not add semicolon to condition (multi-line style)', function() { + it.skip('Should not add semicolon to condition (multi-line style)', function() { let test = new Test(this, {'always-semicolon': true}); return test.shouldBeEqual('condition-multiline.less'); }); diff --git a/test/options/integral/process/css/issue-252.expected.sass b/test/options/integral/process/sass/issue-252.expected.sass similarity index 100% rename from test/options/integral/process/css/issue-252.expected.sass rename to test/options/integral/process/sass/issue-252.expected.sass diff --git a/test/options/integral/process/css/issue-252.sass b/test/options/integral/process/sass/issue-252.sass similarity index 100% rename from test/options/integral/process/css/issue-252.sass rename to test/options/integral/process/sass/issue-252.sass diff --git a/test/options/integral/process/test.js b/test/options/integral/process/test.js index d2a30d73..6cf8055e 100644 --- a/test/options/integral/process/test.js +++ b/test/options/integral/process/test.js @@ -8,16 +8,18 @@ describe('Option `integral`, process', function() { return test.shouldBeEqual('integral.css', 'integral.expected.css'); }); - it.skip('Issue 252', function() { + it('Issue 374', function() { let test = new Test(this); test.useConfig('csscomb'); - return test.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); + return test.shouldBeEqual('issue-374.css'); }); + }); - it('Issue 374', function() { + describe('sass', function() { + it('Issue 252', function() { let test = new Test(this); test.useConfig('csscomb'); - return test.shouldBeEqual('issue-374.css'); + return test.shouldBeEqual('issue-252.sass', 'issue-252.expected.sass'); }); }); }); diff --git a/test/options/sort-order/process/sass/include-specified-1.expected.sass b/test/options/sort-order/process/sass/include-specified-1.expected.sass index ff3a056f..dbc734c2 100644 --- a/test/options/sort-order/process/sass/include-specified-1.expected.sass +++ b/test/options/sort-order/process/sass/include-specified-1.expected.sass @@ -6,7 +6,5 @@ +media(lap) color: green - +media(palm) color: red - diff --git a/test/options/sort-order/process/sass/include-specified-2.expected.sass b/test/options/sort-order/process/sass/include-specified-2.expected.sass index d9a38e51..75cfdaae 100644 --- a/test/options/sort-order/process/sass/include-specified-2.expected.sass +++ b/test/options/sort-order/process/sass/include-specified-2.expected.sass @@ -6,7 +6,5 @@ @include media(lap) color: green - @include media(palm) color: red - diff --git a/test/options/sort-order/process/sass/include.expected.sass b/test/options/sort-order/process/sass/include.expected.sass index f7a50a7a..86ab0463 100644 --- a/test/options/sort-order/process/sass/include.expected.sass +++ b/test/options/sort-order/process/sass/include.expected.sass @@ -1,3 +1,3 @@ div - @include .nani + @include nani color: tomato diff --git a/test/options/sort-order/process/sass/include.sass b/test/options/sort-order/process/sass/include.sass index 9c7ac8b1..5b42a65f 100644 --- a/test/options/sort-order/process/sass/include.sass +++ b/test/options/sort-order/process/sass/include.sass @@ -1,3 +1,3 @@ div color: tomato - @include .nani + @include nani diff --git a/test/options/sort-order/process/sass/issue-332.expected.sass b/test/options/sort-order/process/sass/issue-332.expected.sass index d16ef320..390beee6 100644 --- a/test/options/sort-order/process/sass/issue-332.expected.sass +++ b/test/options/sort-order/process/sass/issue-332.expected.sass @@ -5,6 +5,5 @@ color: green +media(palm) color: red - +last +hide-text diff --git a/test/options/sort-order/process/scss/include.expected.scss b/test/options/sort-order/process/scss/include.expected.scss index ea381a79..390cd58f 100644 --- a/test/options/sort-order/process/scss/include.expected.scss +++ b/test/options/sort-order/process/scss/include.expected.scss @@ -1 +1 @@ -div {@include .nani; color: tomato; } +div {@include nani; color: tomato; } diff --git a/test/options/sort-order/process/scss/include.scss b/test/options/sort-order/process/scss/include.scss index c0ed1345..2feaaec8 100644 --- a/test/options/sort-order/process/scss/include.scss +++ b/test/options/sort-order/process/scss/include.scss @@ -1 +1 @@ -div { color: tomato; @include .nani; } +div { color: tomato; @include nani; } diff --git a/test/options/sort-order/process/scss/leftovers.expected.scss b/test/options/sort-order/process/scss/leftovers.expected.scss index bac4c993..d431a118 100644 --- a/test/options/sort-order/process/scss/leftovers.expected.scss +++ b/test/options/sort-order/process/scss/leftovers.expected.scss @@ -6,7 +6,7 @@ a { leftover: yay; border: 1px solid; - @include .nani; + @include nani; font: 20px/16px Arial, sans-serif; } @@ -18,7 +18,7 @@ b { leftover: yay; border: 1px solid; - @include .nani; + @include nani; font: 20px/16px Arial, sans-serif; } @@ -30,7 +30,7 @@ c { leftover: yay; border: 1px solid; - @include .nani; + @include nani; font: 20px/16px Arial, sans-serif; } diff --git a/test/options/sort-order/process/scss/leftovers.scss b/test/options/sort-order/process/scss/leftovers.scss index 0068e54a..ff5bc4df 100644 --- a/test/options/sort-order/process/scss/leftovers.scss +++ b/test/options/sort-order/process/scss/leftovers.scss @@ -1,14 +1,14 @@ a { leftover: yay; border: 1px solid; - @include .nani; + @include nani; font: 20px/16px Arial, sans-serif; position: $tomato; $red: tomato; } b { border: 1px solid; - @include .nani; + @include nani; position: $tomato; leftover: yay; font: 20px/16px Arial, sans-serif; @@ -16,7 +16,7 @@ b { } c { border: 1px solid; - @include .nani; + @include nani; font: 20px/16px Arial, sans-serif; position: $tomato; $red: tomato; diff --git a/test/options/sort-order/process/test.js b/test/options/sort-order/process/test.js index dc3e5642..6df33154 100644 --- a/test/options/sort-order/process/test.js +++ b/test/options/sort-order/process/test.js @@ -291,7 +291,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('import.sass', 'import.expected.sass'); }); - it.skip('Should sort @include-s', function() { + it('Should sort @include-s', function() { let test = new Test(this, { 'sort-order': [['$include', 'color']] }); @@ -305,14 +305,14 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('extend.sass', 'extend.expected.sass'); }); - it.skip('Should sort @include-s with specified name. Test 1', function() { + it('Should sort @include-s with specified name. Test 1', function() { let test = new Test(this, { 'sort-order': [['$include'], ['color'], ['$include media']] }); return test.shouldBeEqual('include-specified-1.sass', 'include-specified-1.expected.sass'); }); - it.skip('Should sort @include-s with specified name. Test 2', function() { + it('Should sort @include-s with specified name. Test 2', function() { let test = new Test(this, { 'sort-order': [['$include'], ['color'], ['$include media']] }); @@ -420,14 +420,14 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('import.scss', 'import.expected.scss'); }); - it.skip('Should sort @include-s', function() { + it('Should sort @include-s', function() { let test = new Test(this, { 'sort-order': [['$include', 'color']] }); return test.shouldBeEqual('include.scss', 'include.expected.scss'); }); - it.skip('Should sort @include-s with specified name', function() { + it('Should sort @include-s with specified name', function() { let test = new Test(this, { 'sort-order': [['$include'], ['color'], ['$include media']] }); @@ -462,7 +462,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('condition.scss', 'condition.expected.scss'); }); - it.skip('Should sort complex case with leftovers', function() { + it('Should sort complex case with leftovers', function() { let test = new Test(this, { 'sort-order': [ ['$variable'], @@ -475,7 +475,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('leftovers.scss', 'leftovers.expected.scss'); }); - it.skip('Issue 317', function() { + it('Issue 317', function() { let test = new Test(this, {'sort-order': ['...']}); return test.shouldBeEqual('issue-317.scss'); }); @@ -485,7 +485,7 @@ describe('Option `sort-order`, process', function() { return test.shouldBeEqual('issue-333.scss'); }); - it.skip('Issue 399', function() { + it('Issue 399', function() { let test = new Test(this, {'sort-order': [['$extend', 'color']]}); return test.shouldBeEqual('issue-399.expected.scss'); }); diff --git a/test/options/space-before-combinator/process/css/issue-381.css b/test/options/space-before-combinator/process/css/issue-381.css deleted file mode 100644 index 400e8737..00000000 --- a/test/options/space-before-combinator/process/css/issue-381.css +++ /dev/null @@ -1,5 +0,0 @@ -> .u-margins-off, -> .c-media > > *, -> .c-media-list > * > > * { - margin-top: 0; -} diff --git a/test/options/space-before-combinator/process/test.js b/test/options/space-before-combinator/process/test.js index dc9909be..b3f61ba2 100644 --- a/test/options/space-before-combinator/process/test.js +++ b/test/options/space-before-combinator/process/test.js @@ -31,10 +31,5 @@ describe('Option `space-before-combinator`, process', function() { let test = new Test(this, {'space-before-combinator': '\n '}); return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); - - it.skip('Issue 381', function() { - let test = new Test(this, {'space-before-combinator': ' '}); - return test.shouldBeEqual('issue-381.css'); - }); }); }); From e092650f8aa845e8d9f8ad211fdadfdc3c521d0a Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 00:01:36 +0200 Subject: [PATCH 137/184] Remove contributors list from package.json --- package.json | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/package.json b/package.json index 2a957686..41ff1a83 100644 --- a/package.json +++ b/package.json @@ -12,29 +12,6 @@ "web": "http://tonyganch.com/" } ], - "contributors": [ - { - "name": "Igor Novak", - "email": "bezengi@gmail.com" - }, - { - "name": "Roman Komarov", - "email": "kizmarh@ya.ru" - }, - { - "name": "Denis Payase", - "email": "lostsoul@yandex-team.ru" - }, - { - "name": "Mikhail Troshev", - "email": "mishanga@yandex-team.ru", - "web": "http://mishanga.pro/" - }, - { - "name": "Sergey Puzankov", - "email": "puzankov@yandex-team.ru" - } - ], "engines": { "node": ">= 0.10.0" }, From 19fb8da9ca0abc5936ddee390028be291654deeb Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 00:01:59 +0200 Subject: [PATCH 138/184] Update csscomb-core to v3.0.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 41ff1a83..66ef6346 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "dependencies": { "glob": "latest", "minimist": "1.1.x", - "csscomb-core": "csscomb/core#dev", - "gonzales-pe": "sodatea/gonzales-pe#dev", + "csscomb-core": "^3.0.0", + "gonzales-pe": "^3.3.6", "vow": "0.4.4" }, "devDependencies": { From 3bc4e9476fe47ae2478052497471d656e053e1fc Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 00:15:30 +0200 Subject: [PATCH 139/184] Remove postinstall script for csscomb-core --- package.json | 1 - scripts/postinstall.sh | 1 - 2 files changed, 2 deletions(-) delete mode 100755 scripts/postinstall.sh diff --git a/package.json b/package.json index 66ef6346..8d0bdb58 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", - "postinstall": "./scripts/postinstall.sh", "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh deleted file mode 100755 index 3c932c0f..00000000 --- a/scripts/postinstall.sh +++ /dev/null @@ -1 +0,0 @@ -cd ./node_modules/csscomb-core && npm i && npm run build && cd - From 3b3e075b12e8feb201386fc515a1e61f44c8ef11 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 00:30:11 +0200 Subject: [PATCH 140/184] Build files before publishing --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8d0bdb58..8b820ae4 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "scripts": { "build": "./scripts/build.sh", "coverage": "./scripts/coverage.sh", + "prepublish": "./scripts/build.sh", "test": "./scripts/build.sh && ./scripts/test.sh", "watch": "./scripts/watch.sh" } From aefc1d0f190378e6af21353977d66439077a3099 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 00:50:43 +0200 Subject: [PATCH 141/184] Post-rebase fixes --- package.json | 2 +- test/options/unitless-zero/test.js | 115 ----------------------------- 2 files changed, 1 insertion(+), 116 deletions(-) delete mode 100644 test/options/unitless-zero/test.js diff --git a/package.json b/package.json index 8b820ae4..6a0e6dbd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.5", + "version": "3.1.8", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", diff --git a/test/options/unitless-zero/test.js b/test/options/unitless-zero/test.js deleted file mode 100644 index 871405dd..00000000 --- a/test/options/unitless-zero/test.js +++ /dev/null @@ -1,115 +0,0 @@ -var assert = require('assert'); - -describe('options/unitless-zero', function() { - describe('process', function() { - it('Should remove units in zero-valued dimensions', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { margin: 0em; padding: 0px }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: 0; padding: 0 }'); - }); - }); - - it('Should remove units in zero-valued dimensions, test 2', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { margin: 0% }' - ).then(function(actual) { - assert.equal(actual, 'div { margin: 0 }'); - }); - }); - - it('Should remove units in zero-valued media-query params', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - '@media all and (min-width: 0px) { div { margin: 0em; padding: 0px } }' - ).then(function(actual) { - assert.equal(actual, '@media all and (min-width: 0) { div { margin: 0; padding: 0 } }'); - }); - }); - - it('Should not remove units (degs) in rotate property', function() { - this.comb.configure({ 'unitless-zero': true }); - return this.comb.processString( - 'div { -webkit-transform: rotate(0deg); }' - ).then(function(actual) { - assert.equal(actual, 'div { -webkit-transform: rotate(0deg); }'); - }); - }); - - it('Issue 394', function() { - this.comb.configure({ 'unitless-zero': true }); - this.shouldBeEqual('issue-394.css', 'issue-394.expected.css'); - }); - }); - - describe('detect', function() { - it('Should detect unitless zero option', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0 }', - { - 'unitless-zero': true - } - ); - }); - - - it('Should detect zero with unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { width: 0px }', - { - 'unitless-zero': false - } - ); - }); - - it('Should detect unitless zero option with multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0 }', - { - 'unitless-zero': true - } - ); - }); - - it('Should detect zero with unit and multiple values', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0px 0 0em }', - { - 'unitless-zero': false - } - ); - }); - - it('Shouldn’t detect unitless zero option if there is no unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { color: red }', - {} - ); - }); - - it('Shouldn’t detect unitless zero option if there is `deg` unit', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { transform: rotate(0deg) }', - {} - ); - }); - - it('Should detect unitless zero option with percents', function() { - this.shouldDetect( - ['unitless-zero'], - 'a { padding: 0% 0 0 }', - { - 'unitless-zero': true - } - ); - }); - }); -}); From 91f1aa69f2b57a8ea6a64fa3f93e36cb4a767d14 Mon Sep 17 00:00:00 2001 From: ptb Date: Thu, 31 Mar 2016 09:26:16 -0400 Subject: [PATCH 142/184] Remove duplicate entries --- config/yandex.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/config/yandex.json b/config/yandex.json index c8155e48..11efb6dd 100644 --- a/config/yandex.json +++ b/config/yandex.json @@ -149,11 +149,6 @@ "-ms-animation-iteration-count", "-o-animation-iteration-count", "animation-iteration-count", - "-webkit-animation-iteration-count", - "-moz-animation-iteration-count", - "-ms-animation-iteration-count", - "-o-animation-iteration-count", - "animation-iteration-count", "-webkit-animation-direction", "-moz-animation-direction", "-ms-animation-direction", @@ -291,15 +286,6 @@ "-webkit-box-shadow", "-moz-box-shadow", "box-shadow", - "-webkit-box-shadow", - "-moz-box-shadow", - "box-shadow", - "-webkit-box-shadow", - "-moz-box-shadow", - "box-shadow", - "-webkit-box-shadow", - "-moz-box-shadow", - "box-shadow", "filter:progid:DXImageTransform.Microsoft.gradient", "-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient", "text-shadow" From 2f3b28f88e7ce3786c9a1780da4c634c84396966 Mon Sep 17 00:00:00 2001 From: Denis Borodin Date: Mon, 6 Jun 2016 12:41:42 +0300 Subject: [PATCH 143/184] Added flex property to the config --- config/csscomb.json | 3 ++- config/yandex.json | 3 ++- config/zen.json | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/csscomb.json b/config/csscomb.json index ae0ddb7e..66c806fb 100644 --- a/config/csscomb.json +++ b/config/csscomb.json @@ -65,7 +65,8 @@ "flex-direction", "flex-order", "flex-pack", - "flex-align" + "flex-align", + "flex" ], [ "-webkit-box-sizing", diff --git a/config/yandex.json b/config/yandex.json index 11efb6dd..d6001553 100644 --- a/config/yandex.json +++ b/config/yandex.json @@ -29,7 +29,8 @@ "flex-direction", "flex-order", "flex-pack", - "flex-align" + "flex-align", + "flex" ], [ "-webkit-box-sizing", diff --git a/config/zen.json b/config/zen.json index 593c0d3b..b57e3ed6 100644 --- a/config/zen.json +++ b/config/zen.json @@ -35,6 +35,11 @@ "-ms-flex-align", "-o-flex-align", "flex-align", + "-webkit-flex", + "-moz-flex", + "-ms-flex", + "-o-flex", + "flex", "overflow", "-ms-overflow-x", "-ms-overflow-y", From 5b01fb737bc81cb1bc1c9713803ea9a5e66bd9ea Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 01:04:41 +0200 Subject: [PATCH 144/184] Add license info tp package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 6a0e6dbd..a521ebbb 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", + "license": "MIT", "maintainers": [ { "name": "Tony Ganch", From cbf7ca50ea1fb7f3f448c9ebd7107682bb8aeecd Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 12 Jul 2016 01:12:42 +0200 Subject: [PATCH 145/184] v4.0.0-alpha --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a521ebbb..05836159 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "3.1.8", + "version": "4.0.0-alpha", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From f22aad3fb77d636df9d43d5a0004f34e1a0c63bb Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 27 Jul 2016 14:48:27 +0200 Subject: [PATCH 146/184] Update babel dependencies --- package.json | 4 +++- scripts/build.sh | 2 +- scripts/test.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 05836159..f382b270 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "vow": "0.4.4" }, "devDependencies": { - "babel": "^5.5.3", + "babel-cli": "^6.11.4", + "babel-plugin-transform-es2015-destructuring": "^6.9.0", + "babel-plugin-transform-strict-mode": "^6.11.3", "jscs": "2.1.0", "jshint": "2.8.0", "mocha": "1.20.1" diff --git a/scripts/build.sh b/scripts/build.sh index ec78ca4e..a9bccea3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,4 +4,4 @@ printf "\n\ -----------------------\n\ Building source files\n\ -----------------------\n\n" -./node_modules/.bin/babel --loose all src --out-dir lib +./node_modules/.bin/babel --plugins babel-plugin-transform-es2015-destructuring --loose all src --out-dir lib diff --git a/scripts/test.sh b/scripts/test.sh index c118a2e6..195f855d 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -27,7 +27,7 @@ printf "\n\ ---------------\n\ Running Mocha\n\ ---------------\n\n" -test ./node_modules/.bin/babel-node ./test/mocha +test ./node_modules/.bin/babel-node --plugins transform-strict-mode ./test/mocha if [ $EXIT_CODE -ne 0 ]; then printf "\n\ From fc9fd333579d9d15ad10334c9ac259d8db2e9ba6 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 2 Aug 2016 21:32:44 +0200 Subject: [PATCH 147/184] [cli] Fix processing of input data --- src/cli.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cli.js b/src/cli.js index 36aee135..a653760a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -27,13 +27,13 @@ var getInputData = new vow.Promise(function(resolve) { }); function processInputData(input) { - try { - process.stdout.write(comb.processString(input)); - process.exit(0); - } catch (e) { - process.stderr.write(e.message); - process.exit(1); - } + comb.processString(input).catch(e => { + process.stderr.write(e.message); + process.exit(1); + }).then(output => { + process.stdout.write(comb.processString(input)); + process.exit(0); + }); } function processSTDIN() { From 54c559e3879e06a6fbef1490db88cb8839c07740 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 2 Aug 2016 22:06:42 +0200 Subject: [PATCH 148/184] [cli] Add help message Fixes #477 --- src/cli.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/cli.js b/src/cli.js index a653760a..dda14862 100644 --- a/src/cli.js +++ b/src/cli.js @@ -14,6 +14,28 @@ var vow = require('vow'); var Comb = require('./csscomb'); var comb = new Comb(); +function displayHelp() { + var help = [ + 'NAME', + ' csscomb — Lint and fix style errors in css files', + '', + 'SYNOPSIS', + ' csscomb [options] file.css', + ' cat file.css | csscomb [options] -', + '', + 'OPTIONS', + ' -c, --config [path]', + ' Path to configuration file.', + ' -d, --detect', + ' Run the tool in detect mode, returning detected options.', + ' -l, --lint', + ' Run the tool in linter mode, without modifying files.', + ' -v, --verbose', + ' Whether to print logging info.', + ]; + console.log(help.join('\n')); +} + var getInputData = new vow.Promise(function(resolve) { var input = ''; process.stdin.resume(); @@ -140,6 +162,11 @@ console.time('Time spent'); var options = getOptions(); +if (options.help) { + displayHelp(); + process.exit(0); +} + if (options.detect) { detectConfig(options.detect); } From 0c2db5f3c351ee2c64ad410152a8a37ba17a9e79 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 2 Aug 2016 22:21:44 +0200 Subject: [PATCH 149/184] [cli] Fix linter errors --- src/cli.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cli.js b/src/cli.js index dda14862..88f517ed 100644 --- a/src/cli.js +++ b/src/cli.js @@ -31,7 +31,7 @@ function displayHelp() { ' -l, --lint', ' Run the tool in linter mode, without modifying files.', ' -v, --verbose', - ' Whether to print logging info.', + ' Whether to print logging info.' ]; console.log(help.join('\n')); } @@ -49,13 +49,13 @@ var getInputData = new vow.Promise(function(resolve) { }); function processInputData(input) { - comb.processString(input).catch(e => { - process.stderr.write(e.message); - process.exit(1); - }).then(output => { - process.stdout.write(comb.processString(input)); - process.exit(0); - }); + comb.processString(input).catch(e => { + process.stderr.write(e.message); + process.exit(1); + }).then(output => { + process.stdout.write(output); + process.exit(0); + }); } function processSTDIN() { From e2d9960c4f32189801a80e4e6a1c5374a114d635 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 3 Aug 2016 14:33:59 +0200 Subject: [PATCH 150/184] [cli] Make linter the default mode --- src/cli.js | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/cli.js b/src/cli.js index 88f517ed..5a30a66f 100644 --- a/src/cli.js +++ b/src/cli.js @@ -28,8 +28,8 @@ function displayHelp() { ' Path to configuration file.', ' -d, --detect', ' Run the tool in detect mode, returning detected options.', - ' -l, --lint', - ' Run the tool in linter mode, without modifying files.', + ' -f, --fix', + ' Run the tool in fixer mode, modifying files when possible.', ' -v, --verbose', ' Whether to print logging info.' ]; @@ -49,7 +49,7 @@ var getInputData = new vow.Promise(function(resolve) { }); function processInputData(input) { - comb.processString(input).catch(e => { + comb.lintString(input).catch(e => { process.stderr.write(e.message); process.exit(1); }).then(output => { @@ -63,33 +63,16 @@ function processSTDIN() { } function processFiles(files, config) { - vow.all(files.map(comb.processPath.bind(comb))).then(function(c) { - c = c.filter(function(isChanged) { - return isChanged !== undefined; - }); - - var tbchanged = c.reduce(function(a, b) { - return a + b; - }, 0); - - var changed = config.lint ? 0 : tbchanged; - - if (config.verbose) { - let message = `\n - ${c.length} file${c.length === 1 ? '' : 's'} processed\n - ${changed} file${changed === 1 ? '' : 's'} fixed\n`; - process.stdout.write(format(message)); - console.timeEnd('Time spent'); - } - - if (config.lint && tbchanged) { - process.exit(1); - } + const promises = files.map(file => { + return comb.lintPath(file); + }); - process.exit(0); - }).fail(function(e) { - process.stderr.write(e.stack); + Promise.all(promises).catch(error => { + process.stderr.write(error.message); process.exit(1); + }).then(function(c) { + console.log(c); + process.exit(0); }); } @@ -146,7 +129,6 @@ function getConfig(options) { applyTemplate(config); if (options.verbose) config.verbose = options.verbose; - if (options.lint) config.lint = options.lint; return config; } From 822f546dc11faddf107b46466a1ba821aa10c5ed Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 3 Aug 2016 19:47:02 +0200 Subject: [PATCH 151/184] Move csscomb-core from separate repo here --- package.json | 7 +- src/core.js | 458 +++++++++++++++++++++++++++++++++++++++++++++++++ src/csscomb.js | 2 +- src/errors.js | 62 +++++++ src/plugin.js | 96 +++++++++++ 5 files changed, 621 insertions(+), 4 deletions(-) create mode 100644 src/core.js create mode 100644 src/errors.js create mode 100644 src/plugin.js diff --git a/package.json b/package.json index f382b270..e639676d 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,11 @@ }, "dependencies": { "glob": "latest", - "minimist": "1.1.x", - "csscomb-core": "^3.0.0", "gonzales-pe": "^3.3.6", - "vow": "0.4.4" + "minimatch": "3.0.2", + "minimist": "1.1.x", + "vow": "0.4.4", + "vow-fs": "0.3.2" }, "devDependencies": { "babel-cli": "^6.11.4", diff --git a/src/core.js b/src/core.js new file mode 100644 index 00000000..a71cea71 --- /dev/null +++ b/src/core.js @@ -0,0 +1,458 @@ +'use strict'; + + +if (!global._babelPolyfill) { + require('babel-polyfill'); +} +let fs = require('fs'); +let gonzales = require('gonzales-pe'); +let minimatch = require('minimatch'); +let Errors = require('./errors'); +let Plugin = require('./plugin'); + +let vow = require('vow'); +let vfs = require('vow-fs'); + +class Comb { + constructor() { + this.config = {}; + this.exclude = []; + // Whether lint mode is on. + this.lint = false; + // List of file paths that should be excluded from processing. + this.pathsToExclude = null; + // List of used plugins. + this.plugins = []; + this.pluginsDependencies = {}; + // List of supported syntaxes. + this.supportedSyntaxes = new Set(); + // Mapping file extensions to syntax + this.syntaxMap = new Map(); + // Whether verbose mode is on. + this.verbose = false; + } + + /** + * Loads configuration from JSON. + * + * @param {!Object} config + * @return {!Comb} + */ + configure(config) { + if (typeof config !== 'object') + // TODO: throw error + throw new Error(); + + this.lint = config.lint; + this.verbose = config.verbose; + if (config.exclude) + this.exclude = config.exclude.map(function(pattern) { + return new minimatch.Minimatch(pattern); + }); + + if (config.syntax) { + for (let key in config.syntax) { + this.syntaxMap.set(key, config.syntax[key]); + } + } + + for (let i = 0, l = this.plugins.length; i < l; i++) { + let plugin = this.plugins[i]; + let name = plugin.name; + if (!config.hasOwnProperty(name)) continue; + + try { + plugin.value = config[name]; + this.config[name] = plugin.value; + } catch (e) { + // TODO: throw error + } + } + + // Chaining. + return this; + } + + /** + * Lints all files in a directory. + * + * @param {String} path + * @returns {Promise} + */ + lintDirectory(path) { + let files = this._getAcceptableFilesFromDirectory(path); + let promises = files.map((file) => this.lintFile(file)); + return Promise.all(promises); + } + + /** + * Lints a single file. + * + * @param {String} path + * @returns {Promise} + */ + lintFile(path) { + let syntax = this._extractSyntax(path); + return this._readFile(path).then((string) => { + return this.lintString(string, {syntax: syntax, filename: path}); + }); + } + + /** + * Lints a file or a directory. + * + * @param {String} path + */ + lintPath(path) { + path = path.replace(/\/$/, ''); + return fs.statSync(path).isDirectory() ? + this.lintDirectory(path) : + this.lintFile(path); + } + + /** + * Lints a string. + * + * @param {String} text + * @param {{context: String, filename: String, syntax: String}} options + * @returns {Promise} Resolves with list of found errors. + */ + lintString(text, options) { + return this._parseString(text, options) + .then(this._lintTree.bind(this)) + .then(errors => { + errors.forEach(error => { + error.context = this._getContext(text, error.line); + }); + + return errors; + }); + } + + _getContext(text, currentLineNumber) { + var LINES_AROUND = 2; + var result = []; + var start = currentLineNumber - 1 - LINES_AROUND; + var end = currentLineNumber + LINES_AROUND; + var lines = text.split(/\r\n|\r|\n/); + + for (var i = start; i < end; i++) { + var line = lines[i]; + if (!line) continue; + var ln = i + 1; + if (ln === currentLineNumber) { + result.push(ln + '*| ' + line); + } else { + result.push(ln + ' | ' + line); + } + } + return result.join('\n'); + } + + /** + * Processes directory recursively. + * + * @param {String} path + * @returns {Promise} + */ + processDirectory(path) { + let that = this; + + return vfs.listDir(path).then(function(filenames) { + return vow.all(filenames.map(function(filename) { + let fullname = path + '/' + filename; + return vfs.stat(fullname).then(function(stat) { + if (stat.isDirectory() && that._shouldProcess(fullname)) { + return that.processDirectory(fullname); + } else { + return that.processFile(fullname); + } + }); + })).then(function(results) { + return [].concat.apply([], results); + }); + }); + } + + /** + * Processes single file. + * + * @param {String} path + * @returns {Promise} + */ + processFile(path) { + let that = this; + + if (!this._shouldProcessFile(path)) return; + + return vfs.read(path, 'utf8').then(function(data) { + let syntax = that._extractSyntax(path); + that.processString(data, { + syntax: syntax, + filename: path + }).then(function(processedData) { + if (data === processedData) { + if (that.verbose) console.log(' ', path); + return 0; + } + + return vfs.write(path, processedData, 'utf8').then(function() { + if (that.verbose) console.log('✓', path); + return 1; + }); + }); + }); + } + + /** + * Processes directory or file. + * + * @returns {Promise} + */ + processPath(path) { + let that = this; + path = path.replace(/\/$/, ''); + + return vfs.stat(path).then(function(stat) { + if (stat.isDirectory()) { + return that.processDirectory(path); + } else { + return that.processFile(path); + } + }); + } + + /** + * Processes a string. + * + * @param {String} text + * @param {{context: String, filename: String, syntax: String}} options + * @returns {Promise} Resolves in processed string + */ + processString(text, options) { + return this._parseString(text, options) + .then(this._processTree.bind(this)) + .then((ast) => ast.toString()); + } + + /** + * Add a plugin. + * @param {Object} options + * @return {Comb} + */ + use(options) { + // Check whether plugin with the same is already used. + let pluginName = options.name; + if (this._pluginAlreadyUsed(pluginName)) { + if (this.verbose) + console.warn(Errors.twoPluginsWithSameName(pluginName)); + return; + } + + let plugin = new Plugin(options); + + plugin.syntax.forEach(function(s) { + this.supportedSyntaxes.add(s); + }, this); + + // Sort plugins. + let pluginToRunBefore = plugin.runBefore; + + if (!pluginToRunBefore) { + this.plugins.push(plugin); + } else { + if (this._pluginAlreadyUsed(pluginToRunBefore)) { + let i = this._pluginIndex(pluginToRunBefore); + this.plugins.splice(i, 0, plugin); + } else { + this.plugins.push(plugin); + if (!this.pluginsDependencies[pluginToRunBefore]) + this.pluginsDependencies[pluginToRunBefore] = []; + this.pluginsDependencies[pluginToRunBefore].push(pluginName); + } + } + + let dependents = this.pluginsDependencies[pluginName]; + if (!dependents) return this; + + for (let i = 0, l = dependents.length; i < l; i++) { + let name = dependents[i]; + let x = this._pluginIndex(name); + let plugin = this.plugins[x]; + this.plugins.splice(x, 1); + this.plugins.splice(-1, 0, plugin); + } + + // Chaining. + return this; + } + + _getAcceptableFilesFromDirectory(path) { + if (!this._shouldProcess(path)) return; + + let files = []; + let filesInThisDir = fs.readdirSync(path); + + for (let i = 0, fl = filesInThisDir.length; i < fl; i++) { + let fullname = path + '/' + filesInThisDir[i]; + let stat = fs.statSync(fullname); + if (stat.isDirectory() && this._shouldProcess(fullname)) + files = files.concat(this._getAcceptableFilesFromDirectory(fullname)); + else if (this._shouldProcessFile(fullname)) + files.push(fullname); + } + + return files; + } + + /** + * @param {Node} ast + * @param {String=} filename + * @return {Array} List of errors. + */ + _lintTree(ast, filename) { + let errors = []; + let config = this.config; + + this.plugins.filter(function(plugin) { + return typeof plugin.value !== null && + typeof plugin.lint === 'function' && + plugin.syntax.indexOf(ast.syntax) !== -1; + }).forEach(function(plugin) { + let e = plugin.lint(ast, config); + errors = errors.concat(e); + }); + + if (filename) { + errors.map(function(error) { + error.filename = filename; + return error; + }); + } + + return errors; + } + + _parseString(text, options) { + let syntax = options && options.syntax; + let filename = options && options.filename || ''; + let context = options && options.context; + let tree; + + if (!text) return this.lint ? [] : text; + + if (!syntax) syntax = 'css'; + this.syntax = syntax; + + return new Promise(function(resolve) { + try { + tree = gonzales.parse(text, {syntax: syntax, rule: context}); + resolve(tree, filename); + } catch (e) { + let version = require('../package.json').version; + let message = filename ? [filename] : []; + message.push(e.message); + message.push('CSScomb Core version: ' + version); + e.stack = e.message = message.join('\n'); + throw e; + } + }); + } + + _pluginAlreadyUsed(name) { + return this._pluginIndex(name) !== -1; + } + + _pluginIndex(name) { + let index = -1; + this.plugins.some(function(plugin, i) { + if (plugin.name === name) { + index = i; + return true; + } + }); + return index; + } + + /** + * @param {Node} ast + * @return {Node} Transformed AST + */ + _processTree(ast) { + let config = this.config; + + this.plugins.filter(function(plugin) { + return plugin.value !== null && + typeof plugin.process === 'function' && + plugin.syntax.indexOf(ast.syntax) !== -1; + }).forEach(function(plugin) { + plugin.process(ast, config); + }); + + return ast; + } + + _readFile(path) { + return new Promise((resolve, reject) => { + if (!this._shouldProcessFile(path)) reject(); + + fs.readFile(path, 'utf8', function(e, string) { + if (e) reject(); + resolve(string); + }); + }); + } + + /** + * Checks if path is not present in `exclude` list. + * + * @param {String} path + * @returns {Boolean} False if specified path is present in `exclude` list. + * Otherwise returns true. + */ + _shouldProcess(path) { + path = path.replace(/\/$/, ''); + if (!fs.existsSync(path)) { + console.warn('Path ' + path + ' was not found.'); + return false; + } + + path = path.replace(/^\.\//, ''); + return this.exclude.every(function(e) { + return !e.match(path); + }); + } + + /** + * Checks if specified path is not present in `exclude` list and it has one of + * acceptable syntaxes. + * + * @param {String} path + * @returns {Boolean} False if the path either has unacceptable extension or + * is present in `exclude` list. True if everything is ok. + */ + _shouldProcessFile(path) { + // Get file's extension: + var syntax = this._extractSyntax(path); + + // Check if syntax is supported. If not, ignore the file: + if (!this.supportedSyntaxes.has(syntax)) + return false; + + return this._shouldProcess(path); + } + + /** + * Extract syntax by file path + * + * @param {String} path + * @returns {String} syntax + */ + _extractSyntax(path) { + var extension = path.split('.').pop(); + + return this.syntaxMap.get('.' + extension) || extension; + } +} + +module.exports = Comb; diff --git a/src/csscomb.js b/src/csscomb.js index e80b8e2f..a698767a 100644 --- a/src/csscomb.js +++ b/src/csscomb.js @@ -1,8 +1,8 @@ 'use strict'; -let Comb = require('csscomb-core'); let gonzales = require('gonzales-pe'); let fs = require('fs'); +let Comb = require('./core'); let format = require('./format'); let path = require('path'); diff --git a/src/errors.js b/src/errors.js new file mode 100644 index 00000000..e09c9eff --- /dev/null +++ b/src/errors.js @@ -0,0 +1,62 @@ +'use strict'; + + +let format = require('./format'); + +module.exports = { + implementSetValue(valueType) { + if (typeof valueType === 'undefined') throw new Error(); + + return format(`If you see this message and you are not + a developer adding a new option, please open an issue here: + https://github.com/csscomb/core/issues/new\n + For option to accept values of type "${valueType}" + you need to implement custom \`setValue()\` method.`); + }, + + missingName() { + return 'Plugin must have a valid \`name\` property.'; + }, + + missingSetValue() { + return format(`Plugin must either implemet \`setValue()\` method + or provide \`accepts\` object with acceptable values.`); + }, + + missingSyntax() { + return 'Plugin must list supported syntaxes.'; + }, + + twoPluginsWithSameName(pluginName) { + if (typeof pluginName === 'undefined') throw new Error(); + + return format(`You're trying to use one plugin twice: + ${pluginName}. Please make sure there are not two different + plugins with the same name.`); + }, + + unacceptableBoolean(pattern) { + if (typeof pattern === 'undefined') throw new Error(); + + return `Value must be one of the following: ${pattern.join(', ')}.`; + }, + + unacceptableNumber() { + return 'Value must be an integer.'; + }, + + unacceptableString(pattern) { + if (typeof pattern === 'undefined') throw new Error(); + + return `Value must match pattern ${pattern}.`; + }, + + unacceptableValueType(valueType, accepts) { + if (typeof valueType === 'undefined' || + typeof accepts === 'undefined') throw new Error(); + + return format(`The option does not accept values of type + ${valueType}.\nValue\'s type must be one the following: + ${Object.keys(accepts).join(', ')}.`); + } +}; diff --git a/src/plugin.js b/src/plugin.js new file mode 100644 index 00000000..a08046f8 --- /dev/null +++ b/src/plugin.js @@ -0,0 +1,96 @@ +'use strict'; + + +let Errors = require('./errors'); + +let Plugin = function(methods) { + for (let method in methods) { + this[method] = typeof method === 'function'? + methods[method].bind(this) : methods[method]; + } + + this.validate(); +}; + +Plugin.prototype = { + /** + * Plugin's name. + * @type {String} + */ + name: null, + + /** + * List of supported syntaxes. + * @type {Array} + */ + syntax: null, + + /** + * @type {Object} + */ + accepts: null, + + /** + * @type {Function} + */ + process: null, + + /** + * @type {Function} + */ + lint: null, + + value_: null, + get value() { + return this.value_; + }, + set value(value) { + let valueType = typeof value; + let pattern = this.accepts && this.accepts[valueType]; + + if (this.setValue) { + this.value_ = this.setValue(value); + return this.value_; + } + + if (!pattern) + throw new Error(Errors.unacceptableValueType(valueType, this.accepts)); + + if (valueType === 'boolean') { + if (pattern.indexOf(value) < 0) + throw new Error(Errors.unacceptableBoolean(pattern)); + this.value_ = value; + return this.value_; + } + + if (valueType === 'number') { + if (value !== parseInt(value)) + throw new Error(Errors.unacceptableNumber()); + this.value_ = new Array(value + 1).join(' '); + return this.value_; + } + + if (valueType = 'string') { + if (!value.match(pattern)) + throw new Error(Errors.unacceptableString(pattern)); + this.value_ = value; + return this.value_; + } + + throw new Error(Errors.implementSetValue(valueType)); + }, + + validate() { + if (typeof this.name !== 'string' || !this.name) + throw new Error(Errors.missingName()); + + if (!Array.isArray(this.syntax) || this.syntax.length === 0) + throw new Error(Errors.missingSyntax()); + + if (typeof this.accepts !== 'object' && + typeof this.setValue !== 'function') + throw new Error(Errors.missingSetValue()); + } +}; + +module.exports = Plugin; From 6c88e7e34887a35f3fe8c2af9c0b04189dae2c2c Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 3 Aug 2016 19:53:43 +0200 Subject: [PATCH 152/184] [cli] Print linter errors --- src/cli.js | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/src/cli.js b/src/cli.js index 5a30a66f..91ec3cae 100644 --- a/src/cli.js +++ b/src/cli.js @@ -53,8 +53,12 @@ function processInputData(input) { process.stderr.write(e.message); process.exit(1); }).then(output => { - process.stdout.write(output); - process.exit(0); + if (!output.length) { + process.exit(0); + } else { + process.stdout.write(output); + process.exit(1); + } }); } @@ -62,18 +66,46 @@ function processSTDIN() { getInputData.then(processInputData); } -function processFiles(files, config) { +function processFiles(files) { + let anyErrorsFound = false; + const promises = files.map(file => { - return comb.lintPath(file); + return comb.lintPath(file).then(errors => { + if (!errors.length) { + return; + } + + anyErrorsFound = true; + const message = formatErrors(file, errors); + process.stdout.write(message); + }); }); Promise.all(promises).catch(error => { process.stderr.write(error.message); process.exit(1); - }).then(function(c) { - console.log(c); - process.exit(0); + }).then(function() { + if (anyErrorsFound) { + process.exit(1); + } else { + process.exit(0); + } + }); +} + +function formatErrors(fileName, errors) { + let message = []; + + errors.forEach(error => { + message.push( + error.message + ' at ' + fileName + ':' + error.line, + error.context, + '', + '' + ); }); + + return message.join('\n'); } function getOptions() { @@ -157,7 +189,7 @@ var config = getConfig(options); comb.configure(config); if (process.stdin.isTTY) { - processFiles(options._, config); + processFiles(options._); } else { processSTDIN(); } From 49cae437bbc1cdd44a1ae412accdfc2a75c56ced Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 3 Aug 2016 20:32:45 +0200 Subject: [PATCH 153/184] [cli] Fix file processing --- src/cli.js | 254 ++++++++++++++++++++++++++++++-------------------- src/core.js | 30 +++--- src/errors.js | 9 ++ 3 files changed, 176 insertions(+), 117 deletions(-) diff --git a/src/cli.js b/src/cli.js index 91ec3cae..29dd0789 100644 --- a/src/cli.js +++ b/src/cli.js @@ -6,13 +6,67 @@ * Usage example: * ./node_modules/.bin/csscomb [options] [file1 [dir1 [fileN [dirN]]]] */ -var format = require('./format'); var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); -var vow = require('vow'); + var Comb = require('./csscomb'); +var Errors = require('./errors'); + + +var getInputData = new Promise(function(resolve) { + var input = ''; + process.stdin.resume(); + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function(data) { + input += data; + }); + process.stdin.on('end', function() { + resolve(input); + }); +}); + var comb = new Comb(); +var options = getOptions(); + +if (options.help) { + displayHelp(); + process.exit(0); +} + +if (options.detect) { + const config = detectConfig(); + process.stdout.write(config); + process.exit(0); +} + +var config = getConfig(); +comb.configure(config); + +if (options.fix && process.stdin.isTTY) { + processFiles(options._); +} else if (options.fix) { + processSTDIN(); +} else if (process.stdin.isTTY) { + lintFiles(options._); +} else { + lintSTDIN(); +} + + +function getOptions() { + var parserOptions = { + boolean: ['help', 'fix', 'verbose'], + alias: { + config: 'c', + detect: 'd', + fix: 'f', + help: 'h', + verbose: 'v' + } + }; + return parseArgs(process.argv.slice(2), parserOptions); +} function displayHelp() { var help = [ @@ -30,35 +84,87 @@ function displayHelp() { ' Run the tool in detect mode, returning detected options.', ' -f, --fix', ' Run the tool in fixer mode, modifying files when possible.', + ' -h, --help', + ' Display help message.', ' -v, --verbose', ' Whether to print logging info.' ]; - console.log(help.join('\n')); + process.stdout.write(help.join('\n')); } -var getInputData = new vow.Promise(function(resolve) { - var input = ''; - process.stdin.resume(); - process.stdin.setEncoding('utf8'); - process.stdin.on('data', function(data) { - input += data; - }); - process.stdin.on('end', function() { - resolve(input); +function detectConfig() { + const config = Comb.detectInFile(options.detect); + return JSON.stringify(config, false, 4); +} + +function getConfig() { + var configPath = options.config && + path.resolve(process.cwd(), options.config) || + Comb.getCustomConfigPath(); + + var config; + if (!fs.existsSync(configPath)) { + config = require('../config/csscomb.json'); + } else if (configPath.match(/\.css$/)) { + config = Comb.detectInFile(configPath); + } else { + config = Comb.getCustomConfig(configPath); + } + + if (!config) { + const errorMessage = Errors.configParsingError(configPath); + process.stderr.write(errorMessage); + process.exit(1); + } + + applyTemplate(config); + if (options.verbose) config.verbose = options.verbose; + + return config; +} + +function applyTemplate(config) { + if (!config.template) return; + + if (!fs.existsSync(config.template)) { + const errorMessage = Errors.missingTemplateFile(config.template); + process.stderr.write(errorMessage); + process.exit(1); + } + + var templateConfig = Comb.detectInFile(config.template); + for (var attrname in templateConfig) { + if (templateConfig.hasOwnProperty(attrname) && !config[attrname]) { + config[attrname] = templateConfig[attrname]; + } + } +} + +function processFiles(files) { + const promises = files.map(file => { + return comb.processPath(file); }); -}); -function processInputData(input) { - comb.lintString(input).catch(e => { - process.stderr.write(e.message); + Promise.all(promises).catch(error => { + process.stderr.write(error.stack); process.exit(1); - }).then(output => { - if (!output.length) { - process.exit(0); - } else { - process.stdout.write(output); - process.exit(1); + }).then(c => { + var tbchanged = c.filter(isChanged => { + return isChanged !== undefined; + }).reduce((a, b) => { + return a + b; + }, 0); + + if (config.verbose) { + let message = [ + `${c.length} file${c.length === 1 ? '' : 's'} processed`, + `${tbchanged} file${tbchanged === 1 ? '' : 's'} fixed`, + '' + ].join('\n'); + process.stdout.write(message); } + + process.exit(0); }); } @@ -66,7 +172,17 @@ function processSTDIN() { getInputData.then(processInputData); } -function processFiles(files) { +function processInputData(input) { + comb.processString(input).catch(e => { + process.stderr.write(e.message); + process.exit(1); + }).then(output => { + process.stdout.write(output); + process.exit(0); + }); +} + +function lintFiles(files) { let anyErrorsFound = false; const promises = files.map(file => { @@ -108,88 +224,20 @@ function formatErrors(fileName, errors) { return message.join('\n'); } -function getOptions() { - var parserOptions = { - boolean: ['verbose', 'lint'], - alias: { - config: 'c', - detect: 'd', - lint: 'l', - verbose: 'v' - } - }; - return parseArgs(process.argv.slice(2), parserOptions); +function lintSTDIN() { + getInputData.then(lintInputData); } -function applyTemplate(config) { - if (!config.template) return; - - if (!fs.existsSync(config.template)) { - let message = `Template configuration file ${config.template} - was not found.`; - process.stderr.write(format(message)); +function lintInputData(input) { + comb.lintString(input).catch(e => { + process.stderr.write(e.message); process.exit(1); - } - - var templateConfig = Comb.detectInFile(config.template); - for (var attrname in templateConfig) { - if (templateConfig.hasOwnProperty(attrname) && !config[attrname]) { - config[attrname] = templateConfig[attrname]; + }).then(output => { + if (!output.length) { + process.exit(0); + } else { + process.stdout.write(output); + process.exit(1); } - } -} - -function getConfig(options) { - var configPath = options.config && - path.resolve(process.cwd(), options.config) || - Comb.getCustomConfigPath(); - - var config; - if (!fs.existsSync(configPath)) { - config = require('../config/csscomb.json'); - } else if (configPath.match(/\.css$/)) { - config = Comb.detectInFile(configPath); - } else { - config = Comb.getCustomConfig(configPath); - } - - if (!config) { - let message = `Error parsing configuration file ${configPath}.`; - process.stderr.write(format(message)); - process.exit(1); - } - - applyTemplate(config); - if (options.verbose) config.verbose = options.verbose; - - return config; -} - -function detectConfig(file) { - var config = Comb.detectInFile(file); - config = JSON.stringify(config, false, 4); - process.stdout.write(config); - process.exit(0); -} - -console.time('Time spent'); - -var options = getOptions(); - -if (options.help) { - displayHelp(); - process.exit(0); -} - -if (options.detect) { - detectConfig(options.detect); -} - -var config = getConfig(options); -comb.configure(config); - -if (process.stdin.isTTY) { - processFiles(options._); -} else { - processSTDIN(); + }); } diff --git a/src/core.js b/src/core.js index a71cea71..2ee7fd1d 100644 --- a/src/core.js +++ b/src/core.js @@ -185,20 +185,22 @@ class Comb { if (!this._shouldProcessFile(path)) return; - return vfs.read(path, 'utf8').then(function(data) { - let syntax = that._extractSyntax(path); - that.processString(data, { - syntax: syntax, - filename: path - }).then(function(processedData) { - if (data === processedData) { - if (that.verbose) console.log(' ', path); - return 0; - } - - return vfs.write(path, processedData, 'utf8').then(function() { - if (that.verbose) console.log('✓', path); - return 1; + return new Promise(resolve => { + vfs.read(path, 'utf8').then(function(data) { + let syntax = that._extractSyntax(path); + that.processString(data, { + syntax: syntax, + filename: path + }).then(function(processedData) { + if (data === processedData) { + if (that.verbose) console.log(' ', path); + resolve(0); + } + + return vfs.write(path, processedData, 'utf8').then(function() { + if (that.verbose) console.log('✓', path); + resolve(1); + }); }); }); }); diff --git a/src/errors.js b/src/errors.js index e09c9eff..5dc2e4e5 100644 --- a/src/errors.js +++ b/src/errors.js @@ -4,6 +4,10 @@ let format = require('./format'); module.exports = { + configParsingError(configPath) { + return `Error parsing configuration file ${configPath}.`; + }, + implementSetValue(valueType) { if (typeof valueType === 'undefined') throw new Error(); @@ -27,6 +31,11 @@ module.exports = { return 'Plugin must list supported syntaxes.'; }, + missingTemplateFile(file) { + return format(`Template configuration file ${file} + was not found.`); + }, + twoPluginsWithSameName(pluginName) { if (typeof pluginName === 'undefined') throw new Error(); From dd30f0b8751fcc81c54fa170bab5b62ecdb37677 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 8 Feb 2017 17:11:04 +0100 Subject: [PATCH 154/184] [cli] Use old linter --- src/cli.js | 87 +++++++++-------------------------------------------- src/core.js | 12 ++++++-- 2 files changed, 24 insertions(+), 75 deletions(-) diff --git a/src/cli.js b/src/cli.js index 29dd0789..fbbc2ec3 100644 --- a/src/cli.js +++ b/src/cli.js @@ -43,24 +43,20 @@ if (options.detect) { var config = getConfig(); comb.configure(config); -if (options.fix && process.stdin.isTTY) { +if (process.stdin.isTTY) { processFiles(options._); -} else if (options.fix) { - processSTDIN(); -} else if (process.stdin.isTTY) { - lintFiles(options._); } else { - lintSTDIN(); + processSTDIN(); } function getOptions() { var parserOptions = { - boolean: ['help', 'fix', 'verbose'], + boolean: ['help', 'lint', 'verbose'], alias: { config: 'c', detect: 'd', - fix: 'f', + lint: 'l', help: 'h', verbose: 'v' } @@ -82,8 +78,8 @@ function displayHelp() { ' Path to configuration file.', ' -d, --detect', ' Run the tool in detect mode, returning detected options.', - ' -f, --fix', - ' Run the tool in fixer mode, modifying files when possible.', + ' -l, --lint', + ' Run the tool in linter mode, without modifying files.', ' -h, --help', ' Display help message.', ' -v, --verbose', @@ -119,6 +115,7 @@ function getConfig() { applyTemplate(config); if (options.verbose) config.verbose = options.verbose; + if (options.lint) config.lint = options.lint; return config; } @@ -155,15 +152,21 @@ function processFiles(files) { return a + b; }, 0); - if (config.verbose) { + var changed = options.lint ? 0 : tbchanged; + + if (options.verbose) { let message = [ `${c.length} file${c.length === 1 ? '' : 's'} processed`, - `${tbchanged} file${tbchanged === 1 ? '' : 's'} fixed`, + `${changed} file${changed === 1 ? '' : 's'} fixed`, '' ].join('\n'); process.stdout.write(message); } + if (options.lint && tbchanged) { + process.exit(1); + } + process.exit(0); }); } @@ -181,63 +184,3 @@ function processInputData(input) { process.exit(0); }); } - -function lintFiles(files) { - let anyErrorsFound = false; - - const promises = files.map(file => { - return comb.lintPath(file).then(errors => { - if (!errors.length) { - return; - } - - anyErrorsFound = true; - const message = formatErrors(file, errors); - process.stdout.write(message); - }); - }); - - Promise.all(promises).catch(error => { - process.stderr.write(error.message); - process.exit(1); - }).then(function() { - if (anyErrorsFound) { - process.exit(1); - } else { - process.exit(0); - } - }); -} - -function formatErrors(fileName, errors) { - let message = []; - - errors.forEach(error => { - message.push( - error.message + ' at ' + fileName + ':' + error.line, - error.context, - '', - '' - ); - }); - - return message.join('\n'); -} - -function lintSTDIN() { - getInputData.then(lintInputData); -} - -function lintInputData(input) { - comb.lintString(input).catch(e => { - process.stderr.write(e.message); - process.exit(1); - }).then(output => { - if (!output.length) { - process.exit(0); - } else { - process.stdout.write(output); - process.exit(1); - } - }); -} diff --git a/src/core.js b/src/core.js index 2ee7fd1d..ca049611 100644 --- a/src/core.js +++ b/src/core.js @@ -197,10 +197,16 @@ class Comb { resolve(0); } - return vfs.write(path, processedData, 'utf8').then(function() { - if (that.verbose) console.log('✓', path); + let tick = that.lint ? '!' : '✓'; + if (that.lint) { + if (that.verbose) console.log(tick, path); resolve(1); - }); + } else { + return vfs.write(path, processedData, 'utf8').then(function() { + if (that.verbose) console.log(tick, path); + resolve(1); + }); + } }); }); }); From da43ff73307caaa27aafb4cc5ba06ba80fe63512 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 8 Feb 2017 17:17:17 +0100 Subject: [PATCH 155/184] [gpe] Update GPE to v3.4.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e639676d..77b1cf66 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "glob": "latest", - "gonzales-pe": "^3.3.6", + "gonzales-pe": "^3.4.7", "minimatch": "3.0.2", "minimist": "1.1.x", "vow": "0.4.4", From 0ac44e1baffea2cb436bf88e04c792a6c98924b6 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Wed, 8 Feb 2017 17:20:13 +0100 Subject: [PATCH 156/184] [tools] Update Travis config --- .travis.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 650c6dfb..2c4c96ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,6 @@ language: node_js - node_js: - - "iojs" - - "0.10" - - "0.11" - - "0.12" - -matrix: - allow_failures: - - node_js: "0.11" + - '7' + - '6' + - '5' + - '4' From 44642f9146f432c8521f3b45207cec65330d7b62 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 16 Feb 2017 13:10:58 +0100 Subject: [PATCH 157/184] Add note about maintenance mode --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 58895922..0e6fb4ee 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,14 @@ It was inspired by [@miripiruni](https://github.com/miripiruni)'s This is the new JavaScript version, based on the powerful CSS parser [Gonzales PE](https://github.com/tonyganch/gonzales-pe). +## 0. Maintenance mode + +The tool is no longer being developed though we may still fix parsing errors and critical bugs. +That means that you should not expect any new features or options. + +If you'd like to become a maintainer of this project, please ping +[@tonyganch](https://github.com/tonyganch). + ## 1. Install Global installation (for use as a command-line tool): From 7d19f6dbbc125c739a00f51c222c658d50b30a88 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 16 Feb 2017 13:27:32 +0100 Subject: [PATCH 158/184] [cli] Don't print file path in lint mode twice --- src/core.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core.js b/src/core.js index ca049611..2d739d7f 100644 --- a/src/core.js +++ b/src/core.js @@ -195,6 +195,7 @@ class Comb { if (data === processedData) { if (that.verbose) console.log(' ', path); resolve(0); + return; } let tick = that.lint ? '!' : '✓'; From fa37c58a4ee0255ebfb37552aefd17c03399ff1e Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Thu, 16 Feb 2017 13:21:36 +0100 Subject: [PATCH 159/184] v4.0.0 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 794cec0c..7f00f350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.0.0 - 2017-02-16 + +- Added note about maintenance mode +- Updated GPE to v3.4.7, which fixed a number of errors +- Added `lines-between-rulesets` option +- Added support for stdin in cli +- For `sort-order` option, divided `$include` into `$extend`, `$include name` and `$include` + ## 3.1.7 - 2015-06-09 - Do not remove units from values starting from zeroes, like `0.5em` (#394) diff --git a/package.json b/package.json index 77b1cf66..e256bab2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "4.0.0-alpha", + "version": "4.0.0", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From ecea23d2883db1aa1d064026219af0fda68425c0 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 28 Feb 2017 20:37:52 +0100 Subject: [PATCH 160/184] Add babel-polyfill to dependencies --- package.json | 1 + src/core.js | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e256bab2..2144c858 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "node": ">= 0.10.0" }, "dependencies": { + "babel-polyfill": "6.23.0", "glob": "latest", "gonzales-pe": "^3.4.7", "minimatch": "3.0.2", diff --git a/src/core.js b/src/core.js index 2d739d7f..1962dc19 100644 --- a/src/core.js +++ b/src/core.js @@ -1,9 +1,8 @@ 'use strict'; -if (!global._babelPolyfill) { - require('babel-polyfill'); -} +require('babel-polyfill'); + let fs = require('fs'); let gonzales = require('gonzales-pe'); let minimatch = require('minimatch'); From 4bbdac36231d93199687004e2890e760412dc9fd Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 28 Feb 2017 20:38:46 +0100 Subject: [PATCH 161/184] v4.0.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f00f350..7406e038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 4.0.1 - 2017-02-28 + +- Added `babel-polyfill` to dependencies. + ## 4.0.0 - 2017-02-16 - Added note about maintenance mode diff --git a/package.json b/package.json index 2144c858..62f19838 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "4.0.0", + "version": "4.0.1", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From cdc3da4832a8f9399ef2dde0103beafa9f6c5d45 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 23 Mar 2017 14:52:30 +0100 Subject: [PATCH 162/184] fix endless loop with empty files --- src/core.js | 5 ++++- test/core/scss/empty.scss | 0 test/core/scss/test.js | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/core/scss/empty.scss diff --git a/src/core.js b/src/core.js index 1962dc19..b2a50b4a 100644 --- a/src/core.js +++ b/src/core.js @@ -346,8 +346,11 @@ class Comb { let filename = options && options.filename || ''; let context = options && options.context; let tree; + const lint = this.lint; - if (!text) return this.lint ? [] : text; + if (!text) return new Promise(function(resolve) { + resolve(lint ? [] : text); + }); if (!syntax) syntax = 'css'; this.syntax = syntax; diff --git a/test/core/scss/empty.scss b/test/core/scss/empty.scss new file mode 100644 index 00000000..e69de29b diff --git a/test/core/scss/test.js b/test/core/scss/test.js index 66782d7f..06c50d67 100644 --- a/test/core/scss/test.js +++ b/test/core/scss/test.js @@ -169,6 +169,13 @@ describe('scss', function() { return test.shouldBeEqual('content.scss'); }); + it('Should parse an empty file', function() { + let test = new Test(this); + test.comb.configure({}); + + return test.shouldBeEqual('empty.scss'); + }); + it('Should parse functions', function() { let test = new Test(this); test.comb.configure({}); From d96dc21edda9e4d884d328992e5b729270cd5eb7 Mon Sep 17 00:00:00 2001 From: Jonathan Suh Date: Thu, 6 Apr 2017 09:37:16 -0500 Subject: [PATCH 163/184] Include all flexbox properties in config files. --- config/csscomb.json | 52 ++++++++++++++++++++++++++++--- config/yandex.json | 52 ++++++++++++++++++++++++++++--- config/zen.json | 74 ++++++++++++++++++++++++++++++--------------- 3 files changed, 145 insertions(+), 33 deletions(-) diff --git a/config/csscomb.json b/config/csscomb.json index 66c806fb..e4083333 100644 --- a/config/csscomb.json +++ b/config/csscomb.json @@ -62,11 +62,55 @@ "-ms-overflow-y", "clip", "zoom", + "-webkit-align-content", + "-ms-flex-line-pack", + "align-content", + "-webkit-box-align", + "-webkit-align-items", + "-moz-box-align", + "-ms-flex-align", + "align-items", + "-webkit-align-self", + "-ms-flex-item-align", + "-ms-grid-row-align", + "align-self", + "-webkit-box-flex", + "-webkit-flex", + "-moz-box-flex", + "-ms-flex", + "flex", + "-webkit-flex-flow", + "-ms-flex-flow", + "flex-flow", + "-webkit-flex-basis", + "-ms-flex-preferred-size", + "flex-basis", + "-webkit-box-orient", + "-webkit-box-direction", + "-webkit-flex-direction", + "-moz-box-orient", + "-moz-box-direction", + "-ms-flex-direction", "flex-direction", - "flex-order", - "flex-pack", - "flex-align", - "flex" + "-webkit-flex-grow", + "-ms-flex-positive", + "flex-grow", + "-webkit-flex-shrink", + "-ms-flex-negative", + "flex-shrink", + "-webkit-flex-wrap", + "-ms-flex-wrap", + "flex-wrap", + "-webkit-box-pack", + "-webkit-justify-content", + "-moz-box-pack", + "-ms-flex-pack", + "justify-content", + "-webkit-box-ordinal-group", + "-webkit-order", + "-moz-box-ordinal-group", + "-ms-flex-order", + "order" ], [ "-webkit-box-sizing", diff --git a/config/yandex.json b/config/yandex.json index d6001553..c8bac73f 100644 --- a/config/yandex.json +++ b/config/yandex.json @@ -26,11 +26,55 @@ "-webkit-overflow-scrolling", "clip", "zoom", + "-webkit-align-content", + "-ms-flex-line-pack", + "align-content", + "-webkit-box-align", + "-webkit-align-items", + "-moz-box-align", + "-ms-flex-align", + "align-items", + "-webkit-align-self", + "-ms-flex-item-align", + "-ms-grid-row-align", + "align-self", + "-webkit-box-flex", + "-webkit-flex", + "-moz-box-flex", + "-ms-flex", + "flex", + "-webkit-flex-flow", + "-ms-flex-flow", + "flex-flow", + "-webkit-flex-basis", + "-ms-flex-preferred-size", + "flex-basis", + "-webkit-box-orient", + "-webkit-box-direction", + "-webkit-flex-direction", + "-moz-box-orient", + "-moz-box-direction", + "-ms-flex-direction", "flex-direction", - "flex-order", - "flex-pack", - "flex-align", - "flex" + "-webkit-flex-grow", + "-ms-flex-positive", + "flex-grow", + "-webkit-flex-shrink", + "-ms-flex-negative", + "flex-shrink", + "-webkit-flex-wrap", + "-ms-flex-wrap", + "flex-wrap", + "-webkit-box-pack", + "-webkit-justify-content", + "-moz-box-pack", + "-ms-flex-pack", + "justify-content", + "-webkit-box-ordinal-group", + "-webkit-order", + "-moz-box-ordinal-group", + "-ms-flex-order", + "order" ], [ "-webkit-box-sizing", diff --git a/config/zen.json b/config/zen.json index b57e3ed6..deaa6bb7 100644 --- a/config/zen.json +++ b/config/zen.json @@ -13,33 +13,8 @@ "z-index", "display", "visibility", - "-webkit-flex-direction", - "-moz-flex-direction", - "-ms-flex-direction", - "-o-flex-direction", - "flex-direction", - "-webkit-flex-order", - "-moz-flex-order", - "-ms-flex-order", - "-o-flex-order", - "flex-order", - "-webkit-flex-pack", - "-moz-flex-pack", - "-ms-flex-pack", - "-o-flex-pack", - "flex-pack", "float", "clear", - "-webkit-flex-align", - "-moz-flex-align", - "-ms-flex-align", - "-o-flex-align", - "flex-align", - "-webkit-flex", - "-moz-flex", - "-ms-flex", - "-o-flex", - "flex", "overflow", "-ms-overflow-x", "-ms-overflow-y", @@ -47,6 +22,55 @@ "overflow-y", "-webkit-overflow-scrolling", "clip", + "-webkit-align-content", + "-ms-flex-line-pack", + "align-content", + "-webkit-box-align", + "-webkit-align-items", + "-moz-box-align", + "-ms-flex-align", + "align-items", + "-webkit-align-self", + "-ms-flex-item-align", + "-ms-grid-row-align", + "align-self", + "-webkit-box-flex", + "-webkit-flex", + "-moz-box-flex", + "-ms-flex", + "flex", + "-webkit-flex-flow", + "-ms-flex-flow", + "flex-flow", + "-webkit-flex-basis", + "-ms-flex-preferred-size", + "flex-basis", + "-webkit-box-orient", + "-webkit-box-direction", + "-webkit-flex-direction", + "-moz-box-orient", + "-moz-box-direction", + "-ms-flex-direction", + "flex-direction", + "-webkit-flex-grow", + "-ms-flex-positive", + "flex-grow", + "-webkit-flex-shrink", + "-ms-flex-negative", + "flex-shrink", + "-webkit-flex-wrap", + "-ms-flex-wrap", + "flex-wrap", + "-webkit-box-pack", + "-webkit-justify-content", + "-moz-box-pack", + "-ms-flex-pack", + "justify-content", + "-webkit-box-ordinal-group", + "-webkit-order", + "-moz-box-ordinal-group", + "-ms-flex-order", + "order", "-webkit-box-sizing", "-moz-box-sizing", "box-sizing", From cece432d5e44d03d9a451ca86894eaeacd1cceb9 Mon Sep 17 00:00:00 2001 From: Philip von Bargen Date: Thu, 6 Apr 2017 14:40:29 -0400 Subject: [PATCH 164/184] Only call functions on existing sibling nodes --- src/options/remove-empty-rulesets.js | 3 ++- src/options/space-after-colon.js | 8 +++++--- src/options/space-after-combinator.js | 12 ++++++++---- src/options/space-after-selector-delimiter.js | 1 + src/options/space-before-colon.js | 6 ++++-- src/options/space-before-combinator.js | 11 +++++++---- src/options/space-before-selector-delimiter.js | 6 ++++-- src/options/space-between-declarations.js | 2 +- 8 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/options/remove-empty-rulesets.js b/src/options/remove-empty-rulesets.js index 923d86e8..faafd51f 100644 --- a/src/options/remove-empty-rulesets.js +++ b/src/options/remove-empty-rulesets.js @@ -25,7 +25,8 @@ module.exports = (function() { function mergeAdjacentWhitespace(node) { var i = node.content.length - 1; while (i-- > 0) { - if (node.get(i).is('space') && node.get(i + 1).is('space')) { + if (node.get(i).is('space') && + node.get(i + 1) && node.get(i + 1).is('space')) { node.get(i).content += node.get(i + 1).content; node.removeChild(i + 1); } diff --git a/src/options/space-after-colon.js b/src/options/space-after-colon.js index e962d526..bd3007fb 100644 --- a/src/options/space-after-colon.js +++ b/src/options/space-after-colon.js @@ -27,7 +27,7 @@ module.exports = { return null; // Remove any spaces after colon: - if (parent.get(i + 1).is('space')) + if (parent.get(i + 1) && parent.get(i + 1).is('space')) parent.removeChild(i + 1); // If the value set in config is not empty, add spaces: if (value !== '') { @@ -51,8 +51,10 @@ module.exports = { let detected = []; ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { - if (parent.get(i + 1).is('space')) { - detected.push(parent.get(i + 1).content); + var nextNode = parent.get(i + 1); + + if (nextNode.is('space')) { + detected.push(nextNode.content); } else { detected.push(''); } diff --git a/src/options/space-after-combinator.js b/src/options/space-after-combinator.js index a951b26a..556204b4 100644 --- a/src/options/space-after-combinator.js +++ b/src/options/space-after-combinator.js @@ -23,8 +23,10 @@ module.exports = { let value = this.value; ast.traverseByType('combinator', function(combinator, i, parent) { - if (parent.get(i + 1).is('space')) { - parent.get(i + 1).content = value; + var nextNode = parent.get(i + 1); + + if (nextNode && nextNode.is('space')) { + nextNode.content = value; } else { var space = gonzales.createNode({ type: 'space', @@ -44,8 +46,10 @@ module.exports = { let detected = []; ast.traverseByType('combinator', function(combinator, i, parent) { - if (parent.get(i + 1).is('space')) { - detected.push(parent.get(i + 1).content); + var nextNode = parent.get(i + 1); + + if (nextNode.is('space')) { + detected.push(nextNode.content); } else { detected.push(''); } diff --git a/src/options/space-after-selector-delimiter.js b/src/options/space-after-selector-delimiter.js index 636f7606..995ed373 100644 --- a/src/options/space-after-selector-delimiter.js +++ b/src/options/space-after-selector-delimiter.js @@ -26,6 +26,7 @@ module.exports = { if (parent.is('arguments')) return; var nextNode = parent.get(i + 1); + if (!nextNode) return; if (nextNode.is('space')) { nextNode.content = value; diff --git a/src/options/space-before-colon.js b/src/options/space-before-colon.js index a62bb25f..1490bcb3 100644 --- a/src/options/space-before-colon.js +++ b/src/options/space-before-colon.js @@ -51,8 +51,10 @@ module.exports = { let detected = []; ast.traverseByType('propertyDelimiter', function(delimiter, i, parent) { - if (parent.get(i - 1).is('space')) { - detected.push(parent.get(i - 1).content); + var previousNode = parent.get(i - 1); + + if (previousNode && previousNode.is('space')) { + detected.push(previousNode.content); } else { detected.push(''); } diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index 2a91c098..ab2584ab 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -23,8 +23,9 @@ module.exports = { let value = this.value; ast.traverseByType('combinator', function(combinator, i, parent) { - if (parent.get(i - 1).is('space')) { - parent.get(i - 1).content = value; + var previousNode = parent.get(i - 1); + if (previousNode && previousNode.is('space')) { + previousNode.content = value; } else { var space = gonzales.createNode({ type: 'space', @@ -44,8 +45,10 @@ module.exports = { let detected = []; ast.traverseByType('combinator', function(combinator, i, parent) { - if (parent.get(i - 1).is('space')) { - detected.push(parent.get(i - 1).content); + var previousNode = parent.get(i - 1); + + if (previousNode && previousNode.is('space')) { + detected.push(previousNode.content); } else { detected.push(''); } diff --git a/src/options/space-before-selector-delimiter.js b/src/options/space-before-selector-delimiter.js index a116c6af..29f153e2 100644 --- a/src/options/space-before-selector-delimiter.js +++ b/src/options/space-before-selector-delimiter.js @@ -26,7 +26,8 @@ module.exports = { if (parent.is('arguments')) return; var previousNode = parent.get(i - 1); - if (previousNode.is('space')) { + + if (previousNode && previousNode.is('space')) { previousNode.content = value; } else { var space = gonzales.createNode({ @@ -50,7 +51,8 @@ module.exports = { if (parent.is('arguments')) return; var previousNode = parent.get(i - 1); - if (previousNode.is('space')) { + + if (previousNode && previousNode.is('space')) { detected.push(previousNode.content); } else { detected.push(''); diff --git a/src/options/space-between-declarations.js b/src/options/space-between-declarations.js index 91e970e4..2c14e60c 100644 --- a/src/options/space-between-declarations.js +++ b/src/options/space-between-declarations.js @@ -82,7 +82,7 @@ module.exports = (function() { } var nextNode = parent.get(i + 1); - if (nextNode.is('space')) { + if (nextNode && nextNode.is('space')) { nextNode.content = value; } else { var space = gonzales.createNode({ From 3f427137a697a9271c128d67f0aeae8f8d54086b Mon Sep 17 00:00:00 2001 From: Vyacheslav Moskalenko Date: Thu, 6 Apr 2017 00:41:37 +0300 Subject: [PATCH 165/184] Add new --tty-mode option for cli --- doc/usage-cli.md | 1 + src/cli.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/usage-cli.md b/doc/usage-cli.md index 3435e365..1f0a37fa 100644 --- a/doc/usage-cli.md +++ b/doc/usage-cli.md @@ -37,6 +37,7 @@ csscomb -h -c, --config [path] configuration file path -d, --detect detect mode (would return detected options) -l, --lint in case some fixes needed returns an error + -t, --tty-mode execution in TTY mode (useful, when running tool using external app, e.g. IDE) ``` ### config diff --git a/src/cli.js b/src/cli.js index fbbc2ec3..54f00d5a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -43,7 +43,7 @@ if (options.detect) { var config = getConfig(); comb.configure(config); -if (process.stdin.isTTY) { +if (options.ttymode || process.stdin.isTTY) { processFiles(options._); } else { processSTDIN(); @@ -58,7 +58,8 @@ function getOptions() { detect: 'd', lint: 'l', help: 'h', - verbose: 'v' + verbose: 'v', + 'tty-mode': 't' } }; return parseArgs(process.argv.slice(2), parserOptions); @@ -83,7 +84,9 @@ function displayHelp() { ' -h, --help', ' Display help message.', ' -v, --verbose', - ' Whether to print logging info.' + ' Whether to print logging info.', + ' -t, --tty-mode', + ' Run the tool in TTY mode using external app (e.g. IDE).' ]; process.stdout.write(help.join('\n')); } From 16ad316e1ebcfb8d5fd7fa3beef2d183d7248223 Mon Sep 17 00:00:00 2001 From: Viacheslav Moskalenko Date: Thu, 6 Apr 2017 14:00:27 +0300 Subject: [PATCH 166/184] Fix for wrong key in cli options --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 54f00d5a..6d6fc3fc 100644 --- a/src/cli.js +++ b/src/cli.js @@ -43,7 +43,7 @@ if (options.detect) { var config = getConfig(); comb.configure(config); -if (options.ttymode || process.stdin.isTTY) { +if (options['tty-mode'] || process.stdin.isTTY) { processFiles(options._); } else { processSTDIN(); From 97b1e550aba4c56b71bf947e5c329f71d2eaa4ed Mon Sep 17 00:00:00 2001 From: drugan Date: Sat, 13 May 2017 12:23:42 +0300 Subject: [PATCH 167/184] Add empty new line in the end of cli help text --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 6d6fc3fc..7e9df98d 100644 --- a/src/cli.js +++ b/src/cli.js @@ -88,7 +88,7 @@ function displayHelp() { ' -t, --tty-mode', ' Run the tool in TTY mode using external app (e.g. IDE).' ]; - process.stdout.write(help.join('\n')); + process.stdout.write(help.join('\n') + '\n'); } function detectConfig() { From 3c20e095e7e9515c4c9c4835aa201a6fb2d8fc32 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Tue, 16 May 2017 11:37:19 +0200 Subject: [PATCH 168/184] v4.1.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7406e038..74806592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.1.0 - 2017-05-16 + +- Added new `--tty-mode` option for cli. +- Fixed an issue with calling gpe methods on non-existing nodes. + ## 4.0.1 - 2017-02-28 - Added `babel-polyfill` to dependencies. diff --git a/package.json b/package.json index 62f19838..565952b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "4.0.1", + "version": "4.1.0", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From 4e5bc0b7ce8a7438cfb717b37d399b01ed3ae8a2 Mon Sep 17 00:00:00 2001 From: Oleksii Okhrymenko Date: Mon, 29 May 2017 13:59:12 +0300 Subject: [PATCH 169/184] Update README.md project is now actively maintained --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0e6fb4ee..94da9d3d 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,6 @@ It was inspired by [@miripiruni](https://github.com/miripiruni)'s This is the new JavaScript version, based on the powerful CSS parser [Gonzales PE](https://github.com/tonyganch/gonzales-pe). -## 0. Maintenance mode - -The tool is no longer being developed though we may still fix parsing errors and critical bugs. -That means that you should not expect any new features or options. - -If you'd like to become a maintainer of this project, please ping -[@tonyganch](https://github.com/tonyganch). - ## 1. Install Global installation (for use as a command-line tool): @@ -75,9 +67,12 @@ comb.processPath('assets/css'); ## 4. Contribute -Anyone and everyone is welcome to contribute. +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 +[@tonyganch](https://github.com/tonyganch). + ## Authors [@mishanga](https://github.com/mishanga), From 70f38b2db120a2b052e647865465a87b1f450166 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 1 Jun 2017 16:12:26 +0700 Subject: [PATCH 170/184] Update vow-fs Update vow-fs to prevent warning: ``` npm WARN deprecated node-uuid@1.4.0: Use uuid module instead ``` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 565952b1..bf25b14b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "minimatch": "3.0.2", "minimist": "1.1.x", "vow": "0.4.4", - "vow-fs": "0.3.2" + "vow-fs": "0.3.6" }, "devDependencies": { "babel-cli": "^6.11.4", From 0028e608ec7ce55a9664419fda1667d8df75d400 Mon Sep 17 00:00:00 2001 From: Oleksii Okhrymenko Date: Mon, 12 Jun 2017 04:37:48 +0500 Subject: [PATCH 171/184] =?UTF-8?q?Replace=20=E2=80=98\n=E2=80=99=20with?= =?UTF-8?q?=20os.EOL=20(#524)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli.js | 8 +++++--- src/core.js | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cli.js b/src/cli.js index 7e9df98d..c5e2cf18 100644 --- a/src/cli.js +++ b/src/cli.js @@ -9,6 +9,7 @@ var fs = require('fs'); var parseArgs = require('minimist'); var path = require('path'); +var os = require('os'); var Comb = require('./csscomb'); var Errors = require('./errors'); @@ -86,9 +87,10 @@ function displayHelp() { ' -v, --verbose', ' Whether to print logging info.', ' -t, --tty-mode', - ' Run the tool in TTY mode using external app (e.g. IDE).' + ' Run the tool in TTY mode using external app (e.g. IDE).', + '' ]; - process.stdout.write(help.join('\n') + '\n'); + process.stdout.write(help.join(os.EOL)); } function detectConfig() { @@ -162,7 +164,7 @@ function processFiles(files) { `${c.length} file${c.length === 1 ? '' : 's'} processed`, `${changed} file${changed === 1 ? '' : 's'} fixed`, '' - ].join('\n'); + ].join(os.EOL); process.stdout.write(message); } diff --git a/src/core.js b/src/core.js index b2a50b4a..b545a1db 100644 --- a/src/core.js +++ b/src/core.js @@ -4,6 +4,7 @@ require('babel-polyfill'); let fs = require('fs'); +var os = require('os'); let gonzales = require('gonzales-pe'); let minimatch = require('minimatch'); let Errors = require('./errors'); @@ -145,7 +146,7 @@ class Comb { result.push(ln + ' | ' + line); } } - return result.join('\n'); + return result.join(os.EOL); } /** @@ -364,7 +365,7 @@ class Comb { let message = filename ? [filename] : []; message.push(e.message); message.push('CSScomb Core version: ' + version); - e.stack = e.message = message.join('\n'); + e.stack = e.message = message.join(os.EOL); throw e; } }); From 58a898f63f45f53ae1901209ca5180355bc9e6ee Mon Sep 17 00:00:00 2001 From: Oleksii Okhrymenko Date: Mon, 12 Jun 2017 05:31:44 +0500 Subject: [PATCH 172/184] Align prefix spacing #507 --- config/csscomb.json | 6 +++--- config/yandex.json | 6 +++--- config/zen.json | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/csscomb.json b/config/csscomb.json index e4083333..bb27a4eb 100644 --- a/config/csscomb.json +++ b/config/csscomb.json @@ -66,10 +66,10 @@ "-ms-flex-line-pack", "align-content", "-webkit-box-align", - "-webkit-align-items", "-moz-box-align", - "-ms-flex-align", + "-webkit-align-items", "align-items", + "-ms-flex-align", "-webkit-align-self", "-ms-flex-item-align", "-ms-grid-row-align", @@ -102,9 +102,9 @@ "-ms-flex-wrap", "flex-wrap", "-webkit-box-pack", - "-webkit-justify-content", "-moz-box-pack", "-ms-flex-pack", + "-webkit-justify-content", "justify-content", "-webkit-box-ordinal-group", "-webkit-order", diff --git a/config/yandex.json b/config/yandex.json index c8bac73f..ec6c5554 100644 --- a/config/yandex.json +++ b/config/yandex.json @@ -30,10 +30,10 @@ "-ms-flex-line-pack", "align-content", "-webkit-box-align", - "-webkit-align-items", "-moz-box-align", - "-ms-flex-align", + "-webkit-align-items", "align-items", + "-ms-flex-align", "-webkit-align-self", "-ms-flex-item-align", "-ms-grid-row-align", @@ -66,9 +66,9 @@ "-ms-flex-wrap", "flex-wrap", "-webkit-box-pack", - "-webkit-justify-content", "-moz-box-pack", "-ms-flex-pack", + "-webkit-justify-content", "justify-content", "-webkit-box-ordinal-group", "-webkit-order", diff --git a/config/zen.json b/config/zen.json index deaa6bb7..9f462b96 100644 --- a/config/zen.json +++ b/config/zen.json @@ -26,10 +26,10 @@ "-ms-flex-line-pack", "align-content", "-webkit-box-align", - "-webkit-align-items", "-moz-box-align", - "-ms-flex-align", + "-webkit-align-items", "align-items", + "-ms-flex-align", "-webkit-align-self", "-ms-flex-item-align", "-ms-grid-row-align", @@ -62,9 +62,9 @@ "-ms-flex-wrap", "flex-wrap", "-webkit-box-pack", - "-webkit-justify-content", "-moz-box-pack", "-ms-flex-pack", + "-webkit-justify-content", "justify-content", "-webkit-box-ordinal-group", "-webkit-order", From 2c5b8c6bd9cb4f69968d1ec4f08510dba343c02c Mon Sep 17 00:00:00 2001 From: Oleksii Okhrymenko Date: Mon, 12 Jun 2017 05:45:47 +0500 Subject: [PATCH 173/184] changelog for 4.2.0 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74806592..dda20d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 4.2.0 - 2017-06-12 + +- Fixed - align for flexbox properies (#507) +- Updated - replace '\n' with os.EOL for terminal output (#524) +- Updated - vow-fs dependency (#526) +- Fixed - Add empty new line in the end of cli help text (#516) +- Fixed - Endless loop with empty files (#506) +- Added - Include all flexbox properties in config files (#509) + ## 4.1.0 - 2017-05-16 - Added new `--tty-mode` option for cli. From 82c54ed744e9596ef04fcedda6b2d215eb578449 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Mon, 12 Jun 2017 22:59:28 +0200 Subject: [PATCH 174/184] v4.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf25b14b..2a3d4b58 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "4.1.0", + "version": "4.2.0", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From a60cb600075433590f97fed7f9f5824f665d993b Mon Sep 17 00:00:00 2001 From: Roman O Date: Tue, 27 Jun 2017 22:46:32 +0300 Subject: [PATCH 175/184] Update core.js Fix error https://github.com/csscomb/csscomb.js/issues/530 --- src/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index b545a1db..55000aa9 100644 --- a/src/core.js +++ b/src/core.js @@ -1,7 +1,7 @@ 'use strict'; - -require('babel-polyfill'); +if (!global._babelPolyfill) + require('babel-polyfill'); let fs = require('fs'); var os = require('os'); From a8e3be8aaa287c587788ca4b07d5400666d7a3ae Mon Sep 17 00:00:00 2001 From: Yurickh Date: Mon, 7 Aug 2017 12:20:54 -0300 Subject: [PATCH 176/184] Fix CONTRIBUTING.md markdown --- CONTRIBUTING.md | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5312acce..2f309ed1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,50 +7,55 @@ ## Pull requests -1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: +#### 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: - ```bash -# Clone your fork of the repo into the current directory +a. Clone your fork of the repo into the current directory +```bash git clone https://github.com//csscomb.js -# Navigate to the newly cloned directory +``` + +b. Navigate to the newly cloned directory +```bash cd csscomb.js -# Assign the original repo to a remote called `upstream` +``` + +c. Assign the original repo to a remote called `upstream` +```bash git remote add upstream https://github.com/csscomb/csscomb.js ``` -2. If you cloned a while ago, get the latest changes from upstream: +#### 2. If you cloned a while ago, get the latest changes from upstream: - ```bash +```bash git checkout dev git pull upstream dev ``` - **IMPORTANT**: We are using `dev` branch for development, not `master`. +> **IMPORTANT**: We are using `dev` branch for development, not `master`. -3. Create a topic branch for your feature, change, or fix: +#### 3. Create a topic branch for your feature, change, or fix: - ```bash +```bash git checkout -b ``` -4. Patches and features will not be accepted without tests. - Run `npm test` to check that all tests pass after you've made changes. +#### 4. Patches and features will not be accepted without tests. +Run `npm test` to check that all tests pass after you've made changes. -5. Update the `README.md` or [docs](https://github.com/csscomb/csscomb.js/tree/master/doc) if there were corresponding changes or new options. +#### 5. Update the `README.md` or [docs](https://github.com/csscomb/csscomb.js/tree/master/doc) if there were corresponding changes or new options. -6. Locally rebase the upstream development branch into your topic branch: +#### 6. Locally rebase the upstream development branch into your topic branch: - ```bash +```bash git pull --rebase upstream dev ``` -7. Push your topic branch up to your fork: - - ```bash +#### 7. Push your topic branch up to your fork: +```bash git push origin ``` -8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) to a `dev` branch with a clear title and description. +#### 8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) to a `dev` branch with a clear title and description. ## For maintainers From adcfc012dffd51fce6134325a44b7a0e7183b1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Valney?= Date: Wed, 13 Mar 2019 18:49:56 -0300 Subject: [PATCH 177/184] Ignore leading combinators Issue 551 --- src/options/space-before-combinator.js | 5 ++++- .../process/scss/test.expected.scss | 15 +++++++++++++++ .../process/scss/test.scss | 15 +++++++++++++++ .../space-before-combinator/process/test.js | 7 +++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 test/options/space-before-combinator/process/scss/test.expected.scss create mode 100644 test/options/space-before-combinator/process/scss/test.scss diff --git a/src/options/space-before-combinator.js b/src/options/space-before-combinator.js index ab2584ab..6360e6ea 100644 --- a/src/options/space-before-combinator.js +++ b/src/options/space-before-combinator.js @@ -24,7 +24,10 @@ module.exports = { ast.traverseByType('combinator', function(combinator, i, parent) { var previousNode = parent.get(i - 1); - if (previousNode && previousNode.is('space')) { + + if (!previousNode) return; + + if (previousNode.is('space')) { previousNode.content = value; } else { var space = gonzales.createNode({ diff --git a/test/options/space-before-combinator/process/scss/test.expected.scss b/test/options/space-before-combinator/process/scss/test.expected.scss new file mode 100644 index 00000000..d325dfaf --- /dev/null +++ b/test/options/space-before-combinator/process/scss/test.expected.scss @@ -0,0 +1,15 @@ +a >b { + color: red; + + & >c { + color: red; + } +} + +a { + color: red; + + >c { + color: red; + } +} diff --git a/test/options/space-before-combinator/process/scss/test.scss b/test/options/space-before-combinator/process/scss/test.scss new file mode 100644 index 00000000..f7d1894b --- /dev/null +++ b/test/options/space-before-combinator/process/scss/test.scss @@ -0,0 +1,15 @@ +a>b { + color: red; + + &>c { + color: red; + } +} + +a { + color: red; + + >c { + color: red; + } +} diff --git a/test/options/space-before-combinator/process/test.js b/test/options/space-before-combinator/process/test.js index b3f61ba2..523f3b60 100644 --- a/test/options/space-before-combinator/process/test.js +++ b/test/options/space-before-combinator/process/test.js @@ -32,4 +32,11 @@ describe('Option `space-before-combinator`, process', function() { return test.shouldBeEqual('test.css', 'test-3.expected.css'); }); }); + + describe('scss', function() { + it('Should not touch leading combinators', function() { + let test = new Test(this, {'space-before-combinator': ' '}); + return test.shouldBeEqual('test.scss', 'test.expected.scss'); + }); + }); }); From 19b97990dbd2f7afc6eade0fe740546ebb4fbba3 Mon Sep 17 00:00:00 2001 From: tenorok Date: Tue, 15 Jan 2019 18:05:03 +0300 Subject: [PATCH 178/184] [cli] TTY-option type set to boolean --- src/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index c5e2cf18..a87d6f46 100644 --- a/src/cli.js +++ b/src/cli.js @@ -53,7 +53,7 @@ if (options['tty-mode'] || process.stdin.isTTY) { function getOptions() { var parserOptions = { - boolean: ['help', 'lint', 'verbose'], + boolean: ['help', 'lint', 'verbose', 'tty-mode'], alias: { config: 'c', detect: 'd', From db14fceeb0352dd43152757e72710c2e7f888a55 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 22 Mar 2019 21:40:48 +0000 Subject: [PATCH 179/184] Update GPE version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a3d4b58..baf1ad09 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "babel-polyfill": "6.23.0", "glob": "latest", - "gonzales-pe": "^3.4.7", + "gonzales-pe": "4.2.4", "minimatch": "3.0.2", "minimist": "1.1.x", "vow": "0.4.4", From 15a5459c065809ca1ab01f3b77f79b5de2fc74c0 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Fri, 22 Mar 2019 21:45:34 +0000 Subject: [PATCH 180/184] Update list of support Node versions See https://nodejs.org/en/about/releases/ --- .travis.yml | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c4c96ee..432dbd02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - '7' + - '11' + - '10' + - '8' - '6' - - '5' - - '4' diff --git a/package.json b/package.json index baf1ad09..b9fe9c33 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ } ], "engines": { - "node": ">= 0.10.0" + "node": ">= 6.0.0" }, "dependencies": { "babel-polyfill": "6.23.0", From 55d58f439a73ea3ede8a8dd1809841068f766394 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sat, 23 Mar 2019 00:18:07 +0100 Subject: [PATCH 181/184] Duplicate #576 without dependencies --- src/cli.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli.js b/src/cli.js index a87d6f46..5965dd9b 100644 --- a/src/cli.js +++ b/src/cli.js @@ -151,6 +151,7 @@ function processFiles(files) { process.stderr.write(error.stack); process.exit(1); }).then(c => { + c = [].concat.apply([], c); var tbchanged = c.filter(isChanged => { return isChanged !== undefined; }).reduce((a, b) => { From 3e029fcde02a84c9d831acd8747691aaed083463 Mon Sep 17 00:00:00 2001 From: Jan Werkhoven Date: Fri, 27 Oct 2017 20:26:18 +1100 Subject: [PATCH 182/184] Fix ast.remove is not a function error This PR fixes an error that occurs when `"eof-newline": false,` as reported and solved here: https://github.com/Glavin001/atom-beautify/issues/1705 --- src/options/block-indent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options/block-indent.js b/src/options/block-indent.js index b5f473fb..245211e5 100644 --- a/src/options/block-indent.js +++ b/src/options/block-indent.js @@ -45,7 +45,7 @@ let option = { var spaces = whitespaceNode.content.replace(/\n[ \t]+/gm, '\n'); if (spaces === '') { - ast.remove(i); + ast.removeChild(i); } else { whitespaceNode.content = spaces; } From 9c5d02e58a93a5dff125043c2692964f6ae85cd9 Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 24 Mar 2019 05:15:07 +0100 Subject: [PATCH 183/184] v4.3.0 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda20d1a..f6ec7421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 4.3.0 - 2019-03-24 + +- Updated GPE to v4.2.4 +- Updated list of supported Node version to reflect https://nodejs.org/en/about/releases/ +- Fixed #551 +- [cli] Fixed parsing of tty-mode option as boolean + ## 4.2.0 - 2017-06-12 - Fixed - align for flexbox properies (#507) diff --git a/package.json b/package.json index b9fe9c33..96688b7f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csscomb", "description": "CSS coding style formatter", - "version": "4.2.0", + "version": "4.3.0", "homepage": "http://csscomb.com/", "author": "Mikhail Troshev ", "repository": "https://github.com/csscomb/csscomb.js", From f05188ad6a1b3ea167205689eeaaf91fd642c3ce Mon Sep 17 00:00:00 2001 From: Tony Ganch Date: Sun, 24 Mar 2019 05:14:39 +0100 Subject: [PATCH 184/184] Update versions of dependencies --- .eslintrc.js | 334 ++++ .jscs.json | 65 - package-lock.json | 4086 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 24 +- scripts/build.sh | 2 +- scripts/test.sh | 8 +- src/core.js | 2 +- 7 files changed, 4436 insertions(+), 85 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .jscs.json create mode 100644 package-lock.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..eccc6811 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,334 @@ +module.exports = { + 'env': { + 'browser': true, + 'commonjs': true, + 'es6': true + }, + 'extends': 'eslint:recommended', + 'globals': { + 'Atomics': 'readonly', + 'SharedArrayBuffer': 'readonly' + }, + 'parserOptions': { + 'ecmaVersion': 2018 + }, + 'rules': { + 'accessor-pairs': 'error', + 'array-bracket-newline': 'error', + 'array-bracket-spacing': [ + 'error', + 'never' + ], + 'array-callback-return': 'off', + 'array-element-newline': 'off', + 'arrow-body-style': 'off', + 'arrow-parens': 'off', + 'arrow-spacing': [ + 'error', + { + 'after': true, + 'before': true + } + ], + 'block-scoped-var': 'error', + 'block-spacing': 'error', + 'brace-style': [ + 'error', + '1tbs' + ], + 'callback-return': 'error', + 'camelcase': 'error', + 'capitalized-comments': 'off', + 'class-methods-use-this': 'off', + 'comma-dangle': 'error', + 'comma-spacing': [ + 'error', + { + 'after': true, + 'before': false + } + ], + 'comma-style': [ + 'error', + 'last' + ], + 'complexity': 'error', + 'computed-property-spacing': [ + 'error', + 'never' + ], + 'consistent-return': 'off', + 'consistent-this': 'error', + 'curly': 'off', + 'default-case': 'error', + 'dot-location': [ + 'error', + 'property' + ], + 'dot-notation': [ + 'error', + { + 'allowKeywords': true + } + ], + 'eol-last': 'error', + 'eqeqeq': 'error', + 'func-call-spacing': 'error', + 'func-name-matching': 'error', + 'func-names': 'off', + 'func-style': 'off', + 'function-paren-newline': 'error', + 'generator-star-spacing': 'error', + 'global-require': 'off', + 'guard-for-in': 'off', + 'handle-callback-err': 'error', + 'id-blacklist': 'error', + 'id-length': 'off', + 'id-match': 'error', + 'implicit-arrow-linebreak': [ + 'error', + 'beside' + ], + 'indent': 'off', + 'indent-legacy': 'off', + 'init-declarations': 'off', + 'jsx-quotes': 'error', + 'key-spacing': 'error', + 'keyword-spacing': [ + 'error', + { + 'after': true, + 'before': true + } + ], + 'line-comment-position': 'off', + 'linebreak-style': [ + 'error', + 'unix' + ], + 'lines-around-comment': 'off', + 'lines-around-directive': 'error', + 'lines-between-class-members': [ + 'error', + 'always' + ], + 'max-classes-per-file': 'error', + 'max-depth': 'error', + 'max-len': 'error', + 'max-lines': 'off', + 'max-lines-per-function': 'error', + 'max-nested-callbacks': 'error', + 'max-params': 'error', + 'max-statements': 'off', + 'max-statements-per-line': 'error', + 'multiline-comment-style': [ + 'error', + 'separate-lines' + ], + 'multiline-ternary': 'off', + 'new-cap': 'error', + 'new-parens': 'error', + 'newline-after-var': 'off', + 'newline-before-return': 'off', + 'newline-per-chained-call': 'off', + 'no-alert': 'error', + 'no-array-constructor': 'error', + 'no-async-promise-executor': 'error', + 'no-await-in-loop': 'error', + 'no-bitwise': 'error', + 'no-buffer-constructor': 'error', + 'no-caller': 'error', + 'no-catch-shadow': 'error', + 'no-confusing-arrow': 'error', + 'no-continue': 'off', + 'no-div-regex': 'error', + 'no-duplicate-imports': 'error', + 'no-else-return': 'off', + 'no-empty-function': 'error', + 'no-eq-null': 'error', + 'no-eval': 'error', + 'no-extend-native': 'error', + 'no-extra-bind': 'error', + 'no-extra-label': 'error', + 'no-extra-parens': 'error', + 'no-floating-decimal': 'error', + 'no-implicit-coercion': 'error', + 'no-implicit-globals': 'error', + 'no-implied-eval': 'error', + 'no-inline-comments': 'off', + 'no-inner-declarations': [ + 'error', + 'functions' + ], + 'no-invalid-this': 'error', + 'no-iterator': 'error', + 'no-label-var': 'error', + 'no-labels': 'error', + 'no-lone-blocks': 'error', + 'no-lonely-if': 'off', + 'no-loop-func': 'error', + 'no-magic-numbers': 'off', + 'no-misleading-character-class': 'error', + 'no-mixed-operators': 'off', + 'no-mixed-requires': 'error', + 'no-multi-assign': 'off', + 'no-multi-spaces': 'error', + 'no-multi-str': 'error', + 'no-multiple-empty-lines': 'error', + 'no-native-reassign': 'error', + 'no-negated-condition': 'off', + 'no-negated-in-lhs': 'error', + 'no-nested-ternary': 'error', + 'no-new': 'error', + 'no-new-func': 'error', + 'no-new-object': 'error', + 'no-new-require': 'error', + 'no-new-wrappers': 'error', + 'no-octal-escape': 'error', + 'no-param-reassign': 'off', + 'no-path-concat': 'off', + 'no-plusplus': 'off', + 'no-process-env': 'off', + 'no-process-exit': 'off', + 'no-proto': 'error', + 'no-prototype-builtins': 'off', + 'no-restricted-globals': 'error', + 'no-restricted-imports': 'error', + 'no-restricted-modules': 'error', + 'no-restricted-properties': 'error', + 'no-restricted-syntax': 'error', + 'no-return-assign': 'error', + 'no-return-await': 'error', + 'no-script-url': 'error', + 'no-self-compare': 'error', + 'no-sequences': 'error', + 'no-shadow': 'off', + 'no-shadow-restricted-names': 'error', + 'no-spaced-func': 'error', + 'no-sync': 'off', + 'no-tabs': 'error', + 'no-template-curly-in-string': 'error', + 'no-ternary': 'off', + 'no-throw-literal': 'error', + 'no-trailing-spaces': 'error', + 'no-undef-init': 'error', + 'no-undefined': 'off', + 'no-underscore-dangle': 'off', + 'no-unmodified-loop-condition': 'error', + 'no-unneeded-ternary': 'error', + 'no-unused-expressions': 'error', + 'no-use-before-define': 'off', + 'no-useless-call': 'error', + 'no-useless-catch': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-concat': 'error', + 'no-useless-constructor': 'error', + 'no-useless-rename': 'error', + 'no-useless-return': 'error', + 'no-var': 'off', + 'no-void': 'error', + 'no-warning-comments': 'off', + 'no-whitespace-before-property': 'error', + 'no-with': 'error', + 'nonblock-statement-body-position': [ + 'error', + 'any' + ], + 'object-curly-newline': 'error', + 'object-curly-spacing': [ + 'error', + 'never' + ], + 'object-shorthand': 'off', + 'one-var': 'off', + 'one-var-declaration-per-line': 'error', + 'operator-assignment': [ + 'error', + 'always' + ], + 'operator-linebreak': [ + 'error', + 'after' + ], + 'padded-blocks': 'off', + 'padding-line-between-statements': 'error', + 'prefer-arrow-callback': 'off', + 'prefer-const': 'off', + 'prefer-destructuring': 'off', + 'prefer-named-capture-group': 'error', + 'prefer-numeric-literals': 'error', + 'prefer-object-spread': 'error', + 'prefer-promise-reject-errors': [ + 'error', + { + 'allowEmptyReject': true + } + ], + 'prefer-reflect': 'off', + 'prefer-rest-params': 'error', + 'prefer-spread': 'off', + 'prefer-template': 'off', + 'quote-props': 'off', + 'quotes': [ + 'error', + 'single' + ], + 'radix': [ + 'error', + 'as-needed' + ], + 'require-atomic-updates': 'error', + 'require-await': 'error', + 'require-jsdoc': 'off', + 'require-unicode-regexp': 'off', + 'rest-spread-spacing': 'error', + 'semi': 'error', + 'semi-spacing': [ + 'error', + { + 'after': true, + 'before': false + } + ], + 'semi-style': [ + 'error', + 'last' + ], + 'sort-imports': 'error', + 'sort-keys': 'off', + 'sort-vars': 'off', + 'space-before-blocks': 'error', + 'space-before-function-paren': 'off', + 'space-in-parens': [ + 'error', + 'never' + ], + 'space-infix-ops': 'off', + 'space-unary-ops': 'error', + 'spaced-comment': [ + 'error', + 'always' + ], + 'strict': 'error', + 'switch-colon-spacing': 'error', + 'symbol-description': 'error', + 'template-curly-spacing': [ + 'error', + 'never' + ], + 'template-tag-spacing': 'error', + 'unicode-bom': [ + 'error', + 'never' + ], + 'valid-jsdoc': 'off', + 'vars-on-top': 'off', + 'wrap-iife': 'error', + 'wrap-regex': 'error', + 'yield-star-spacing': 'error', + 'yoda': [ + 'error', + 'never' + ] + } +}; diff --git a/.jscs.json b/.jscs.json deleted file mode 100644 index f34264ce..00000000 --- a/.jscs.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "disallowMultipleSpaces": true, - "disallowMultipleVarDecl": true, - "disallowNewlineBeforeBlockStatements": true, - "disallowPaddingNewlinesInBlocks": true, - "disallowSpaceBeforePostfixUnaryOperators": true, - "disallowSpacesInCallExpression": true, - "disallowSpacesInFunction": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideObjectBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowTrailingComma": true, - "disallowTrailingWhitespace": true, - "esnext": true, - "maximumLineLength": 80, - "requireBlocksOnNewline": 1, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "requireCapitalizedComments": true, - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireDotNotation": true, - "requireLineBreakAfterVariableAssignment": true, - "requireSemicolons": true, - "requireSpaceAfterBinaryOperators": true, - "requireSpaceAfterKeywords": [ - "do", - "for", - "if", - "else", - "switch", - "case", - "try", - "catch", - "while", - "return", - "typeof" - ], - "requireSpaceAfterLineComment": true, - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceBeforeBlockStatements": true, - "requireSpaceBeforeKeywords": [ - "else", - "while", - "catch" - ], - "requireSpaceBetweenArguments": true, - "requireSpacesInForStatement": true, - "validateIndentation": 2, - "validateQuoteMarks": { - "mark": "'", - "escape": true - }, - "jsDoc": { - "checkAnnotations": "closurecompiler", - "checkParamNames": true, - "checkRedundantParams": true, - "checkRedundantReturns": true, - "checkReturnTypes": true, - "checkTypes": true, - "requireParamTypes": true, - "requireReturnTypes": true - } -} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..c7f2c458 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,4086 @@ +{ + "name": "csscomb", + "version": "4.2.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/cli": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.2.3.tgz", + "integrity": "sha1-GyYuQqPpWdKKs9IFuicY4ZI8/uY=", + "dev": true, + "requires": { + "chokidar": "^2.0.3", + "commander": "^2.8.1", + "convert-source-map": "^1.1.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.0.0", + "lodash": "^4.17.10", + "mkdirp": "^0.5.1", + "output-file-sync": "^2.0.0", + "slash": "^2.0.0", + "source-map": "^0.5.0" + } + }, + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha1-BuKrGb21NThVWaq7W6WXKUgoAPg=", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/core": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.0.tgz", + "integrity": "sha1-JI/Wh0t9dVAQv+YfVXRh1PRG2ek=", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.4.0", + "@babel/helpers": "^7.4.0", + "@babel/parser": "^7.4.0", + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.0", + "@babel/types": "^7.4.0", + "convert-source-map": "^1.1.0", + "debug": "^4.1.0", + "json5": "^2.1.0", + "lodash": "^4.17.11", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo=", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", + "integrity": "sha1-wjDnlYmuenKf1GMbne1NwiBBgZY=", + "dev": true, + "requires": { + "@babel/types": "^7.4.0", + "jsesc": "^2.5.1", + "lodash": "^4.17.11", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha1-oM6wFoX3M1XUNgwSR/WCv6/I/1M=", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha1-g1ctQyDipGVyY3NBE8QoaLZOScM=", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", + "integrity": "sha1-u7P77phmHFaQNCN8wDlnupm08lA=", + "dev": true + }, + "@babel/helper-split-export-declaration": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", + "integrity": "sha1-Vxv9UnAfSSkg1jt/c1Aw6aPhC1U=", + "dev": true, + "requires": { + "@babel/types": "^7.4.0" + } + }, + "@babel/helpers": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.2.tgz", + "integrity": "sha1-O9+kalUsp371oPhVG+XwhFrpib4=", + "dev": true, + "requires": { + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.0", + "@babel/types": "^7.4.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha1-9xDDjI1Fjm3ZogGvtjf8t4HOmeQ=", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/node": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/@babel/node/-/node-7.2.2.tgz", + "integrity": "sha1-FVfdI1RbONex0DCpwOj7Il2/cKs=", + "dev": true, + "requires": { + "@babel/polyfill": "^7.0.0", + "@babel/register": "^7.0.0", + "commander": "^2.8.1", + "lodash": "^4.17.10", + "v8flags": "^3.1.1" + } + }, + "@babel/parser": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.2.tgz", + "integrity": "sha1-tFIaQAy1qHHqs4kHh7S8EybTjZE=", + "dev": true + }, + "@babel/plugin-transform-destructuring": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.4.0.tgz", + "integrity": "sha1-rLubJBjSkBB9szP01s2Kpq6gA0M=", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-strict-mode": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-strict-mode/-/plugin-transform-strict-mode-7.2.0.tgz", + "integrity": "sha1-Gv9Lmc6Ye0cVJWaph+lGnke5ZiY=", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/polyfill": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.4.0.tgz", + "integrity": "sha1-kPnWiuNKxCq0tKoDFRhI9TaWAhg=", + "requires": { + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.2" + } + }, + "@babel/register": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.4.0.tgz", + "integrity": "sha1-2dCmIdsmj7FCAPJoWk+JJMgiQEw=", + "dev": true, + "requires": { + "core-js": "^3.0.0", + "find-cache-dir": "^2.0.0", + "lodash": "^4.17.11", + "mkdirp": "^0.5.1", + "pirates": "^4.0.0", + "source-map-support": "^0.5.9" + }, + "dependencies": { + "core-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0.tgz", + "integrity": "sha1-qNv6l40pv8Jjv7ZsVW0MqSTCiVc=", + "dev": true + } + } + }, + "@babel/template": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", + "integrity": "sha1-EkdOnAd7rlhcXYNalcCwt5DCXIs=", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.4.0", + "@babel/types": "^7.4.0" + } + }, + "@babel/traverse": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.0.tgz", + "integrity": "sha1-FABpZ90dKzSUzdZQxobbna8N2to=", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.4.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.0", + "@babel/parser": "^7.4.0", + "@babel/types": "^7.4.0", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.11" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo=", + "dev": true + } + } + }, + "@babel/types": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", + "integrity": "sha1-Zwck930kzObMfYz2RZnVEdFkiUw=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + }, + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha1-fSWuBbuK0fm2mRCOEJTs14hK3B8=", + "dev": true + }, + "acorn-jsx": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", + "integrity": "sha1-MqBk/ZJUKSFqCbFBECv90YX65A4=", + "dev": true + }, + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha1-kNDVRDnaWHzX6EO/twRfUL0ivfE=", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha1-V9NbhoboUeLMBMQD8cACA5dqGBM=", + "dev": true + }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha1-h4C5j/nb9WOBUtHx/lwde0RCl2s=", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha1-vLJLTzeTTZqnrBe0ra+J58du8us=", + "dev": true, + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=", + "dev": true + }, + "async-each": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.2.tgz", + "integrity": "sha1-i4p8oqZY+Sfp8wfW0aQvQZnw9zU=", + "dev": true, + "optional": true + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha1-bZUX654DDSQ2ZmZR6GvZ9vE1M8k=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "binary-extensions": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.0.tgz", + "integrity": "sha1-lSPgATBqMkRLkHQj8d4hZCIvarE=", + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha1-WXn9PxTNUxVl5fot8av/8d+u5yk=", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA=", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha1-MnE7wCj3XAL9txDXx7zsHyxgcO8=", + "dev": true + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "callsites": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.0.0.tgz", + "integrity": "sha1-+361abcq16RYEvk/2UMKPkELPdM=", + "dev": true + }, + "camelcase": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.2.0.tgz", + "integrity": "sha1-51IqvaXtlMwEieG4RmYQ6IQEz0U=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ=", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha1-kAlISfCTfy7twkJdDSip5fDLrZ4=", + "dev": true + }, + "chokidar": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", + "integrity": "sha1-CuhDTZYigaX1bHKGnnnLbZ2GrU0=", + "dev": true, + "optional": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + } + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "^7.1.1" + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha1-NIQi2+gtgAswIu709qwQvy5NG0k=", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg=", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha1-9hmKqE5bg8RgVLlN3tv+1e6f8So=", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "convert-source-map": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha1-UbU3qMQ+DwTewZk7/83VBOdYrCA=", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-js": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz", + "integrity": "sha1-RLyNJJ5/sv9dAOA0Gn/7lPv2eJU=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha1-Sl7Hxk364iw6FBJNus3uhG2Ay8Q=", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha1-z4jabL7ib+bbcJT2HYcMvYTO6fE=", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha1-1Flono1lS6d+AqgX+HENcCyxbp0=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "dev": true + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha1-gAwN0eCov7yVg1wgKtIg/jF+WhI=", + "dev": true + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha1-rd6+rXKmV023g2OdyHoSF3OXOWE=", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "dom-serializer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha1-HsQFnihLq+027sKUHUqXChic58A=", + "dev": true, + "requires": { + "domelementtype": "^1.3.0", + "entities": "^1.1.1" + }, + "dependencies": { + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha1-vfpzUplmTfr9NFKe1PhSKidf6lY=", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha1-0EjESzew0Qp/Kj1f7j9DM9eQSB8=", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha1-kzoEBShgyF6DwSJHnEdIqOTHIVY=", + "dev": true + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha1-7SljTRm6ukY7bOa4CjchPqtx7EM=", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha1-rIYUX91QmdjdSVWMy6Lq+biOJOk=", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha1-7fckeAM0VujdqO8J4ArZZQcH83c=", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "5.15.3", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.15.3.tgz", + "integrity": "sha1-x5w5CdyKf6NxT7NAwR4w/SUmuLU=", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.9.1", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", + "eslint-utils": "^1.3.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^5.0.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.2.2", + "js-yaml": "^3.12.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo=", + "dev": true + } + } + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha1-ygODMxD2iJoyZHgaqC5j65z+eEg=", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", + "integrity": "sha1-moUbqJ7nxGA0b5fPiTnHKYgn5RI=", + "dev": true + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha1-PzGA+y4pEBdxastMnW1bXDSmqB0=", + "dev": true + }, + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha1-XWUm+k/H8HiKXPdbFfMDI+L4H3o=", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha1-QGxRZYsfWZGl+bYrHcJbAOPlxwg=", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha1-xiNqW7TfbW8V6I5/AXeYIWdJ3dg=", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "external-editor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", + "integrity": "sha1-WGbbKal4Jtvkvzr9JAcOrZ6kOic=", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha1-rQD+TcYSqSMuhxhxHcXLWrAoVUM=", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha1-yg9u+m3T1WEzP7FFFQZcL6/fQ5w=", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha1-jQ+UzRP+Q8bHwmGg2GEVypGMBfc=", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha1-SRafHXmTQwZG2mHsxa41XCHJe3M=", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "findup-sync": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", + "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha1-CQvsiwXjnLowl0fx1YjwTbr5jbI=", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + }, + "dependencies": { + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha1-Ts8/z3ScvR5HJonhCaxmJhol5yU=", + "dev": true + } + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha1-XSltbwS9pEpGMKMBQTvbwuwIXsA=", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha1-VRIrZTbqSWtLRIk+4mCBQdENmRY=", + "dev": true + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha1-4y/AMKLM7kSmtTcTCNpUvgs5fSc=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.7.tgz", + "integrity": "sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true, + "optional": true + }, + "minipass": { + "version": "2.3.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.10.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "yallist": { + "version": "3.0.3", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha1-+Xj6TJDR3+f/LWvtoqUV5xO9z0o=", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha1-wbJVV189wh1Zv8ec09K0axw6VLU=", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha1-OWCDLT8VdBCDQtr9OmezMsCWnfE=", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "optional": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=", + "dev": true, + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "globals": { + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", + "integrity": "sha1-3Pk3V/ot5Uhvvu1xGFOK33ienC4=", + "dev": true + }, + "gonzales-pe": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.2.4.tgz", + "integrity": "sha1-NWrjajEsRv4PECbdbLU5A5+FANI=", + "requires": { + "minimist": "1.1.x" + }, + "dependencies": { + "minimist": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.1.3.tgz", + "integrity": "sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=" + } + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha1-/7cD4QZuig7qpMi4C6klPu77+wA=", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha1-8nNdwig2dPpnR4sQGBBZNVw2nl4=", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha1-hK5l+n6vsWX922FWauFLrwVmTw8=", + "dev": true + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha1-dDKYzvTlrz4ZQWH7rcwhUdOgWOg=", + "dev": true, + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=", + "dev": true + }, + "import-fresh": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", + "integrity": "sha1-o9iX9CDKsOZxI2iX91vBS0iFw5A=", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "dev": true + }, + "inquirer": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.2.tgz", + "integrity": "sha1-RpQRdvZcnrIIBGJxSbdDohjyVAY=", + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.11", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.0.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha1-i5+PCM8ay4Q3Vqg5yox+MWjFGZc=", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4=", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha1-c5P1r6Weyf9fZ6J2INEcIm4+7AI=", + "dev": true + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "optional": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha1-HhrfIZ4e62hNaR+dagX/DTCiTXU=", + "dev": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha1-Nm2CQN3kh8pRgjsaufB6EKeCUco=", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha1-cpyR4thXt6QZofmqZWhcTDP1hF0=", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "optional": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha1-oFX2rlcZLK7jKeeoYBGLSXqVDzg=", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha1-GSA/tZmR35jjoocFDUZHzerzJJk=", + "dev": true + }, + "js-yaml": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz", + "integrity": "sha1-OO5xeKwO6iyX/22W//SxjH2M+Y4=", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q=", + "dev": true + }, + "jshint": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", + "integrity": "sha1-7WYmxPgiPJjpSq6mJ2dDVCekmj0=", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.11", + "minimatch": "~3.0.2", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x" + }, + "dependencies": { + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + } + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "json5": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha1-56DGLEgoXGKNIKELhcibuAfDKFA=", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha1-ARRrNqYhjmTljzqNZt5df8b20FE=", + "dev": true + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha1-bvXS32DlL4LrIopMNz6NHzlyU88=", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha1-2+w7OrdZdYBxtY/ln8QYca8hQA4=", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha1-s56mIp72B+zYniyN8SU2iRysm40=", + "dev": true + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha1-V0Dhxdbw39pK2TI7UzIQfva0xAo=", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha1-XwMQ4YuL6JjMBwCSlaMK5B6R5vU=", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha1-fVg6cwZDTAVf5HSw9FB45uG0uSo=", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "mem": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.2.0.tgz", + "integrity": "sha1-XuBXaA7Zy42tinjYIPmoiXoQICU=", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.0.0.tgz", + "integrity": "sha1-CRP/CxIdtE71hIJCw4u7NdRMq94=", + "dev": true + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha1-cIWbyVyYQJUvNZoGij/En57PrCM=", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha1-ggyGo5M0ZA6ZUWkovQP8qIBX0CI=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha1-pJ5yaNzhoNlpjkUybFYm3zVD0P4=", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "mocha": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.2.tgz", + "integrity": "sha1-zcGm/fZkcsB5tWBbrFnSmAdwLSw=", + "dev": true, + "requires": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "findup-sync": "2.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.12.0", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.4", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "12.0.5", + "yargs-parser": "11.1.1", + "yargs-unparser": "1.5.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha1-6D0X3hbYp++3cX7b5fsQE17uYps=", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha1-6u1lbsg0TxD1J8a/obbiJE3hZ9E=", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo=", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha1-ds/nQs8fQbubHCmtAwaMBbTA5Ao=", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "nan": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.1.tgz", + "integrity": "sha512-I6YB/YEuDeUZMmhscXKxGgZlFnhsn5y0hgOZBadkzfTRrZBtJDZeg6eQf7PYMIEclwmorTKK8GztsyOUSVBREA==", + "dev": true, + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha1-uHqKpPwN6P5r6IiVs4mD/yZb0Rk=", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha1-ozeKdpbOfSI+iPybdkvX7xCJ42Y=", + "dev": true + }, + "node-environment-flags": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.4.tgz", + "integrity": "sha1-C3hKZVFCa/wW07IghCTcvCsv8Dg=", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3" + } + }, + "node-modules-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", + "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=", + "dev": true, + "optional": true + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", + "integrity": "sha1-Eb0iNI3S4JagRasG9shbzDQPoDI=", + "dev": true + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha1-lovxEA15Vrs8oIbwBvhGs7xACNo=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha1-qAKm7hfyTBBIOrmTVxnO9O0Wvxo=", + "dev": true, + "requires": { + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "output-file-sync": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-2.0.1.tgz", + "integrity": "sha1-9TEYKC9fVTwnmVQXkrcjpMcUMMA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "is-plain-obj": "^1.1.0", + "mkdirp": "^0.5.1" + } + }, + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-is-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", + "integrity": "sha1-dVTj1XIQmofh8/U/an2F0bGU9MU=", + "dev": true + }, + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha1-QXyZQeYCepq8ulCS3SkE4lW1+8I=", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha1-Mi1poFwCZLJZl9n0DNiokasAZKQ=", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", + "integrity": "sha1-waDxAw6X3gGLsscYkp0q9ZRj5QU=", + "dev": true + }, + "parent-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.0.tgz", + "integrity": "sha1-3yUL3FOR9KCF+1idrXYfWta4ZbU=", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true, + "optional": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=", + "dev": true + }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha1-SyzSXFDVmHNcUCkiJP2MbfQeMjE=", + "dev": true + }, + "pirates": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", + "integrity": "sha1-ZDqSyviUVm+RsrmG0sZpUKji+4c=", + "dev": true, + "requires": { + "node-modules-regexp": "^1.0.0" + } + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha1-J0kCDyOe2ZCIGx9xIQ1R62UjvqM=", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "dev": true, + "optional": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha1-foz42PW48jnBvGi+tOt4Vn1XLvg=", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha1-tKIRaBW94vTh6mAjVOjHVWUQemQ=", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha1-sRwn2IuP8fvgcGQ8+UsMea4bCq8=", + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha1-DodiKjMlqjPokihcr4tOhGUppSU=", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + }, + "regenerator-runtime": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", + "integrity": "sha1-MuWcmm+5saSv8JtJMMotRHc0NEc=" + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha1-H07OJ+ALC2XgJHpoEOaoXYOldSw=", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=", + "dev": true + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true, + "optional": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha1-eC4NglwMWjuzlzH4Tv7mt0Lmsc4=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "resolve": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", + "integrity": "sha1-O9qur0XMB/N1ZW39LlTtCBCxAbo=", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha1-SrzYUq0y3Xuqv+m0DgCjbbXzkuY=", + "dev": true + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=", + "dev": true + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha1-stEE/g2Psnz54KHNqCYt04M8bKs=", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", + "integrity": "sha1-87sP572n+2nerAwW8XtQsLh5BQQ=", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0=", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=", + "dev": true + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha1-fnQlb7qknHWqfHogXMInmcrIAAQ=", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha1-3lUoUaF1nfOo8gZTVEL17E3eq0Q=", + "dev": true + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha1-ys12k0YaY3pXiNkqfdT7oGjoFjY=", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + } + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha1-ZJIufFZbDhQgS6GqfWlkJ40lGC0=", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha1-cuLMNAlVQ+Q7LGKyxMENSpBU8lk=", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-support": { + "version": "0.5.11", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.11.tgz", + "integrity": "sha1-76ws4IADVdAmMmoMoj4WKurJpOI=", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "dev": true + } + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "table": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/table/-/table-5.2.3.tgz", + "integrity": "sha1-zeDMbrBnUcAJ76sn6Mggyltnt/I=", + "dev": true, + "requires": { + "ajv": "^6.9.1", + "lodash": "^4.17.11", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha1-i5+PCM8ay4Q3Vqg5yox+MWjFGZc=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha1-InZ74htirxCBV0MG9prFG2IgOWE=", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4=", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha1-E8/dmzNlUvMLUfM6iuG0Knp1mc4=", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "upath": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha1-PbZYYA7a7sy+bbXmhNZ+6MKs0Gg=", + "dev": true, + "optional": true + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha1-lMVA4f93KVbiKZUHwBCupsiDjrA=", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha1-1QyMrHmhn7wg8pEfVuuXP04QBw8=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true, + "optional": true + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" + }, + "v8flags": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.2.tgz", + "integrity": "sha1-/FzQwidCgYHmwpspkuT48dpeDJ8=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "vow": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/vow/-/vow-0.4.19.tgz", + "integrity": "sha1-zF701rtpctgwgwp8ns+K2DSnxSU=" + }, + "vow-fs": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/vow-fs/-/vow-fs-0.3.6.tgz", + "integrity": "sha1-LUxZviLivyYY3fWXq0uqkjvnIA0=", + "requires": { + "glob": "^7.0.5", + "uuid": "^2.0.2", + "vow": "^0.4.7", + "vow-queue": "^0.4.1" + } + }, + "vow-queue": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/vow-queue/-/vow-queue-0.4.3.tgz", + "integrity": "sha1-S6j2S1bpISwNvlfxQFruvVTM540=", + "requires": { + "vow": "^0.4.17" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo=", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha1-rgdOa9wMFKQx6ATmJFScYzsABFc=", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha1-CADhRSO5I6OH5BUSPIZWFqrg9cM=", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha1-le+U+F7MgdAHwmThkKEg8KPIVms=", + "dev": true + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha1-BfWZe2CWR7ZPZrgeO0sQo2jnrRM=", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha1-h5oIZZc7yp9rq1y987HGfsfTvPQ=", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha1-8rsqfoPLyHu5XI5XKCigbJrdbg0=", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" + } + } + } +} diff --git a/package.json b/package.json index 96688b7f..d0e74e0f 100644 --- a/package.json +++ b/package.json @@ -17,21 +17,23 @@ "node": ">= 6.0.0" }, "dependencies": { - "babel-polyfill": "6.23.0", - "glob": "latest", + "@babel/polyfill": "^7.4.0", "gonzales-pe": "4.2.4", - "minimatch": "3.0.2", - "minimist": "1.1.x", - "vow": "0.4.4", + "minimatch": "3.0.4", + "minimist": "1.2.0", + "vow": "0.4.19", "vow-fs": "0.3.6" }, "devDependencies": { - "babel-cli": "^6.11.4", - "babel-plugin-transform-es2015-destructuring": "^6.9.0", - "babel-plugin-transform-strict-mode": "^6.11.3", - "jscs": "2.1.0", - "jshint": "2.8.0", - "mocha": "1.20.1" + "@babel/cli": "^7.2.3", + "@babel/core": "^7.4.0", + "@babel/node": "^7.2.2", + "@babel/plugin-transform-destructuring": "^7.4.0", + "@babel/plugin-transform-strict-mode": "^7.2.0", + "acorn": "^6.1.1", + "eslint": "^5.15.3", + "jshint": "2.10.2", + "mocha": "6.0.2" }, "main": "./lib/csscomb.js", "files": [ diff --git a/scripts/build.sh b/scripts/build.sh index a9bccea3..bbfd5f36 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,4 +4,4 @@ printf "\n\ -----------------------\n\ Building source files\n\ -----------------------\n\n" -./node_modules/.bin/babel --plugins babel-plugin-transform-es2015-destructuring --loose all src --out-dir lib +./node_modules/.bin/babel --plugins @babel/plugin-transform-destructuring --loose all src --out-dir lib diff --git a/scripts/test.sh b/scripts/test.sh index 195f855d..1948c810 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -16,18 +16,12 @@ printf "\n\ ----------------\n\n" test ./node_modules/.bin/jshint ./src -printf "\n\ ---------------\n\ - Running JSCS\n\ ---------------\n\n" -test ./node_modules/.bin/jscs ./src - # Run tests printf "\n\ ---------------\n\ Running Mocha\n\ ---------------\n\n" -test ./node_modules/.bin/babel-node --plugins transform-strict-mode ./test/mocha +test ./node_modules/.bin/babel-node --plugins @babel/plugin-transform-strict-mode ./test/mocha if [ $EXIT_CODE -ne 0 ]; then printf "\n\ diff --git a/src/core.js b/src/core.js index 55000aa9..eea63d2f 100644 --- a/src/core.js +++ b/src/core.js @@ -1,7 +1,7 @@ 'use strict'; if (!global._babelPolyfill) - require('babel-polyfill'); + require('@babel/polyfill'); let fs = require('fs'); var os = require('os');