"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = _default; exports.ruleName = exports.messages = void 0; var _stylelint = require("stylelint"); var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var ruleName = 'a11y/line-height-is-vertical-rhythmed'; exports.ruleName = ruleName; var messages = _stylelint.utils.ruleMessages(ruleName, { expected: function expected(selector) { return "Expected a vertical rhythmed line-height in ".concat(selector); } }); exports.messages = messages; function check(node) { if (node.type !== 'rule') { return true; } var checkInPx = function checkInPx(o) { return o.value.toLowerCase().endsWith('px') && parseInt(o.value) % 24 !== 0; }; var checkInRel = function checkInRel(o) { return !isNaN(o.value) && parseFloat(o.value) < 1.5; }; return !node.nodes.some(function (o) { return o.type === 'decl' && o.prop.toLowerCase() === 'line-height' && (checkInPx(o) || checkInRel(o)); }); } function _default(actual) { return function (root, result) { var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual }); if (!validOptions || !actual) { return; } root.walk(function (node) { var selector = null; if (node.type === 'rule') { if (!(0, _isStandardSyntaxRule["default"])(node)) { return; } selector = node.selector; } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { selector = node.params; } if (!selector) { return; } var isAccepted = check(node); if (!isAccepted) { _stylelint.utils.report({ index: node.lastEach, message: messages.expected(selector), node: node, ruleName: ruleName, result: result }); } }); }; }