60 lines
No EOL
1.8 KiB
JavaScript
60 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"));
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
var ruleName = 'a11y/no-display-none';
|
|
exports.ruleName = ruleName;
|
|
var messages = _stylelint.utils.ruleMessages(ruleName, {
|
|
expected: function expected(selector) {
|
|
return "Unexpected using \"{ display: none; }\" in ".concat(selector);
|
|
}
|
|
});
|
|
exports.messages = messages;
|
|
function check(selector, node) {
|
|
if (node.type !== 'rule') {
|
|
return true;
|
|
}
|
|
return !node.nodes.some(function (o) {
|
|
return o.type === 'decl' && o.prop.toLowerCase() === 'display' && o.value.toLowerCase() === 'none';
|
|
});
|
|
}
|
|
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
|
|
});
|
|
}
|
|
});
|
|
};
|
|
} |