Add stylelint-selector-bem-pattern so that components can opt-in on BEM-like rules #8139
Conversation
|
Up to you, this seems to work pretty well. I wonder if there are other linters that are popular for stylelint... |
b6131fc
to
e758a6c
|
I looked at other stylelint plugins or rules and nothing else seems to match our needs. Let's go with this solution for now, and I'll try to write a simpler plugin that we can use to replace this one later on. |
|
This looks like a nice solution but seems like it will be a massive undertaking. Is there any type of validation that occurs with this? What's a good plan moving forward? |
|
@darkwing The plan as discussed in #7905.
My strategy would be to work on some of the components from the "list of issues" progressively, and when we do see if we can opt-in to using Debugger doesn't have that many CSS components anyway. I think we could get to 50% coverage reasonably quick. |
|
@fvsch Would you be up for moving this over to MC so we could continue the conversation there? |
|
@darkwing Do you know how and when Eslint and stylelint are run when working on the Debugger on m-c? And then on the Try servers? You can perhaps show me next week. :) |
|
Of course! Let's sit down next week and I can help you get it all set up! :) |
Fixes parts of #7905.
Following discussion about global CSS styles in that issue, here's a test implementation of stylelint-selector-bem-pattern, and a few example usages in "weak" mode on a few components.
It seems to work alright. I found two downsides:
.foo .my-componentwhen the defined component name ismy-component. This is mostly an issue for.theme-(light|dark)styles. Using:root.theme-(light|dark)as a prefix "solves" it, but in practice it disables the rule completely for that selector.I'm kinda tempted to create a smaller and simpler Stylelint plugin for our needs.