postcss / postcss-bem-linter

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

linter skips selector with only @extends #118

Closed bencripps closed 7 years ago

bencripps commented 7 years ago

With the following CSS, the hasNoDeclarations function in get-selectors is returning true, which means we are not linting the selector name. (We're running our code through a couple plugins, mentioned below, but it looks like those are behaving correctly).

/** @define Foo */

.namespace-Component {
    @extend .myMixin;
}

I would expect this to provide a warning, but since the hasNoDeclarations function returns false, we early return before linting the selector name. I see the following comment:

  // Skip validation on rules with no declarations
  // as these don't exist after rules have been unwrapped

so I assume this is the expected behavior, but I wonder if we should add a clause for extends and other atrules?

We're using the following versions:

postcss: 5.2.17
postcss-bem-linter: 2.7.0
stylelint-selector-bem-pattern: 1.0.0
stylelint-config-suitcss: 7.0.0.
simonsmith commented 7 years ago

In your example what CSS would you expect the linter to be checking?

bencripps commented 7 years ago

I'd prefer that the linter not skip over this selector so we can verify we the class name matches our naming conventions (defined by stylelint-selector-bem-pattern).

In this case .namespace-Component does not match the comment at the top, so I would expect to see an error in the lint output.

simonsmith commented 7 years ago

Makes sense. Sounds like what you suggested is the sensible route and we don't assume these rulesets are empty.

simonsmith commented 7 years ago

Fixed in #119