Closed foresightyj closed 5 years ago
To fix my problem, all I have to do is to replace getComponentRootRule
in get-selectors.js
:
function getComponentRootRule(node) {
while (node.root() !== node) {
node = node.parent;
}
return node;
}
by:
function getComponentRootRule(node) {
while (node.root() !== node.parent) {
node = node.parent;
}
return node;
}
The original getComponentRootRule
returns the top level node that has type root
which in my case I only want to reach to the top level node that has type rule
.
Closed by #139
I experienced this problem while using stylelint-selector-bem-pattern. But this problem is completely reproducible in postcss-bem-linter so I raised the issue here.
In my project, I am migrating an existing scss code base into BEM. Because there are many css rules involving primitive html tags directly like
my-component h1 {}
, I am trying to relax the rules a little bit so that tags with stronger semantics (like a, h1-h6, ul, li, etc) are allowed in combined position.Here is my config and code:
package versions:
However, when running, the result is:
It seems that the problem only exists, when I have two
BEM
components in the same file. If I delete the line from/** @define notification */
till the end, no more errors. But I do prefer multiple BEMs in the same files or the team members may complain about the troubles.In vscode with stylelint, I have:
What did I do wrong, or is my use case not supported?