Repository: lesshint/lesshint (js)

Issue:
Allow .lesshintrc options to be true instead of { "enabled": true }
This works:

```json
	"attributeQuotes": {
		"enabled": true
	},
```

This does no:

```json
	"attributeQuotes": true,
```

Would it be as simple as changing the `if (!options || (options && !options.enabled)) {` under the `ast.root.walk` under `linter.js`' `runChecks`?

Pull request description:
Added a shorthand `true` for `{ enabled: true }`
Fixes #272.

Rules can just say they're `true` rather than the full `{ enabled: true
}`.

Patch:
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..3ba818b 100644
--- a/lib/linter.js
+++ b/lib/linter.js
@@ -107,7 +107,7 @@ var runChecks = function (ast, fullPath, lines, config) {
             var lint;
 
             // Bail if the linter isn't wanted
-            if (!options || (options && !options.enabled)) {
+            if (!options || (options && options !== true && !options.enabled)) {
                 return;
             }
 
@@ -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/linter.js b/test/specs/linter.js
index 577cc20..9453dde 100644
--- a/test/specs/linter.js
+++ b/test/specs/linter.js
@@ -134,9 +134,7 @@ describe('linter', function () {
             ];
 
             var config = {
-                attributeQuotes: {
-                    enabled: true
-                },
+                attributeQuotes: true,
                 duplicateProperty: {
                     enabled: true,
                     exclude: []
@@ -193,9 +191,7 @@ describe('linter', function () {
             var result;
 
             var config = {
-                stringQuotes: {
-                    enabled: true
-                }
+                stringQuotes: true
             };
 
             result = linter.lint(source, path, config);
@@ -249,9 +245,7 @@ describe('linter', function () {
             }];
 
             var config = {
-                emptyRule: {
-                    enabled: true
-                },
+                emptyRule: true,
                 spaceAfterPropertyColon: {
                     enabled: true,
                     style: 'one_space'
@@ -283,9 +277,7 @@ describe('linter', function () {
             }];
 
             var config = {
-                emptyRule: {
-                    enabled: true
-                },
+                emptyRule: true,
                 spaceAfterPropertyColon: {
                     enabled: true,
                     style: 'one_space'
@@ -391,9 +383,7 @@ describe('linter', function () {
 
             var config = {
                 linters: ['../test/plugins/sampleLinter'],
-                sample: {
-                    enabled: true
-                }
+                sample: true
             };
 
             var expected = [{
@@ -419,9 +409,7 @@ describe('linter', function () {
 
             var config = {
                 linters: [require('../plugins/sampleLinter')],
-                sample: {
-                    enabled: true
-                }
+                sample: true
             };
 
             var expected = [{
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 = {