Repository: lesshint/lesshint (js)

Issue:
Spaces before colon leads to Strings should use single quotes
This `Less` code leads to `Strings should use single quotes`:

```less
@size      :       10rem; // Error: Strings should use single quotes
@size:             10rem; // Works well
```

Pull request:
stringQuotes shouldn't check string-less at-rules
Closes #260.

Patch:
diff --git a/README.md b/README.md
index 0394b94..a3ab7d4 100644
--- a/README.md
+++ b/README.md
@@ -194,7 +194,7 @@ lesshint src/less/ lib/style.less
 Available Flags     | Description
 --------------------|----------------------------------------------
 `-c`/`--config`     | Specify the configuration file to use (will be merged with defaults).
-`-e`/`--exclude`    | A [minimatch glob pattern](https://github.com/isaacs/minimatch) or a file to exclude form being linted.
+`-e`/`--exclude`    | A [minimatch glob pattern](https://github.com/isaacs/minimatch) or a file to exclude from being linted.
 `-l`/`--linters`    | Require paths of custom linters to add to the built-in list.
 `-r`/`--reporter`   | The reporter to use. See "Reporters" below for possible values.
 `-V`/`--version`    | Show version.
diff --git a/lib/cli.js b/lib/cli.js
index 0c108f9..7c3ed4d 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -89,7 +89,7 @@ module.exports = function (program) {
             exitDefer.reject(EXIT_CODES.WARNING);
         }
     }).fail(function (error) {
-        console.error('An unknown error occurred, please file an issue with this info:');
+        console.error('An unknown error occurred when checking "%s", please file an issue with this info:', error.lesshintFile);
         console.error(error.stack);
 
         exitDefer.reject(EXIT_CODES.SOFTWARE);
diff --git a/lib/linter.js b/lib/linter.js
index c65fb59..52bb61f 100644
--- a/lib/linter.js
+++ b/lib/linter.js
@@ -251,6 +251,9 @@ exports.lint = function (input, fullPath, config) {
 
         return results;
     } catch (e) {
+        // Attach the offending file to the exception, so we know which file is the culprit
+        e.lesshintFile = fullPath;
+
         // Just rethrow the exception and let someone else handle it
         throw e;
     }
diff --git a/lib/linters/newline_after_block.js b/lib/linters/newline_after_block.js
index 85e7101..7ecd469 100644
--- a/lib/linters/newline_after_block.js
+++ b/lib/linters/newline_after_block.js
@@ -6,6 +6,7 @@ module.exports = {
     message: 'All blocks should be followed by a new line.',
 
     lint: function newlineAfterBlockLinter (config, node) {
+        var regexp = /\n[ \t]*\n?/;
         var parent = node.parent;
         var prev;
 
@@ -35,12 +36,12 @@ module.exports = {
          * unless it's the first comment of a block.
          */
         if (prev.type === 'comment') {
-            if (Object.is(prev, parent.first) || prev.raws.before.indexOf('\n\n') !== -1) {
+            if (Object.is(prev, parent.first) || regexp.test(prev.raws.before)) {
                 return;
             }
         }
 
-        if (node.raws.before.indexOf('\n\n') === -1) {
+        if (!regexp.test(node.raws.before)) {
             return [{
                 message: this.message
             }];
diff --git a/lib/linters/string_quotes.js b/lib/linters/string_quotes.js
index 1d15a19..778861b 100644
--- a/lib/linters/string_quotes.js
+++ b/lib/linters/string_quotes.js
@@ -32,6 +32,11 @@ module.exports = {
                 return;
             }
 
+            // Not a string, bail
+            if (!(/"|'/.test(node.params))) {
+                return;
+            }
+
             if (!quotes[config.style].test(node.params)) {
                 column = (node.raws.afterName ? node.raws.afterName.length : 0) +
                          node.source.start.column +


Test patch:
diff --git a/test/specs/linters/newline_after_block.js b/test/specs/linters/newline_after_block.js
index 38473e2..62c1276 100644
--- a/test/specs/linters/newline_after_block.js
+++ b/test/specs/linters/newline_after_block.js
@@ -135,5 +135,24 @@ describe('lesshint', function () {
                 expect(result).to.be.undefined;
             });
         });
+
+        it('should not report nested blocks with a preceding new line containing other white space', function () {
+            var source = '';
+
+            source += '.foo {';
+            source += '    color: red;';
+            source += '\n \t\n';
+            source += '    .bar {';
+            source += '        color: red;';
+            source += '    }';
+            source += '\n';
+            source += '}';
+
+            return spec.parse(source, function (ast) {
+                var result = spec.linter.lint({}, ast.root.last);
+
+                expect(result).to.be.undefined;
+            });
+        });
     });
 });
diff --git a/test/specs/linters/string_quotes.js b/test/specs/linters/string_quotes.js
index cf3233e..9f702d1 100644
--- a/test/specs/linters/string_quotes.js
+++ b/test/specs/linters/string_quotes.js
@@ -326,6 +326,32 @@ describe('lesshint', function () {
             });
         });
 
+        it('should not check @-rules without strings', function () {
+            var source = '@var: 16px;';
+            var options = {
+                style: 'double'
+            };
+
+            return spec.parse(source, function (ast) {
+                var result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.deep.undefined;
+            });
+        });
+
+        it('should not warn on variables with a lot of spaces. #260', function () {
+            var source = '@var      :       16px;';
+            var options = {
+                style: 'double'
+            };
+
+            return spec.parse(source, function (ast) {
+                var result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.deep.undefined;
+            });
+        });
+
         it('should throw on invalid "style" value', function () {
             var source = ".foo { content: 'Hello world' }";
             var options = {