-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selector-class-pattern
doesn't match BEM
#193
Comments
Yeah, it was broken previously, happy to roll in any proposed changes for this though, can possibly work with the Gutenberg team to discuss this further and come up with a scheme that works for all |
Updating this to work for BEM in the core standards would definitely be best! What naming convention/style is it supposed to be supporting now? The link in the first comment works reasonably well and I would propose something along those lines. I've looked into some more in-depth BEM naming rules but they seem to involve a dev setting up some configuration for each project which isn't great. |
The Gutenberg docs for this are at:
I'd suspect the relatively new #core-css team and @peterwilsoncc would have opinions |
this answer for you question |
I used the vanilla rule with a bit of custom config and it works perfectly: 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`;
},
},
],
}, |
We use BEM style selectors in our CSS. This adds a custom rule, based on some prior work by @a-tokyo, but adjusted to fit in our JSON configuration file. humanmade/coding-standards#193 (comment) simonsmith/stylelint-selector-bem-pattern#23
In #2397, we're having trouble with ignoring directories using the existing `scss-lint` configuration on Hound. `scss-lint` has been deprecated for a while and we have another configuration based on thoughtbot guides, so this is a good fit. We use BEM style selectors in our CSS. So we add a custom rule, based on some prior work by @a-tokyo, but adjusted to fit in our JSON configuration file. In addition, we disable these rules as they don't make sense on Administrate: * Disable scss/dollar-variable-empty-line-before on variables * Disable function-no-unknown/no-global function names https://github.com/thoughtbot/stylelint-config sds/scss-lint@4ac76f9 humanmade/coding-standards#193 (comment) simonsmith/stylelint-selector-bem-pattern#23
In #2397, we're having trouble with ignoring directories using the existing `scss-lint` configuration on Hound. `scss-lint` has been deprecated for a while and we have another configuration based on thoughtbot guides, so this is a good fit. We use BEM style selectors in our CSS. So we add a custom rule, based on some prior work by @a-tokyo, but adjusted to fit in our JSON configuration file. In addition, we disable these rules as they don't make sense on Administrate: * Disable scss/dollar-variable-empty-line-before on variables * Disable function-no-unknown/no-global function names https://github.com/thoughtbot/stylelint-config sds/scss-lint@4ac76f9 humanmade/coding-standards#193 (comment) simonsmith/stylelint-selector-bem-pattern#23
In the WordPress stylelint standards version 16.0.0, the selector-class-pattern was updated, but it doesn't allow for BEM naming patterns which can cause a huge quantity of stylelint errors.
I propose that we either remove the rule, or add a BEM-specific pattern in our ruleset and allow project to overrule this rule individually. I tried this rule out on a project when testing the upgrade for them and it works nicely in almost all situations: postcss/postcss-bem-linter#82 (comment)
The text was updated successfully, but these errors were encountered: