postcss / postcss-bem-linter

A BEM linter for postcss
MIT License
571 stars 35 forks source link

Allow both /** and /* for module definitions #125

Closed ehzhang closed 6 years ago

ehzhang commented 6 years ago

Thanks for this excellent plugin!

We've been using this to enforce our usage of suit-style css, but found that for some of our module definitions, the linter was silently failing when the module definitions were close but not quite right.

In this case, we found that the /* @define Foo */ would look correct, but not trigger the linter.

This seemed to be because the comment text provided by the walkComment callback includes everything after the initial /*, so the DEFINE_DIRECTIVE was matching against * @define Foo, and just @define Foo would fail the match.

This PR adds an optional flag to the regex and adds some tests to ensure that a correctly defined definition recognizes a bad rule.

I noticed that there were some comments and PRs related (like this one) but I'm not sure if this is an intended behavior to only have the /** style vs also allowing /*. Interested to hear your thoughts!

simonsmith commented 6 years ago

Hey @ehzhang, thanks for the PR!

I think this is a good change and reduces the chance of accidentally skipping linting on a file (as you experienced).

@davidtheclark Just to check, any historical reason that only /** works?

simonsmith commented 6 years ago

Okay, merging. Thanks again @ehzhang, I'll get a release out shortly.

ehzhang commented 6 years ago

Thanks @simonsmith!

simonsmith commented 6 years ago

https://github.com/postcss/postcss-bem-linter/releases/tag/3.1.0