Sha256: 47bf488a2dbf4bfb9cb35b10abea0ef0928634adbe36f7bb6e9efd334d8b8475

Contents?: true

Size: 1.56 KB

Versions: 45

Compression:

Stored size: 1.56 KB

Contents

'use strict';

var helpers = require('../helpers');

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

    ast.traverseByTypes(['operator', 'delimiter'], function (operator, i, parent) {
      var next,
          doubleNext;

      if (operator.content === ',') {
        next = parent.content[i + 1] || false;
        doubleNext = parent.content[i + 2] || false;

        if (next) {
          if (operator.is('delimiter')) {
            if (next.is('selector')) {
              next = next.content[0];
            }
          }

          if ((next.is('space') && !helpers.hasEOL(next.content)) && !parser.options.include) {
            if (doubleNext && doubleNext.is('singlelineComment')) {
              return false;
            }

            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.is('space') && 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
            });
          }
        }
      }
      return true;
    });

    return result;
  }
};

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
govuk_publishing_components-17.6.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.5.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.4.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.3.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.2.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.1.1 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.1.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-17.0.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.29.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.28.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.27.1 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.27.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.26.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.25.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.24.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.23.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.22.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.21.0 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.20.1 node_modules/sass-lint/lib/rules/space-after-comma.js
govuk_publishing_components-16.20.0 node_modules/sass-lint/lib/rules/space-after-comma.js