Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selectors.walk((selector) => {
// we only need to modify class names. We can ignore everything else,
// like existing attributes, pseudo selectors, comments, imports,
// exports, etc
if (parser.isClassName(selector)) {
let bemSelector = bemSelectorCache.get(selector.value);
// get the block class from the bemSelector
let blockClassName = bemSelector && bemToBlockClassMap.get(bemSelector);
// if the selector was previously cached
if (blockClassName) {
let stripSelector = false;
if (blockClassName.class) {
selector.value = blockClassName.class;
} else {
//prepend a :scope node before this and remove this node later
let newScopeNode = parser.pseudo({
value: ":scope",
});
root.walkRules(/&/, rule => {
const parentNodes = [];
const selector = getSelectorFromRule(rule.parent);
if (selector) {
parseSelector(selector, result, rule, fullSelector => {
fullSelector.walk(node => parentNodes.push(node));
});
}
if (parentNodes.length === 0) return;
const lastParentNode = parentNodes[parentNodes.length - 1];
if (!isClassName(lastParentNode)) return;
parseSelector(rule.selector, result, rule, fullSelector => {
fullSelector.walkNesting(node => {
const next = node.next();
if (!next) return;
if (validNestingTypes.some(isType => isType(next))) return;
utils.report({
ruleName,
result,
node: rule,
message: messages.rejected,
index: node.sourceIndex
});