★ wanayoo — archive 1999 https://github.com/firefox-devtools/debugger/pull/8139Nouvelle recherche | Portail wanayoo
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

Add stylelint-selector-bem-pattern so that components can opt-in on BEM-like rules #8139

Open
wants to merge 4 commits into
base: master
from

Conversation

@fvsch
Copy link
Member

@fvsch fvsch commented Mar 18, 2019

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:

  1. The dependencies are a bit on the heavy side (374 packages, like +37MB in node_modules).
  2. Even in weak mode, it chokes on selectors like .foo .my-component when the defined component name is my-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.

@jasonLaster
Copy link
Contributor

@jasonLaster jasonLaster commented Mar 19, 2019

Up to you, this seems to work pretty well.

I wonder if there are other linters that are popular for stylelint...

@fvsch fvsch force-pushed the fvsch:stylelint-selector-bem-pattern branch from b6131fc to e758a6c Mar 20, 2019
@fvsch
Copy link
Member Author

@fvsch fvsch commented Mar 20, 2019

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.

@darkwing
Copy link
Contributor

@darkwing darkwing commented Mar 25, 2019

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?

@fvsch
Copy link
Member Author

@fvsch fvsch commented Mar 26, 2019

@darkwing The plan as discussed in #7905.

  • Against: adding tooling which transforms CSS selectors (like CSS Modules)
  • For: trying to use BEM or similar manually-scoped naming conventions for new components / updates to componets
  • For: fixing potentially dangerous global CSS as listed in #7905 (comment) (hereafter "list of issues")

This looks like a nice solution but seems like it will be a massive undertaking.

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 /* @define component-name; weak */.

Debugger doesn't have that many CSS components anyway. I think we could get to 50% coverage reasonably quick.

@darkwing
Copy link
Contributor

@darkwing darkwing commented Apr 10, 2019

@fvsch Would you be up for moving this over to MC so we could continue the conversation there?

@fvsch
Copy link
Member Author

@fvsch fvsch commented Jun 15, 2019

@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. :)

@darkwing
Copy link
Contributor

@darkwing darkwing commented Jun 15, 2019

Of course! Let's sit down next week and I can help you get it all set up! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants