Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylelint-scss selector-no-union-class-name breaks entire stylelint process #345

Closed
jantimon opened this issue Jul 16, 2019 · 3 comments · Fixed by #346
Closed

stylelint-scss selector-no-union-class-name breaks entire stylelint process #345

jantimon opened this issue Jul 16, 2019 · 3 comments · Fixed by #346
Labels
Bug 🐛 Something isn't working

Comments

@jantimon
Copy link
Contributor

Reproduction css example:

@mixin demo() {
   @content;
}

.a-selector {

  @include demo() { 
      button:hover & {
  	background:purple
     }
  }

}

If you run this code against the selector-no-union-class-name test it will crash the entire process.

I did some research and found out that the reason is that the parent of button:hover & { is @include demo() { and therefore there is no selector property for the parent in this line:

https://github.com/kristerkari/stylelint-scss/blob/147b44cf10725fbf7b08a33885a6f7b7b8df4bb9/src/rules/selector-no-union-class-name/index.js#L38

undefinedSelector

The good news is that the selector is in the parent of the parent:
parent_parent

So probably we could just iterate over the parents until we find the closest parent with a selector` property.
If none can be found we just skip the test.

What do you think?

@kristerkari
Copy link
Collaborator

Thanks! I'll have a look at it

@kristerkari
Copy link
Collaborator

@jantimon I made a PR with a fix: #346

@kristerkari kristerkari added the Bug 🐛 Something isn't working label Jul 18, 2019
@jantimon
Copy link
Contributor Author

Added a small improvement over #346 in #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Something isn't working
2 participants