New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix false positives for trailing combinator in selector-combinator-space-after #4878
Fix false positives for trailing combinator in selector-combinator-space-after #4878
Conversation
…paceChecker copied over from a (now mangled) PR on malsf21/stylelint
Thank you for continuing to work on this issue. The pull request is almost ready, I think.
The The a {
> b {
...
}
} Is not, I believe, a standard CSS combinator.
Yes, I think so. |
Hey @jeddy3, Thank you for taking the time to go back-and-forth with me on this PR. I've removed the special case, and adjusted the test case in a way that I think best implements the feature - but, the caveat is that it actually removes some extra rejection cases. For example, consider the following for a {
> /*comment*/a {
}
} in conjunction with the test config {
code: 'a { >/*comment*/a {} }',
fixed: 'a { > /*comment*/a {} }',
description: 'scss nesting and comment',
message: messages.expectedAfter('>'),
line: 1,
column: 5,
}, Previously, we would reject this. However, the new implementation of Another way I could re-do these specific test cases (and still keep the original test ) is to add the {
code: 'a { & >/*comment*/a {} }',
fixed: 'a { & > /*comment*/a {} }',
description: 'scss nesting and comment',
message: messages.expectedAfter('>'),
line: 1,
column: 7,
}, But this kind of dodges the main problem, which is dropping certain rejection cases, and I don't think it actually tests for Sorry for this wall of text, but I want to make sure I get this right! Let me know what you think, and if there's a different option I should take. If not, I think the PR is good to be reviewed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, LGTM!
In my opinion, this seems quite reasonable, since this is the same philosophy behind the problem in the original issue #4584; however, I do want to clarify if I'm taking this approach properly.
Yes, you are. The built-in rules are geared towards standard CSS. A plugin author can, if they like, create scss/selector-combinator-space-after
that deals with non-standard things like the implicit nesting selector. This is already the case for many other SCSS and SCSS-like syntax.
* master: (34 commits) Update CHANGELOG.md Fix double-slash disable comments when followed by another comment (#4913) Update CHANGELOG.md (#4916) 13.7.0 Prepare 13.7.0 Prepare changelog Update dependencies Update CHANGELOG.md Deprecate *-blacklist/*-requirelist/*-whitelist (#4892) Fix some path / glob problems (#4867) Update CHANGELOG.md Add a reportDescriptionlessDisables flag (#4907) Fix CHANGELOG.md format via Prettier (#4910) Fix callbacks in tests (#4903) Update CHANGELOG.md Fix false positives for trailing combinator in selector-combinator-space-after (#4878) Add coc-stylelint (#4901) Update CHANGELOG.md Add support for *.cjs config files (#4905) Add a reportDisables secondary option (#4897) ...
Hey there!
This is a PR that tries to fix the false positive brought up in #4584, namely that a trailing combinator (such as the general sibling combinator,
~
) is not properly handled byselector-combinator-space-after
.After some discussion in #4849, this PR implements a fix by updating the
isStandardSyntaxCombinator
rule util to ignore certain combinators that are the first or last combinator in their container. Since combinators should generally be between two different selectors, we can rule out combinators that... aren't. Then, we use this new utility inselectorCombinatorSpaceChecker
, which then fixes the false positive inselector-combinator-space-after
.I also added some test to verify our functionality, for
isStandardSyntaxCombinator
and for the case mentioned in #4584 inselector-combinator-space-after
.Closes #4584.
First, a quick question about the
>
nesting selector: I had to ignore this, because the following SCSS is standard:Not sure if this is the right approach, or if I should instead update the existing tests. Any thoughts on this would be appreciated.
Also, a meta-note: this is a fresh version of the PR #4849, which had some issues after merging
master
back into the forked repository. Copied over the code to a fresh branch frommaster
.