Repository: sasstools/sass-lint (js)

Issue:
Space After Colons doesn't work inside of arguments
For instance, inside of Media Query arguments:

https://github.com/bgriffith/sass-lint/commit/2ceb329be1e014ddf7c71508eabf37d59a223e07#diff-9749c71a6762edb9480fb15c79950231R23

Pull request:
Fix bug in Space After Colon
Now works for all colons, whether the parser considers them of type `propertyDelimiter` or `operator`.

Fixes #98 

DCO 1.1 Signed-off-by: Ben Griffith <gt11687@gmail.com>

Patch:
diff --git a/lib/rules/space-after-colon.js b/lib/rules/space-after-colon.js
index b54e819..3425579 100644
--- a/lib/rules/space-after-colon.js
+++ b/lib/rules/space-after-colon.js
@@ -10,29 +10,31 @@ module.exports = {
   'detect': function (ast, parser) {
     var result = [];
 
-    ast.traverseByType('propertyDelimiter', function (delimiter, i, parent) {
-      var next = parent.content[i + 1];
+    ast.traverseByTypes(['propertyDelimiter', 'operator'], function (delimiter, i, parent) {
+      if (delimiter.content === ':') {
+        var next = parent.content[i + 1];
 
-      if (next.is('space')) {
-        if (!parser.options.include) {
-          result = helpers.addUnique(result, {
-            'ruleId': parser.rule.name,
-            'line': next.start.line,
-            'column': next.start.column,
-            'message': 'No space allowed after `:`',
-            'severity': parser.severity
-          });
+        if (next.is('space')) {
+          if (!parser.options.include) {
+            result = helpers.addUnique(result, {
+              'ruleId': parser.rule.name,
+              'line': next.start.line,
+              'column': next.start.column,
+              'message': 'No space allowed after `:`',
+              'severity': parser.severity
+            });
+          }
         }
-      }
-      else {
-        if (parser.options.include) {
-          result = helpers.addUnique(result, {
-            'ruleId': parser.rule.name,
-            'line': delimiter.start.line,
-            'column': delimiter.start.column,
-            'message': 'Space expected after `:`',
-            'severity': parser.severity
-          });
+        else {
+          if (parser.options.include) {
+            result = helpers.addUnique(result, {
+              'ruleId': parser.rule.name,
+              'line': delimiter.start.line,
+              'column': delimiter.start.column,
+              'message': 'Space expected after `:`',
+              'severity': parser.severity
+            });
+          }
         }
       }
     });


Test patch:
diff --git a/tests/main.js b/tests/main.js
index 48a5870..82a3748 100644
--- a/tests/main.js
+++ b/tests/main.js
@@ -478,7 +478,9 @@ describe('rule', function () {
   //////////////////////////////
   // Space After Colon
   //////////////////////////////
-  it('space after colon', function (done) {
+
+  // Default
+  it('space after colon - [include: true]', function (done) {
     lintFile('space-after-colon.scss', {
       'options': {
         'merge-default-rules': false
@@ -487,7 +489,26 @@ describe('rule', function () {
         'space-after-colon': 1
       }
     }, function (data) {
-      assert.equal(1, data.warningCount);
+      assert.equal(3, data.warningCount);
+      done();
+    });
+  });
+
+  it('space after colon - [include: false]', function (done) {
+    lintFile('space-after-colon.scss', {
+      'options': {
+        'merge-default-rules': false
+      },
+      'rules': {
+        'space-after-colon': [
+          1,
+          {
+            'include': false
+          }
+        ]
+      }
+    }, function (data) {
+      assert.equal(4, data.warningCount);
       done();
     });
   });
diff --git a/tests/sass/space-after-colon.scss b/tests/sass/space-after-colon.scss
index 19efb8c..967c594 100644
--- a/tests/sass/space-after-colon.scss
+++ b/tests/sass/space-after-colon.scss
@@ -1,4 +1,16 @@
 .foo {
-  content: 'bar';
+  content: 'foo';
+}
+
+.bar {
   content:'bar';
 }
+
+.baz {
+  @media (max-width: 50em) and (orientation:landscape) {
+    content: 'baz';
+  }
+}
+
+$qux: 'qux';
+$norf:'norf';