Skip to content

Instantly share code, notes, and snippets.

@frontendbeast
Last active May 26, 2016 06:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frontendbeast/0034b7697cc9831c693d to your computer and use it in GitHub Desktop.
Save frontendbeast/0034b7697cc9831c693d to your computer and use it in GitHub Desktop.
Namespaced, hyphenated BEM covention regex for SCSS-Lint
linters:
SelectorFormat:
convention: ^(_)?[a-z]+-[a-z0-9-]+((_{2}|-{2})?[a-z0-9-]+)?(-{2}[a-z0-9-]+)?[a-z0-9]$
convention_explanation: 'should be written in namespaced, hyphenated BEM format'
ignored_types: [element]
@frontendbeast
Copy link
Author

SCSS-Lint config for namespaced, hyphenated BEM format. The regex is taken from Harry Roberts' post More transparent UI code with namespaces. SCSS-Lint validates against the selector, so the period requirement has been removed from the regex.

The convention_explanation option requires v0.37.0 or greater.

@ArmorDarks
Copy link

Just to mention — this regex won't accept following selectors:

test
test-m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment