epiphany/node_modules/postcss-sorting/lib/isAllowedToProcess.js
2023-12-09 22:48:07 -08:00

28 lines
676 B
JavaScript

const atRuleExcludes = ['function', 'if', 'else', 'for', 'each', 'while'];
module.exports = function isAllowedToProcess(node) {
if (node.type === 'atrule' && atRuleExcludes.includes(node.name)) {
return false;
}
if (!node?.nodes?.length) {
return false;
}
// 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;
}
// @stylelint/postcss-css-in-js only
if (node.nodes.some((item) => item.type === 'literal')) {
return false;
}
return true;
};