define(["exports"], function (exports) {
  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

  function _defineProperty(obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
    } else {
      obj[key] = value;
    }

    return obj;
  }

  function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
  }

  var _createClass = function () {
    function defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
      }
    }

    return function (Constructor, protoProps, staticProps) {
      if (protoProps) defineProperties(Constructor.prototype, protoProps);
      if (staticProps) defineProperties(Constructor, staticProps);
      return Constructor;
    };
  }();

  var privs = new WeakMap();
  /**
   * Checks if the linter rule is enabled.
   *
   * @param {Object} conf ReSpec config object.
   */
  function canLint(conf, name) {
    return !(conf.hasOwnProperty("lint") === false || conf.lint === false || !conf.lint[name]);
  }

  var LinterRule = function () {
    /**
     *
     * @param {String} the name of the rule
     * @param {Function} lintingFunction has a conf, and doc argument
     */
    function LinterRule(name, lintingFunction) {
      _classCallCheck(this, LinterRule);

      privs.set(this, { name: name, lintingFunction: lintingFunction });
    }

    _createClass(LinterRule, [{
      key: "lint",
      value: function lint() {
        var conf = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { lint: _defineProperty({}, this.name, false) };
        var doc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;

        return canLint(conf, this.name) ? [].concat(privs.get(this).lintingFunction(conf, doc)) : [];
      }
    }, {
      key: "name",
      get: function get() {
        return privs.get(this).name;
      }
    }]);

    return LinterRule;
  }();

  exports.default = LinterRule;
});
//# sourceMappingURL=LinterRule.js.map