Repository: lesshint/lesshint
Pull request #81 (2015-10-14 20:25:42)

Update gonzales-pe to 3.0.0-beta
Still work in progress.

Everything but `qualifyingElement` and `spaceBeforeBrace` is fixed and works.


Patch:
diff --git a/lib/linters/attribute_quotes.js b/lib/linters/attribute_quotes.js
index 0658c63..54a41f5 100644
--- a/lib/linters/attribute_quotes.js
+++ b/lib/linters/attribute_quotes.js
@@ -2,23 +2,14 @@
 
 module.exports = {
     name: 'attributeQuotes',
-    nodeTypes: ['simpleSelector'],
+    nodeTypes: ['attributeValue'],
     message: 'Attribute selectors should use quotes.',
 
     lint: function attributeQuotesLinter (config, node) {
-        var selector = node.first('attribute');
-        var value;
-
-        // Bail if no attribute selectors are found or if there's no value to check
-        if (!selector || !selector.contains('attributeSelector')) {
-            return;
-        }
-
-        // Try and find a string
-        value = selector.first('string');
+        var value = node.first('string');
 
         if (!value) {
-            value = selector.last('ident');
+            value = node.last('ident');
 
             return [{
                 column: value.start.column,
diff --git a/lib/linters/id_selector.js b/lib/linters/id_selector.js
index 5daadb4..0f50584 100644
--- a/lib/linters/id_selector.js
+++ b/lib/linters/id_selector.js
@@ -16,19 +16,17 @@ module.exports = {
             return id.replace(/^\#/, '');
         });
 
-        node.forEach('simpleSelector', function (selector) {
-            selector.content.some(function (element) {
-                var name = element.first('ident') && element.first('ident').content;
+        node.content.some(function (element) {
+            var name = element.first('ident') && element.first('ident').content;
 
-                if (element.type === 'id' && excludes.indexOf(name) === -1) {
-                    valid = false;
-                    start = element.start;
+            if (element.type === 'id' && excludes.indexOf(name) === -1) {
+                valid = false;
+                start = element.start;
 
-                    return true;
-                }
+                return true;
+            }
 
-                return false;
-            });
+            return false;
         });
 
         if (!valid) {
diff --git a/lib/linters/import_path.js b/lib/linters/import_path.js
index 5b3b36b..035e2bc 100644
--- a/lib/linters/import_path.js
+++ b/lib/linters/import_path.js
@@ -2,7 +2,7 @@
 
 module.exports = {
     name: 'importPath',
-    nodeTypes: ['atrules'],
+    nodeTypes: ['atrule'],
     message: {
         extension: 'Imported file, "%s" should%s include the file extension.',
         underscore: 'Imported file, "%s" should%s include a leading underscore.'
diff --git a/lib/linters/qualifying_element.js b/lib/linters/qualifying_element.js
index 9a8c9b1..a1e6582 100644
--- a/lib/linters/qualifying_element.js
+++ b/lib/linters/qualifying_element.js
@@ -2,7 +2,7 @@
 
 module.exports = {
     name: 'qualifyingElement',
-    nodeTypes: ['simpleSelector'],
+    nodeTypes: ['selector'],
     message: '%s selectors should not include a qualifying element.',
 
     lint: function qualifyingElementLinter (config, node) {
@@ -10,20 +10,17 @@ module.exports = {
         var helpers = require('../helpers');
         var sprintf = require('sprintf-js').sprintf;
 
-        node.forEach(function (selector, index) {
-            var content = helpers.ensureObject(node.get(index - 1));
-
-            if (content.type !== 'ident') {
-                return;
-            }
+        node.forEach('typeSelector', function (selector, index) {
+            selector = helpers.ensureObject(node.get(index + 1));
 
             switch (selector.type) {
-                case 'attribute':
+                case 'attributeSelector':
                     if (config.allowWithAttribute) {
                         return;
                     }
 
                     result = selector;
+                    result.type = 'attribute'; // Special case because of node type
                     break;
                 case 'class':
                     if (config.allowWithClass) {
diff --git a/lib/linters/single_line_per_selector.js b/lib/linters/single_line_per_selector.js
index 2705afa..5e42320 100644
--- a/lib/linters/single_line_per_selector.js
+++ b/lib/linters/single_line_per_selector.js
@@ -2,23 +2,17 @@
 
 module.exports = {
     name: 'singleLinePerSelector',
-    nodeTypes: ['selector'],
+    nodeTypes: ['ruleset'],
     message: 'Each selector should be on its own line.',
 
     lint: function singleLinePerSelectorLinter (config, node) {
         var results = [];
         var self = this;
 
-        node.forEach('simpleSelector', function (element, index) {
-            /*
-             * Since the new line character is emitted together with each selector following the first one
-             * we'll simply ignore the first selector and just check the rest for new line characters.
-             */
-            if (!index) {
-                return true;
-            }
+        node.forEach('delimiter', function (element, index) {
+            element = node.get(index + 1);
 
-            if (element.get(0).content.indexOf('\n') === -1) {
+            if (element.content.indexOf('\n') === -1) {
                 results.push({
                     column: element.start.column,
                     line: element.start.line,
diff --git a/lib/linters/space_before_brace.js b/lib/linters/space_before_brace.js
index 7c67e6b..eb10fb5 100644
--- a/lib/linters/space_before_brace.js
+++ b/lib/linters/space_before_brace.js
@@ -1,8 +1,10 @@
 'use strict';
 
+var helpers = require('../helpers');
+
 module.exports = {
     name: 'spaceBeforeBrace',
-    nodeTypes: ['selector', 'atruleb', 'atruler'],
+    nodeTypes: ['atrule', 'mixin', 'ruleset'],
     message: {
         newLine: 'Opening curly brace should be on its own line.',
         noSpace: 'Opening curly brace should not be preceded by a space or new line.',
@@ -10,21 +12,10 @@ module.exports = {
     },
 
     lint: function spaceBeforeBraceLinter (config, node) {
-        var maybeSpace;
+        var maybeSpace = helpers.ensureObject(node.content[node.content.length - 2]);
         var message;
         var column;
-
-        if (node.type === 'selector' || node.type === 'atruler') {
-            if (node.first('atrulerq')) {
-                // Media queries without a space need special handling
-                maybeSpace = node.first('atrulerq').last();
-            } else {
-                maybeSpace = node.last().last();
-            }
-        } else {
-            // For atruleb and atruler the last element is actually the code block so take the second last
-            maybeSpace = node.content[node.content.length - 2];
-        }
+        var block;
 
         switch (config.style) {
             case 'no_space':
@@ -37,11 +28,9 @@ module.exports = {
                 if (maybeSpace.type !== 'space' || (maybeSpace.type === 'space' && maybeSpace.content !== ' ')) {
                     message = this.message.oneSpace;
 
-                    if (maybeSpace.last().start) {
-                        column = maybeSpace.last().start.column + maybeSpace.last().content.length;
-                    } else {
-                        column = maybeSpace.start.column + maybeSpace.content.length;
-                    }
+                    // Fetch the position where the space should have been
+                    block = helpers.ensureObject(node.first('block'));
+                    column = block.start.column;
                 }
 
                 break;
diff --git a/package.json b/package.json
index 6dcca4d..b377b4a 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
     "chalk": "^1.0.0",
     "commander": "^2.8.0",
     "exit": "^0.1.2",
-    "gonzales-pe": "3.0.0-31",
+    "gonzales-pe": "3.0.0-beta",
     "lodash.assign": "^3.2.0 ",
     "lodash.findindex": "^3.2.1",
     "lodash.flatten": "^3.0.2",


Test patch:
diff --git a/test/specs/linters/attribute_quotes.js b/test/specs/linters/attribute_quotes.js
index 150d12e..aac3cf4 100644
--- a/test/specs/linters/attribute_quotes.js
+++ b/test/specs/linters/attribute_quotes.js
@@ -18,7 +18,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector').first('attributeValue');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -34,7 +34,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector').first('attributeValue');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -58,14 +58,14 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector').first('attributeValue');
 
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
-        it('should return null for value-less selectors', function () {
+        it('should return undefined for value-less selectors', function () {
             var source = 'input[disabled] {}';
             var actual;
             var ast;
@@ -77,7 +77,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector');
 
             assert.equal(undefined, lint(options, ast));
         });
@@ -92,7 +92,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector').first('attributeValue');
 
             assert.equal(undefined, lint(options, ast));
         });
@@ -105,7 +105,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector').first('attributeSelector').first('attributeValue');
 
             assert.equal(undefined, lint(options, ast));
         });
diff --git a/test/specs/linters/qualifying_element.js b/test/specs/linters/qualifying_element.js
index d59e2b7..f7637f4 100644
--- a/test/specs/linters/qualifying_element.js
+++ b/test/specs/linters/qualifying_element.js
@@ -18,7 +18,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -42,7 +42,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             actual = lint(options, ast);
 
@@ -68,7 +68,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             actual = lint(options, ast);
 
@@ -94,7 +94,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             actual = lint(options, ast);
 
@@ -113,7 +113,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -130,7 +130,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -147,7 +147,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -171,7 +171,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             actual = lint(options, ast);
 
@@ -179,7 +179,7 @@ describe('lesshint', function () {
         });
 
         it('should return null when disabled', function () {
-            var source = 'div#foo';
+            var source = 'div#foo {}';
             var ast;
             var options = {
                 qualifyingElement: {
@@ -188,20 +188,20 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.equal(null, lint(options, ast));
         });
 
         it('should return null when disabled via shorthand', function () {
-            var source = 'div#foo';
+            var source = 'div#foo {}';
             var ast;
             var options = {
                 qualifyingElement: false
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector');
+            ast = ast.first().first('selector');
 
             assert.equal(null, lint(options, ast));
         });
diff --git a/test/specs/linters/single_line_per_selector.js b/test/specs/linters/single_line_per_selector.js
index ea86a2b..1f86f19 100644
--- a/test/specs/linters/single_line_per_selector.js
+++ b/test/specs/linters/single_line_per_selector.js
@@ -18,7 +18,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('ruleset').first('selector');
+            ast = ast.first('ruleset');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -42,7 +42,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('ruleset').first('selector');
+            ast = ast.first('ruleset');
 
             actual = lint(options, ast);
 
@@ -59,7 +59,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('ruleset').first('selector');
+            ast = ast.first('ruleset');
 
             assert.equal(null, lint(options, ast));
         });
@@ -72,7 +72,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('ruleset').first('selector');
+            ast = ast.first('ruleset');
 
             assert.equal(null, lint(options, ast));
         });
diff --git a/test/specs/linters/space_around_comma.js b/test/specs/linters/space_around_comma.js
index d5b60c6..9028ba1 100644
--- a/test/specs/linters/space_around_comma.js
+++ b/test/specs/linters/space_around_comma.js
@@ -124,7 +124,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -149,7 +149,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -167,7 +167,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -239,7 +239,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -264,7 +264,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -282,7 +282,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -387,7 +387,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -412,7 +412,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -439,7 +439,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -457,7 +457,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -549,7 +549,7 @@ describe('lesshint', function () {
             }];
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.deepEqual(expected, lint(options, ast));
         });
@@ -574,7 +574,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -592,7 +592,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -608,7 +608,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
@@ -673,7 +673,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(undefined, lint(options, ast));
         });
@@ -698,7 +698,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -716,7 +716,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first('atrules').first('parentheses');
+            ast = ast.first('atrule').first('parentheses');
 
             assert.strictEqual(undefined, lint(options, ast));
         });
diff --git a/test/specs/linters/space_before_brace.js b/test/specs/linters/space_before_brace.js
index 3b50185..168c1ae 100644
--- a/test/specs/linters/space_before_brace.js
+++ b/test/specs/linters/space_before_brace.js
@@ -8,7 +8,7 @@ var undefined;
 describe('lesshint', function () {
     describe('#spaceBeforeBrace()', function () {
         it('should allow no space when "style" is "no_space"', function () {
-            var source = '.foo{ color: red; }';
+            var source = '.foo{}';
             var ast;
 
             var options = {
@@ -19,13 +19,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.strictEqual(undefined, lint(options, ast));
         });
 
         it('should not allow one space when "style" is "no_space"', function () {
-            var source = '.foo { color: red; }';
+            var source = '.foo {}';
             var actual;
             var ast;
 
@@ -44,14 +44,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow multiple spaces when "style" is "no_space"', function () {
-            var source = '.foo  { color: red; }';
+            var source = '.foo  {}';
             var actual;
             var ast;
 
@@ -70,14 +71,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow one new line when "style" is "no_space"', function () {
-            var source = '.foo\n{ color: red; }';
+            var source = '.foo\n{}';
             var actual;
             var ast;
 
@@ -96,14 +98,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow multiple new lines when "style" is "no_space"', function () {
-            var source = '.foo\n\n{ color: red; }';
+            var source = '.foo\n\n{}';
             var actual;
             var ast;
 
@@ -122,14 +125,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should allow one space when "style" is "one_space"', function () {
-            var source = '.foo { color: red; }';
+            var source = '.foo {}';
             var ast;
 
             var options = {
@@ -140,13 +144,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.strictEqual(undefined, lint(options, ast));
         });
 
         it('should not allow missing space when "style" option is "one_space"', function () {
-            var source = '.foo{ color: red; }';
+            var source = '.foo{}';
             var actual;
             var ast;
 
@@ -165,14 +169,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should allow one space when multiple simple selectors are used and "style" is "one_space"', function () {
-            var source = '.foo, .bar { color: red; }';
+            var source = '.foo, .bar {}';
             var ast;
 
             var options = {
@@ -183,13 +188,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.strictEqual(undefined, lint(options, ast));
         });
 
         it('should not allow missing space when multiple simple selectors are used and "style" is "one_space"', function () {
-            var source = '.foo, .bar{ color: red; }';
+            var source = '.foo, .bar{}';
             var actual;
             var ast;
 
@@ -208,14 +213,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow multiple spaces when "style" is "one_space"', function () {
-            var source = '.foo  { color: red; }';
+            var source = '.foo  {}';
             var actual;
             var ast;
 
@@ -234,14 +240,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow multiple spaces when multiple simple selectors are used and "style" is "one_space"', function () {
-            var source = '.foo, .bar  { color: red; }';
+            var source = '.foo, .bar  {}';
             var actual;
             var ast;
 
@@ -260,14 +267,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should allow one new line when "style" is "new_line"', function () {
-            var source = '.foo\n{ color: red; }';
+            var source = '.foo\n{}';
             var ast;
 
             var options = {
@@ -278,13 +286,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.strictEqual(undefined, lint(options, ast));
         });
 
         it('should allow one new line when a selector group is used and "style" is "new_line"', function () {
-            var source = '.foo, .bar\n{ color: red; }';
+            var source = '.foo, .bar\n{}';
             var ast;
 
             var options = {
@@ -295,13 +303,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.strictEqual(undefined, lint(options, ast));
         });
 
         it('should not allow multiple new lines when "style" is "new_line"', function () {
-            var source = '.foo\n\n{ color: red; }';
+            var source = '.foo\n\n{}';
             var actual;
             var ast;
 
@@ -320,14 +328,15 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
         it('should not allow multiple new lines when a selector group is used and "style" is "new_line"', function () {
-            var source = '.foo, .bar\n\n{ color: red; }';
+            var source = '.foo, .bar\n\n{}';
             var actual;
             var ast;
 
@@ -346,83 +355,23 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
+
             actual = lint(options, ast);
 
             assert.deepEqual(actual, expected);
         });
 
-        it('should handle mixins', function () {
-            var source = '.foo() { color: red; }';
-            var ast;
-
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'one_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first().first('selector');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle media queries', function () {
-            var source = '@media screen and (max-width: 480px) { color: blue; }';
-            var ast;
-
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'one_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first('atruleb');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle media queries without space', function () {
-            var source = '@media screen and (max-width: 480px){ color: blue; }';
-            var ast;
-
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'no_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first('atruleb');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle nested media queries', function () {
-            var source = '.class{ color: red; @media screen and (max-width: 480px){ color: blue; } }';
+        it('should check mixins', function () {
+            var source = '.foo(){}';
             var ast;
 
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'no_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first().first('selector');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle empty media queries', function () {
-            var source = '@media(all) {}';
-            var ast;
+            var expected = [{
+                column: 7,
+                line: 1,
+                linter: 'spaceBeforeBrace',
+                message: linter.message.oneSpace
+            }];
 
             var options = {
                 spaceBeforeBrace: {
@@ -434,63 +383,43 @@ describe('lesshint', function () {
             ast = parseAST(source);
             ast = ast.first();
 
-            assert.strictEqual(undefined, lint(options, ast));
+            assert.deepEqual(expected, lint(options, ast));
         });
 
-        it('should handle media queries', function () {
-            var source = '@media screen and (max-width: 480px) { color: blue; }';
+        it('should check media queries', function () {
+            var source = '@media screen and (max-width: 480px){}';
             var ast;
 
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'one_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first('atruleb');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle media queries without space', function () {
-            var source = '@media screen and (max-width: 480px){ color: blue; }';
-            var ast;
+            var expected = [{
+                column: 37,
+                line: 1,
+                linter: 'spaceBeforeBrace',
+                message: linter.message.oneSpace
+            }];
 
             var options = {
                 spaceBeforeBrace: {
                     enabled: true,
-                    style: 'no_space'
+                    style: 'one_space'
                 }
             };
 
             ast = parseAST(source);
-            ast = ast.first('atruleb');
+            ast = ast.first('atrule');
 
-            assert.strictEqual(undefined, lint(options, ast));
+            assert.deepEqual(expected, lint(options, ast));
         });
 
-        it('should handle nested media queries', function () {
-            var source = '.class{ color: red; @media screen and (max-width: 480px){ color: blue; } }';
+        it('should check nested media queries', function () {
+            var source = '.class { color: red; @media screen and (max-width: 480px){} }';
             var ast;
 
-            var options = {
-                spaceBeforeBrace: {
-                    enabled: true,
-                    style: 'no_space'
-                }
-            };
-
-            ast = parseAST(source);
-            ast = ast.first().first('selector');
-
-            assert.strictEqual(undefined, lint(options, ast));
-        });
-
-        it('should handle empty media queries', function () {
-            var source = '@media(all) {}';
-            var ast;
+            var expected = [{
+                column: 58,
+                line: 1,
+                linter: 'spaceBeforeBrace',
+                message: linter.message.oneSpace
+            }];
 
             var options = {
                 spaceBeforeBrace: {
@@ -500,13 +429,13 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first();
+            ast = ast.first().first('block').first('atrule');
 
-            assert.strictEqual(undefined, lint(options, ast));
+            assert.deepEqual(expected, lint(options, ast));
         });
 
         it('should return null when disabled', function () {
-            var source = '.foo{ color: red; }';
+            var source = '.foo{}';
             var ast;
             var options = {
                 spaceBeforeBrace: {
@@ -515,26 +444,26 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.equal(undefined, lint(options, ast));
         });
 
         it('should return null when disabled via shorthand', function () {
-            var source = '.foo{ color: red; }';
+            var source = '.foo{}';
             var ast;
             var options = {
                 spaceBeforeBrace: false
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.equal(undefined, lint(options, ast));
         });
 
         it('should throw on invalid "style" value', function () {
-            var source = '.foo{ color: red; }';
+            var source = '.foo{}';
             var ast;
             var options = {
                 spaceBeforeBrace: {
@@ -544,7 +473,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector');
+            ast = ast.first();
 
             assert.throws(lint.bind(null, options, ast), Error);
         });
diff --git a/test/specs/linters/space_between_parens.js b/test/specs/linters/space_between_parens.js
index 5898357..189dc85 100644
--- a/test/specs/linters/space_between_parens.js
+++ b/test/specs/linters/space_between_parens.js
@@ -462,7 +462,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -478,7 +478,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -494,7 +494,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -519,7 +519,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -546,7 +546,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -579,7 +579,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -606,7 +606,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -633,7 +633,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -666,7 +666,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -684,7 +684,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -700,7 +700,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -716,7 +716,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             assert.equal(null, lint(options, ast));
         });
@@ -741,7 +741,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -768,7 +768,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -801,7 +801,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -828,7 +828,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -855,7 +855,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);
 
@@ -888,7 +888,7 @@ describe('lesshint', function () {
             };
 
             ast = parseAST(source);
-            ast = ast.first().first('selector').first('simpleSelector').first('parentheses');
+            ast = ast.first('mixin').first('arguments');
 
             actual = lint(options, ast);