stylelint-order
Version:
A collection of order related linting rules for Stylelint.
18 lines (14 loc) • 439 B
JavaScript
export function getContainingNode(node) {
if (node.type === 'rule' || node.type === 'atrule') {
return node;
}
// postcss-styled-syntax: declarations are children of Root node
if (node.parent?.type === 'root' && node.parent?.raws.isRuleLike) {
return node.parent;
}
// postcss-html `style` attributes: declarations are children of Root node
if (node.parent?.source.inline === true) {
return node.parent;
}
return node;
}