You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Naming convention: drop BEM entirely, or adopt it consistently? #33
Two reviewers have pointed in opposite directions on CSS class naming, and we're currently inconsistent in a way neither would endorse. The #16 lint series is landing the fixes as suggested in review — this issue is just to settle the convention so we stop rediscovering the question.
@aduth in #2, on "selector-class-pattern": null in .stylelintrc.json:
I think we should change the remaining BEM style classes… The naming needs to be self-consistent.
Two things that aren't obvious
1. The Gutenberg convention isn't textbook BEM. It uses __ for child elements, but modifiers are not-- — they're separate is-/has- classes (.components-panel.is-opened). So badge--experiment is wrong under both readings; under Gutenberg it'd be .accessibility-lab-badge.is-experiment. We already do this correctly for .accessibility-lab-row.is-dependent.
2. Our linter currently enforces the opposite of Gutenberg. We extend @wordpress/stylelint-config, whose selector-class-pattern is hyphens-only and rejects __. Gutenberg uses a different package, @wordpress/stylelint-tools, which explicitly allows __ and -- and ships a suppressions file for grandfathering. Upholding the Gutenberg rule is a package switch, not a config tweak.
Options
A — Drop BEM, kebab-case everywhere. Matches @joedolson, already enforced by our linter for free, no tooling change. But diverges from the Gutenberg convention, and names get long with no block/element boundary (accessibility-lab-media-view-config-field-description).
B — Adopt Gutenberg properly:__ for descendants, is-/has- for modifiers, switch to @wordpress/stylelint-tools. Matches @aduth and upstream expectations. But it's a tooling change, and it means revisiting the src/settings classes a second time.
(@aduth's suppressions idea is a migration mechanism for either option, not a third answer.)
I prefer non-BEM, overall; but I'm not going to argue the point if others prefer BEM. It's not a big deal to me one way or the other, but I would prefer to be consistent.
Another option is to adopt CSS modules, which is what a lot of newer Gutenberg code uses, and makes the whole naming problem moot at least from a conflicts point-of-view.
Activity
joedolson commentedon Sep 23, 2026
I prefer non-BEM, overall; but I'm not going to argue the point if others prefer BEM. It's not a big deal to me one way or the other, but I would prefer to be consistent.
troychaplin commentedon Sep 23, 2026
I'm a fan of BEM, but I don't care enough to push for that. Like @joedolson, I would prefer consistency.
aduth commentedon Sep 29, 2026
Another option is to adopt CSS modules, which is what a lot of newer Gutenberg code uses, and makes the whole naming problem moot at least from a conflicts point-of-view.