Repository: sasstools/sass-lint (js)

Issue:
Space after Comma syntax error…
**Calling module within JS file**
```
/sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:18
        if (next.is('space')) {
                ^
TypeError: Cannot read property 'is' of undefined
    at /sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:18:17
    at RootNode.traverseByType (/sass-lib/node_modules/sass-lint/node_modules/gonzales-pe/lib/node/root-node.js:1:1739)
    at Object.module.exports.detect (/sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:13:9)
    at /sass-lib/node_modules/sass-lint/index.js:30:25
    at Array.forEach (native)
    at Function.sassLint.lintText (/sass-lib/node_modules/sass-lint/index.js:29:9)
    at /sass-lib/node_modules/sass-lint/index.js:73:21
    at Array.forEach (native)
    at Function.sassLint.lintFiles (/sass-lib/node_modules/sass-lint/index.js:72:9)
    at Object.<anonymous> (/sass-lib/index.js:5:17)
```


**Using Gulp task**
```
/sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:18
        if (next.is('space')) {
                ^
TypeError: Cannot read property 'is' of undefined
    at /sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:18:17
    at RootNode.traverseByType (/sass-lib/node_modules/sass-lint/node_modules/gonzales-pe/lib/node/root-node.js:1:1739)
    at Object.module.exports.detect (/sass-lib/node_modules/sass-lint/lib/rules/space-after-comma.js:13:9)
    at /sass-lib/node_modules/sass-lint/index.js:30:25
    at Array.forEach (native)
    at Function.sassLint.lintText (/sass-lib/node_modules/sass-lint/index.js:29:9)
    at DestroyableTransform._transform (/sass-lib/node_modules/gulp-sass-lint/index.js:32:27)
    at DestroyableTransform.Transform._read (/sass-lib/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:10)
    at DestroyableTransform.Transform._write (/sass-lib/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:160:12)
    at doWrite (/sass-lib/node_modules/gulp-sass-lint/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:326:12)
```

Pull request description:
Fix Space After Comma and new lines
Fixes an issue with Space After Comma and new lines. Also added tests for non default values.

Fixes #89 

DCO 1.1 Signed-off-by: Ben Griffith <gt11687@gmail.com>

Patch:
diff --git a/.travis.yml b/.travis.yml
index 4fee618..79bc77b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,6 @@ node_js:
   - '0.10'
   - node
   - iojs
-before_install: npm install -g sass-lint
 notifications:
   slack:
     secure: RrEbq2xE1hWdog4AckkaKDnIYYwo5VdjPcFNhRJbn/7KI0fKeZVCKZy1Ww7aaJGth7R7UX415sEV1U6RrjFyhnBb6Sh+rh8fKTvcvuTbENZW45SbtUD+xmgOvb2kfk4PzgD5Q457DpchAZD7W+E+9qr3xI3Uvh4II1uhDmSKiLI=
diff --git a/lib/rules/space-after-comma.js b/lib/rules/space-after-comma.js
index 90c624f..226d89e 100644
--- a/lib/rules/space-after-comma.js
+++ b/lib/rules/space-after-comma.js
@@ -1,6 +1,7 @@
 'use strict';
 
-var helpers = require('../helpers');
+var helpers = require('../helpers'),
+    os = require('os');
 
 module.exports = {
   'name': 'space-after-comma',
@@ -10,31 +11,34 @@ module.exports = {
   'detect': function (ast, parser) {
     var result = [];
 
-    ast.traverseByType('operator', function (operator, i, parent) {
+    ast.traverseByTypes(['operator', 'delimiter'], function (operator, i, parent) {
       var next;
 
       if (operator.content === ',') {
         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': 'Commas should not be followed by a space',
-              'severity': parser.severity
-            });
+
+        if (next) {
+          if (next.is('space')) {
+            if ((next.content.indexOf(os.EOL) === -1) && !parser.options.include) {
+              result = helpers.addUnique(result, {
+                'ruleId': parser.rule.name,
+                'line': next.start.line,
+                'column': next.start.column,
+                'message': 'Commas should not be followed by a space',
+                'severity': parser.severity
+              });
+            }
           }
-        }
-        else {
-          if (parser.options.include) {
-            result = helpers.addUnique(result, {
-              'ruleId': parser.rule.name,
-              'line': operator.start.line,
-              'column': operator.start.column,
-              'message': 'Commas should be followed by a space',
-              'severity': parser.severity
-            });
+          else {
+            if (parser.options.include) {
+              result = helpers.addUnique(result, {
+                'ruleId': parser.rule.name,
+                'line': operator.start.line,
+                'column': operator.start.column,
+                'message': 'Commas should be followed by a space',
+                'severity': parser.severity
+              });
+            }
           }
         }
       }


Test patch:
diff --git a/tests/cli.js b/tests/cli.js
deleted file mode 100644
index 6b416b7..0000000
--- a/tests/cli.js
+++ /dev/null
@@ -1,42 +0,0 @@
-var assert = require('assert'),
-    should = require('should'),
-    childProcess = require('child_process');
-
-
-describe('CLI', function () {
-  describe('#help', function () {
-    it('should return help instructions', function (done) {
-
-      var command = 'sass-lint -h';
-
-      childProcess.exec(command, function (err, stdout) {
-        if (err) {
-          return done(err);
-        }
-
-        assert(stdout.indexOf('Usage') > 0);
-
-        done(null);
-      });
-
-    });
-  });
-
-  describe('#version', function () {
-    it('should return a version', function (done) {
-
-      var command = 'sass-lint -V';
-
-      childProcess.exec(command, function (err, stdout) {
-        if (err) {
-          return done(err);
-        }
-
-        should(stdout).match(/^[0-9]+.[0-9]+(.[0-9]+)?/);
-
-        done(null);
-      });
-
-    });
-  });
-});
diff --git a/tests/lint.js b/tests/lint.js
index 6afcd0f..f6f3863 100644
--- a/tests/lint.js
+++ b/tests/lint.js
@@ -47,17 +47,6 @@ describe('code style guide', function () {
     done();
   });
 
-  it('tests/cli.js should follow our JavaScript style guide', function (done) {
-    report = cli.executeOnFiles(['tests/cli.js']);
-    if (report.errorCount > 0 || report.warningCount > 0) {
-      console.log(formatter(report.results));
-    }
-
-    should(report.errorCount).equal(0);
-    should(report.warningCount).equal(0);
-    done();
-  });
-
   it('tesst/lint.js should follow our JavaScript style guide', function (done) {
     cli = new eslint.CLIEngine({
       'rules': {
diff --git a/tests/main.js b/tests/main.js
index 7dd3e97..2ec2b6d 100644
--- a/tests/main.js
+++ b/tests/main.js
@@ -461,7 +461,9 @@ describe('rule', function () {
   //////////////////////////////
   // Space After Comma
   //////////////////////////////
-  it('space after comma', function (done) {
+
+  // Default
+  it('space after comma - [include: true]', function (done) {
     lintFile('space-after-comma.scss', {
       'options': {
         'merge-default-rules': false
@@ -470,7 +472,26 @@ describe('rule', function () {
         'space-after-comma': 1
       }
     }, function (data) {
-      assert.equal(1, data.warningCount);
+      assert.equal(2, data.warningCount);
+      done();
+    });
+  });
+
+  it('space after comma - [include: false]', function (done) {
+    lintFile('space-after-comma.scss', {
+      'options': {
+        'merge-default-rules': false
+      },
+      'rules': {
+        'space-after-comma': [
+          1,
+          {
+            'include': false
+          }
+        ]
+      }
+    }, function (data) {
+      assert.equal(2, data.warningCount);
       done();
     });
   });
diff --git a/tests/sass/space-after-comma.scss b/tests/sass/space-after-comma.scss
index 59c85e0..2c4d20d 100644
--- a/tests/sass/space-after-comma.scss
+++ b/tests/sass/space-after-comma.scss
@@ -1,9 +1,23 @@
 .foo {
   @include mixin('foo', 'bar');
-  @include mixin('foo','bar');
-
   box-shadow: 1px 1px black, 1px 1px black;
+}
+
+.bar {
+  @include mixin('foo','bar');
   box-shadow: 1px 1px black,1px 1px black;
+}
 
+@mixin baz(
+  $foo: true,
+  $bar: false
+) {
+  content: 'foo';
+}
 
+@mixin norf(
+  $foo: true, // This is a comment
+  $bar: false /* This is a comment */
+) {
+  content: 'foo';
 }