epiphany/node_modules/@ronilaukkarinen/stylelint-a11y/dist/rules/no-obsolete-attribute/index.js
2023-12-09 22:48:07 -08:00

61 lines
No EOL
1.8 KiB
JavaScript

"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"));
var _obsoleteAttributes = require("./obsoleteAttributes");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var ruleName = 'a11y/no-obsolete-attribute';
exports.ruleName = ruleName;
var messages = _stylelint.utils.ruleMessages(ruleName, {
expected: function expected(selector) {
return "Unexpected using obsolete attribute \"".concat(selector, "\"");
}
});
exports.messages = messages;
function check(selector, node) {
if (node.type !== 'rule') {
return true;
}
return !node.selectors.some(function (sel) {
return _obsoleteAttributes.obsoleteAttributes.has(sel);
});
}
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(selector, node);
if (!isAccepted) {
_stylelint.utils.report({
index: node.lastEach,
message: messages.expected(selector),
node: node,
ruleName: ruleName,
result: result
});
}
});
};
}