question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use single underscore for BEM modifier classes instead of double-hyphen

See original GitHub issue

As of the 2.3.1 release of @salesforce-ux/design-system, it seems that the double-hyphen -- syntax for CSS modifier classes has been deprecated in favor of a single underscore _.

From https://www.lightningdesignsystem.com/release-notes/:

Release 2.3.1 - May 25, 2017

Big Impact

BEM Naming Change Initially we used the double dash style for BEM notation (–). Due to the fact that double dashes are problematic in an XML environment (which doesn’t allow double dashes within comments), we have upgraded our syntax to use the single underscore style (_). This change is backward compatible for 18 months. But all components going forward are built with the single underscore BEM style.

Ironically, the markup on that page seems to still use the double-hyphen syntax.

If the single underscore is the recommended syntax going forward (and if the double-hyphen syntax will be removed in a few months), it would be great to switch the @salesforce/design-system-react components and the examples in the documentation to use the new syntax.

In our codebase, it has caused a mixed use of both syntaxes. I ended up writing an ESLint rule with a fixer to resolve the issue for us (which I’m happy to provide here as well if you think it will be useful).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
interactivellamacommented, Sep 5, 2018
0reactions
interactivellamacommented, Sep 4, 2018

I plan to remove prettier-eslint in the next month or so and just go straight prettier AND eslint. I can remove it sooner than later if it makes it easier for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does BEM often use two underscores instead of one for ...
In standard BEM style, single underscores are reserved for modifiers. Also, they usually represent a combination of key/value pairs. E.g.
Read more >
The search for a Regex to match Hyphenated BEM CSS class ...
The element name is separated from the block name by a double underscore ( __ ). For boolean modifiers, the value is not...
Read more >
How to Use BEM Methodology - Toptal
Note that the best practice is to use BEM only with classes, ... a block name by a double underscore __; Boolean modifiers...
Read more >
Naming convention / Methodology / BEM - BEM Info
Words within the names of BEM entities are separated by a hyphen ( - ). The element name is separated from the block...
Read more >
BEM by Example: Best Practices for BEM CSS Naming
BEM names intentionally use double underscores and double hyphens instead of single to separate Block-Element-Modifier.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found