'use strict';

var gonzales = require('gonzales-pe'),
    util = require('util'),
    merge = require('merge');

module.exports = {
  'name': 'space-after-colon',
  'defaults': {
    'include': true
  },
  'detect': function (ast, parser) {
    var result = [],
	determineResult;

    ast.traverseByType('operator', function (operator, i, parent) {
      var next;

      if (operator.content === ',') {
	next = parent.content[i + 1];
	if (next.is('space')) {
	  if (!parser.options.include) {
	    result.push({
	      '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.push({
	      'ruleId': parser.rule.name,
	      'line': operator.start.line,
	      'column': operator.start.column,
	      'message': 'Commas should be followed by a space',
	      'severity': parser.severity
	    });
	  }
	}
      }
    });

    return result;
  }
}
'use strict';

var gonzales = require('gonzales-pe'),
    util = require('util'),
    merge = require('merge');

module.exports = {
  'name': 'space-after-comma',
  'defaults': {
    'include': true
  },
  'detect': function (ast, parser) {
    var result = [],
	determineResult;

    ast.traverseByType('operator', function (operator, i, parent) {
      var next;

      if (operator.content === ',') {
	next = parent.content[i + 1];
	if (next.is('space')) {
	  if (!parser.options.include) {
	    result.push({
	      '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.push({
	      'ruleId': parser.rule.name,
	      'line': operator.start.line,
	      'column': operator.start.column,
	      'message': 'Commas should be followed by a space',
	      'severity': parser.severity
	    });
	  }
	}
      }
    });

    return result;
  }
}
Fix rule name in space after comma
Fix rule name in space after comma
