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
False positive for declarationless rules in no-duplicate-selectors #2198
Comments
@subzey I think it is bug, not feature, we should ignore |
it should be easy fix, add |
SGTM. Let's go with |
This rule fails if a CSS rule has a nested rule with selector When I started to figure out a solution for this problem and edge cases, I wrote following text based on the discussion above: What This shouldn't show warnings but shows now: .foo {
& {}
}
.foo {
&--bar {}
& {}
} This should show warnings, and it's ok: .foo {
color: red;
& {
color: blue;
}
} How about this: .foo {
/* comment 1 */
& {}
/* comment 2 */
&--bar {}
} Should it fails, if there are nested rules and comments? Processed CSS would have two There are few more edge cases for non-standard syntax: .foo {
@include icon;
& {
color: red;
}
} .foo {
@at-root & {
color: red;
}
} .foo {
@media (min-width: 300px) {
& {
color: pink;
}
}
} Now I re-read We shouldn't check rule content because we can't predict what preprocessors will compile. Following code: .foo {
& {}
} Can be compiled as We don't know how it will compile. But in most cases, it will compile as To sum up, I think it's a correct behavior for .foo {
& {}
} |
@hudochenkov can you send failed test PR? so it will be much easier to solve the problem |
@evilebottnawi how failed test should be written in a test code? Should it really fail tests? I believe this rule should throw warnings in this particular case, so I can add tests in |
@hudochenkov Thanks for doing the investigation.
I agree with your assessment. Does that means this issue can be closed? |
Yeah, after I'll add tests, so we won't forget about correct behaviour :) |
Closed because it works as expected. Explanation in a comment above. |
@7iomka you have duplicate selector on line 13. |
@hudochenkov , What do you think about this .class {
&, /* <-- no-duplicate-selectors error here */
> .content {
display: block;
}
} The error still in |
A feature request. Add a secondary option
ignoreEmpty
tono-duplicate-selectors
, so blocks with no content won't count.The use case:
This LESS code is linted as
triggering a
no-duplicate-selectors
error/warning.ignoreEmpty
would allow using such a style, yet catching the "real" errors, like this:no-duplicate-selectors
e.g.
e.g.
7.6.0
CLI, as a git hook and with SublimeLinter-contrib-stylelint
Yes, it's about LESS nesting
&
within a rule without properties is not treated as a duplicate block&
within a rule without properties is treated as a duplicate blockThe text was updated successfully, but these errors were encountered: