-3

I'm setting up a .stylint file for my VS Code editor. Here is the example:

#main > div // there is no comma so stylint should throw an error here
div {
     ...
}

#main > div, // this is ok, no error here
div {
     ...
}
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
Mateusz
  • 23
  • 5
  • Please provide more details and/or code about your issue. We cannot help you so far. – Ced Jan 09 '19 at 15:13
  • @Ced I really cannot be more clear... – Mateusz Jan 09 '19 at 15:16
  • Oh man, another site that explicitly states to ask on SO in case of problem, and even "blocks" questions on their github.. Did you read the faq? What have you tried and what went wrong with it? You are supposed to show an attempt to solve it yourself first.. – Kaddath Jan 09 '19 at 15:37
  • @Kaddath I was trying to do it by myself and spend 2 hours looking for proper stylelint rule in the documantation but couldnt find any that works... – Mateusz Jan 09 '19 at 15:43
  • The first selector **is valid** so no error is required..or, I suspect, **possible**. – Paulie_D Jan 09 '19 at 16:11
  • @Paulie_D I know, it's just styling – Mateusz Jan 10 '19 at 08:09

1 Answers1

0

It is not possible to do this with the built-in rules in stylelint because the following is a valid selector:

#main > div
div {}

It's the equivalent of:

#main > div div {}

As the descendant combinator is any whitespace, including a newline.

However, you could write your own plugin for stylelint that enforces a comma at the end of each line of a selector, but the consequences of the plugin may be problematic unless you can guarantee that each selector within a selector list will occupy a single line.

jeddy3
  • 3,451
  • 1
  • 12
  • 21