elirasza / stylelint-stylistic

Plugin for endangered stylelint stylistic rules.
Other
64 stars 3 forks source link

Multiline pseudo selector #15

Open zipper opened 1 year ago

zipper commented 1 year ago

I have a selector which looks like this:

.foo:where(
    :not(
        .bar,
        .baz
    )
) {
    margin: 0
}

Even though I consider this to be well formatted, this selector triggers multiple errors: 2:5 ✖ Expected indentation of 0 spaces stylistic/indentation 3:9 ✖ Expected indentation of 4 spaces stylistic/indentation 4:9 ✖ Expected indentation of 4 spaces stylistic/indentation 5:4 ✖ Unexpected whitespace before ")" stylistic/selector-pseudo-class-parentheses-space-inside 5:5 ✖ Expected indentation of 0 spaces stylistic/indentation

Correct form according to default settings (except indentation is to 4) would be like this, which I believe is not right, nor pretty.

.foo:where(
:not(
    .bar,
    .baz
)
) {
    margin: 0;
}

Note that it keeps the closing parentheses on separate lines even with selector-pseudo-class-parentheses-space-inside set to its default value (never), but removes some spaces before. Similarly, when I nest the selector into media query, the formatting after fix is off. This time, the behaviour of closing parenthesis differ:

Input Formatted by stylelint fix (default config) `'selector-pseudo-class-parentheses-space-inside': null`
```css @media screen { .foo:where( :not( .bar, .baz ) ) { margin: 0; } } ``` ```css @media screen { .foo:where( :not( .bar, .baz)) { margin: 0; } } ``` ```css @media screen { .foo:where( :not( .bar, .baz ) ) { margin: 0; } } ```

Same thing happens when SCSS nesting is used.

When simplified version is used, I get similar behaviour, except the selector-pseudo-class-parentheses-space-inside doesn't matter again:

Input Formatted by stylelint fix (default config)
```css .foo:where( .bar, .baz ) { margin: 0; } ``` ```css .foo:where( .bar, .baz ) { margin: 0; } ```

I think those inputs should be considered well-formatted and should not throw an error. Am I missing something in the settings or should this be considered a bug? I think it is a bug with multiline parentheses in selectors as opposed to property values.