securityos/node_modules/postcss-sorting/lib/isAllowedToProcess.js

29 lines
676 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
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;
};