postcss / postcss-bem-linter

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

Added support for ignoreSelectors as string #69

Closed tornqvist closed 9 years ago

tornqvist commented 9 years ago

I'm using this with postcss-cli but ran into trouble when trying to implement ignoreSelectors since the options to postcss-cli are all strings.

Take my simple npm test script:

postcss -u postcss-bem-linter --postcss-bem-linter.preset suit --postcss-bem-linter.ignoreSelectors '\\.no-.+' -u postcss-reporter --postcss-reporter.throwError -d $TMPDIR ./components/**/*.css

So if ignoreSelectors is a string I try and convert it into a RegExp. I also added tests by piggybacking on the existing tests for ignoreSelectors.

davidtheclark commented 9 years ago

Thanks @tornqvist! This enhancement makes good sense to me.

Did you notice that the tests failed in Node 0.12 (because of the use Object.assign(), I believe)?

Also, if you wouldn't mind adding some corresponding documentation, that would help polish this off.

I plan to take a deeper look this weekend and hopefully merge it in. Thanks again.

tornqvist commented 9 years ago

I noticed that. I'll get right on it. And maybe the package.json should have an engines field just to clarify?

davidtheclark commented 9 years ago

@tornqvist : I incorporated the key contributions here into https://github.com/postcss/postcss-bem-linter/pull/71, and added to it so that all of the patterns can be strings (not just ignoreSelectors). Thanks again!

davidtheclark commented 9 years ago

@tornqvist : Please have a look at #71 and see if it suits your needs.

tornqvist commented 9 years ago

Sorry for the scruffy tests, I was trying to make sure that ignorePattern was tested both as regex and as a string, hence the nesting. In regard to your second comment, it was just a typo.

71 is just what I was hoping for. I appreciate the help!