Sha256: f90fc39718c1da03bd855f936af36f5be10467023de3a39d429979b1ea6b7dc7

Contents?: true

Size: 987 Bytes

Versions: 45

Compression:

Stored size: 987 Bytes

Contents

'use strict';

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

module.exports = {
  'name': 'no-trailing-whitespace',
  'defaults': {},
  'detect': function (ast, parser) {
    var result = [];
    var trailing = (/( |\t)+\n/);
    var trailingCRLF = (/( |\t)+\r\n/);

    ast.traverseByType('space', function (space, i, parent) {
      var content = space.content;
      var nextIndex = i + 1;
      var next = parent.content[nextIndex];

      while (next && (next.is('space') || next.is('declarationDelimiter'))) {
        content += next.content;
        nextIndex++;
        next = parent.content[nextIndex];
      }

      if (trailing.test(content) || trailingCRLF.test(content)) {
        result = helpers.addUnique(result, {
          'ruleId': parser.rule.name,
          'severity': parser.severity,
          'line': space.start.line,
          'column': space.start.column,
          'message': 'No trailing whitespace allowed'
        });
      }
    });

    return result;
  }
};

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.21.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.20.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.19.1 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.19.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.18.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.17.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.16.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.15.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.14.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.13.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.12.2 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.12.1 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.12.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.11.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.10.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.9.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.8.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.7.0 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js
govuk_publishing_components-17.6.1 node_modules/sass-lint/lib/rules/no-trailing-whitespace.js