postcss-sorting
Version:
PostCSS plugin to keep rules and at-rules content in order.
28 lines (21 loc) • 681 B
JavaScript
const atRuleExcludes = ['function', 'if', 'else', 'for', 'each', 'while'];
module.exports = function isAllowedToProcess(node, options) {
if (node.type === 'atrule' && atRuleExcludes.includes(node.name)) {
return false;
}
if (!node?.nodes?.length) {
return false;
}
const ignoreInterpolations = options && options.ignoreInterpolations;
if (!ignoreInterpolations) {
// postcss-styled-syntax: Interpolations at the end of node
if (node.raws.after?.includes('${')) {
return false;
}
// postcss-styled-syntax: Interpolations among children of a node
if (node.nodes.some((item) => item.raws.before.includes('${'))) {
return false;
}
}
return true;
};