stylelint: Fix configuration comments within selector and value lists being ignored

I was told in https://github.com/rstacruz/stylelint-rscss/issues/11#issuecomment-350542523 that this is a problem in stylelint rather than stylelint-rscss.

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

    &:checked ~ .single-steward-header, // stylelint-disable-line rscss/class-format
    &:checked ~ .toggle {
      //
    }

still triggers an error for the first line: Invalid element name: '.single-steward-header' rscss/class-format

ATM you have to do this instead:

    // stylelint-disable
    &:checked ~ .single-steward-header,
    // stylelint-enable
    &:checked ~ .toggle {
      //
    }

Which rule, if any, is this issue related to?

stylelint-disable-line

What CSS is needed to reproduce this issue?

See above.

What stylelint configuration is needed to reproduce this issue?

{
  "extends": [
    "stylelint-rscss/config"
  ]
}

Which version of stylelint are you using?

8.2.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

Webpack with stylelint-webpack-plugin.

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

Yes, SCSS.

What did you expect to happen?

No warnings to be flagged.

What actually happened (e.g. what warnings or errors you are getting)?

The following warnings were flagged:

Invalid element name: '.single-steward-header'   rscss/class-format

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 26 (19 by maintainers)

Most upvoted comments

@romainmenke Thanks for describing the solution. If we can maintain backward compatibility with other syntaxes like SCSS, there will be no problems.

And for now, I don’t think supporting non-standard comments like // is necessary. We can still use /* */ comments on such non-standard syntaxes, and we should usually avoid introducing more complexity than needed. Thanks for considering a possible solution. Let’s revisit it if people would strongly request //.

The direction of #7839 sounds good to me. 👍🏼

@ybiquitous We will continue to use the Comment node wherever possible. We also won’t change anything about things that already work.

The proposed change only adds an extra step where we also check other parts of the AST for comments.

For example:

.foo {
  color: rgb(255 /* stylelint-disable-line */ 0 0);
}

But I do share your concerns about other syntaxes. This won’t work because // stylelint-disable-line isn’t a standard CSS comment.

.foo {
  color: rgb(
    255 // stylelint-disable-line
    0
    0
  );
}

It also doesn’t work today, but it is still possible surprising given that this would work with the proposed change:

.foo {
  color: rgb(
    255 /* stylelint-disable-line */
    0
    0
  );
}

As I said before, please open a new issue if you think there are other bugs.

I will once this issue is fixed. i.e. there are no bugs right now