sourcegraph/stylelint-config

Custom Stylelint rule to ban BEM convention in CSS modules

開放

#131 建立於 2021年9月22日

 (1 則留言) (0 個反應) (1 位負責人)JavaScript (2 個分叉)auto 404
good first issue

倉庫指標

星標
 (6 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Problem statement

This summer we started the migration to CSS modules in the main Sourcegraph monorepo. We decided not to use the BEM convention in CSS modules apart from modifier selectors:

// Global CSS
.repo-header {
  &--active  { ... }
  &__button { ... }
}

// CSS module
.repo-header {
  &--active  { ... }
}

.button { ... }

Notice how we keep a nested modifier selector &--active. But the &__button selector is bubbled to the top level. To stick to this convention, we need a Stylelint rule to ban usage on &__* selectors in CSS modules.

Success criteria

  1. A custom Stylelint rule is created that warns if the &__* selector is used.
  2. It's added to our Stylelint config as a glob-based rule to apply it only to *.module.scss files.

Things to learn/practice during the implementation

Writing custom Stylelint rules to keep the codebase consistent.

Estimated amount of work

T-shirt size estimate: M.

貢獻者指南