Sha256: 93c17729f4970422c7ff62bf1290aebe85344fde1dc75e3ca0188a1d31ec5588

Contents?: true

Size: 1.79 KB

Versions: 24

Compression:

Stored size: 1.79 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 ruleName = (0, _utils.namespace)("at-mixin-argumentless-call-parentheses");
exports.ruleName = ruleName;

var messages = _stylelint.utils.ruleMessages(ruleName, {
  expected: function expected(mixin) {
    return "Expected parentheses in mixin \"".concat(mixin, "\" call");
  },
  rejected: function rejected(mixin) {
    return "Unexpected parentheses in argumentless mixin \"".concat(mixin, "\" call");
  }
});

exports.messages = messages;

function _default(value, _, context) {
  return function (root, result) {
    var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
      actual: value,
      possible: ["always", "never"]
    });

    if (!validOptions) {
      return;
    }

    root.walkAtRules("include", function (mixinCall) {
      // If it is "No parens in argumentless calls"
      if (value === "never" && mixinCall.params.search(/\(\s*?\)\s*?$/) === -1) {
        return;
      } // If it is "Always use parens"


      if (value === "always" && mixinCall.params.search(/\(/) !== -1) {
        return;
      }

      if (context.fix) {
        if (value === "always") {
          mixinCall.params = "".concat(mixinCall.params, " ()");
        } else {
          mixinCall.params = mixinCall.params.replace(/\s*\([\s\S]*?\)$/, "");
        }

        return;
      }

      var mixinName = /\s*(\S*?)\s*(?:\(|$)/.exec(mixinCall.params)[1];

      _stylelint.utils.report({
        message: messages[value === "never" ? "rejected" : "expected"](mixinName),
        node: mixinCall,
        result: result,
        ruleName: ruleName
      });
    });
  };
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.7 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.6 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.5 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.4 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.3 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.2 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.1 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3.5 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-5.0.0 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3.4 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3.3 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3.2 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3.1 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.3 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.2.3 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.2.2 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.2.1 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.2 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
trusty-cms-4.1.9 node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js