Sha256: d5d7a8d4949b9aa1015bb7e7be158d4565f9dbce9b2a086a25dc6241cce25d88

Contents?: true

Size: 1.52 KB

Versions: 24

Compression:

Stored size: 1.52 KB

Contents

"use strict";

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

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

var _stylelint = require("stylelint");

var ruleName = (0, _utils.namespace)("at-if-no-null");
exports.ruleName = ruleName;

var messages = _stylelint.utils.ruleMessages(ruleName, {
  equals_null: "Expected @if not statement rather than @if statement == null",
  not_equals_null: "Expected @if statement rather than @if statement != null"
});

exports.messages = messages;

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

    if (!validOptions) {
      return;
    }

    root.walkAtRules(function (atrule) {
      // Do nothing if it's not an @if
      if (atrule.name !== "if") {
        return;
      } // If rule != null and (expr), skip


      if (atrule.params.match(/\(?[ \t]*.* != null and .*\)?/)) {
        return;
      }

      if (atrule.params.match(/\(?[ \t]*.* == null[ \t]*\)?/)) {
        _stylelint.utils.report({
          message: messages.equals_null,
          node: atrule,
          result: result,
          ruleName: ruleName
        });
      } else if (atrule.params.match(/\(?[ \t]*.* != null[ \t]*\)?/)) {
        _stylelint.utils.report({
          message: messages.not_equals_null,
          node: atrule,
          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-if-no-null/index.js
trusty-cms-5.0.7 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.6 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.5 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.4 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.3 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.2 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.1 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3.5 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-5.0.0 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3.4 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3.3 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3.2 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3.1 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.3 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.2.3 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.2.2 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.2.1 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.2 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js
trusty-cms-4.1.9 node_modules/stylelint-scss/dist/rules/at-if-no-null/index.js