Created
January 26, 2023 19:37
-
-
Save a-tokyo/ad6fd401f67ef669924b540b5c00f5d6 to your computer and use it in GitHub Desktop.
stylelint-selector-class-pattern-bem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Root Stylelint configuration */ | |
module.exports = { | |
rules: { | |
/** selector class pattern must match [BEM CSS](https://en.bem.info/methodology/css) - [Regex](https://regexr.com/3apms) */ | |
'selector-class-pattern': [ | |
'^[a-z]([-]?[a-z0-9]+)*(__[a-z0-9]([-]?[a-z0-9]+)*)?(--[a-z0-9]([-]?[a-z0-9]+)*)?$', | |
{ | |
/** This option will resolve nested selectors with & interpolation. - https://stylelint.io/user-guide/rules/selector-class-pattern/#resolvenestedselectors-true--false-default-false */ | |
resolveNestedSelectors: true, | |
/** Custom message */ | |
message: function expected(selectorValue) { | |
return `Expected class selector "${selectorValue}" to match BEM CSS pattern https://en.bem.info/methodology/css. Selector validation tool: https://regexr.com/3apms`; | |
}, | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment