Skip to content
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

BEM lint should allow block's/element's boolean modifier in shorthand. #419

Closed
christophercochran opened this issue Apr 10, 2015 · 5 comments
Labels

Comments

@christophercochran
Copy link

Hi, I wouldnt consider myself a BEM expert, and fairly new to using it, but currently the BEM lint only allows block's/element's boolean modifier in key-value format.

For example:
block-name_mod-name_mod-val // allowed
block-name_mod // not

block-name__elem-name_mod-name_mod-val // allowed
block-name__elem_mod // not

Shouldn't block-name_mod and block-name__elem_mod be allowed? Or in writing BEM when using a modifier shouldn't it always be in key-value format?

@sds sds added the question label Apr 12, 2015
@sds
Copy link
Owner

sds commented Apr 12, 2015

Hey @christophercochran,

It sounds like you are trying to use the hyphenated_BEM convention, not BEM? See the discussion in #335 for more information.

Others have been tripped up by this as well, so we may call greater attention to this by renaming BEM to strict_BEM.

@sds sds closed this as completed Apr 12, 2015
@christophercochran
Copy link
Author

@sds From my understanding hyphenated_BEM is for writing BEM like classes like:
block-name--mod
block-name__elem--mod

where the modifier is delimited by a '--' (double hyphen) instead of '_' (single underscore).

block-name_mod
block-name__elem_mod

is following BEM naming convention set by BEM (https://github.com/bem/bem-naming/blob/master/README.md) and would use a single underscore instead of the double hyphen, so should still be within the convention of BEM and not hyphenated_BEM.

block-name_modifier_value
block-name__elem_modifier_value

are currently allowed, but sometimes it is simpler to just write block-name_mod. Unless I am wrong and block-name_mod is not allowed, but in the link above it seems that it should be.

@sds
Copy link
Owner

sds commented Apr 15, 2015

It seems like your understanding is correct. Unfortunately, our team does not use strict_BEM ourselves, but hyphenated_BEM instead, so I'm not familiar enough with the definition of strict_BEM to really speak to this issue.

The original regex was provided by @mrpavlikov in #254 (comment), who I believe is also using strict_BEM. @mrpavlikov, can you speak to this issue at all?

@christophercochran if you provide me a modified regex that matches the cases you expect and include some tests, I would happily merge a pull request. Thanks!

@mrpavlikov
Copy link
Contributor

Hello everyone!

Or in writing BEM when using a modifier shouldn't it always be in key-value format?

Yes, correct, only key-value pair, like when you are writing css you write which property will have which value. Same goes for modifiers, you say what will be modified and which way. Check this out: https://en.bem.info/method/definitions/#modifiers-for-blocks

A modifier has a name and a value.

@christophercochran
Copy link
Author

@mrpavlikov Thank you for your explanation. I saw one mention of boolean statements, but now that I think of it, in the world of CSS, these would be few anyways, and having the name and value does give more detail into what the modification is. Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants