Sha256: 12d08aa6cf408ea2e2442a5c32f7022e4b20ded1e3217c5ab1413ee31b528438

Contents?: true

Size: 1.82 KB

Versions: 24

Compression:

Stored size: 1.82 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;
exports.messages = exports.ruleName = void 0;

var _stylelint = require("stylelint");

var _utils = require("../../utils");

var _operatorNoUnspaced = require("../operator-no-unspaced");

var ruleName = (0, _utils.namespace)("operator-no-newline-after");
exports.ruleName = ruleName;

var messages = _stylelint.utils.ruleMessages(ruleName, {
  rejected: function rejected(operator) {
    return "Unexpected newline after \"".concat(operator, "\"");
  }
});

exports.messages = messages;

/**
 * The checker function: whether there is a newline before THAT operator.
 */
function checkNewlineBefore(_ref) {
  var string = _ref.string,
      globalIndex = _ref.globalIndex,
      startIndex = _ref.startIndex,
      endIndex = _ref.endIndex,
      node = _ref.node,
      result = _ref.result;
  var symbol = string.substring(startIndex, endIndex + 1);
  var newLineBefore = false;
  var index = endIndex + 1;

  while (index && (0, _utils.isWhitespace)(string[index])) {
    if (string[index] === "\n") {
      newLineBefore = true;
      break;
    }

    index++;
  }

  if (newLineBefore) {
    _stylelint.utils.report({
      ruleName: ruleName,
      result: result,
      node: node,
      message: messages.rejected(symbol),
      index: endIndex + globalIndex
    });
  }
}

function _default(expectation) {
  return function (root, result) {
    var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
      actual: expectation
    });

    if (!validOptions) {
      return;
    }

    (0, _utils.eachRoot)(root, checkRoot);

    function checkRoot(root) {
      (0, _operatorNoUnspaced.calculationOperatorSpaceChecker)({
        root: root,
        result: result,
        checker: checkNewlineBefore
      });
    }
  };
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.7 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.6 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.5 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.4 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.3 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.2 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.1 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3.5 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-5.0.0 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3.4 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3.3 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3.2 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3.1 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.3 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.2.3 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.2.2 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.2.1 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.2 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
trusty-cms-4.1.9 node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js