securityos/node_modules/stylelint-order/rules/order/calcRulePatternPriority.js

20 lines
432 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
module.exports = function calcRulePatternPriority(pattern, node) {
// 0 — it pattern doesn't match
// 1 — pattern without `selector`
// 2 — pattern match `selector`
let priority = 0;
// doesn't have `selector`
if (!pattern.hasOwnProperty('selector')) {
priority = 1;
}
// match `selector`
if (pattern.hasOwnProperty('selector') && pattern.selector.test(node.selector)) {
priority = 2;
}
return priority;
};