sourcegraph/stylelint-config

Custom Stylelint rule to ban BEM convention in CSS modules

Ouverte

#131 ouverte le 22 sept. 2021

 (1 commentaire) (0 réaction) (1 personne assignée)JavaScript (2 forks)auto 404
good first issue

Métriques du dépôt

Stars
 (6 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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.

Guide contributeur