-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
📎 Implment no-duplicate-selectors #2514
Comments
Hi, I would like to contribute to this issue! 🙇 |
Still working on this one, will do a status update as soon as I can 🙇
Since we need to compare the all the selectors in the sheet against each other, as well as being able to compare whether selectors are equivalent I need to do some things to "resolve" the selector. |
I created a draft PR (#2660) Working on trying to get the selector resolver to properly resolve the I want to eventually remove the If there is some way to persist |
Update: working on another solution that does not rely on recursion (see the PR for context). Will attempt to reduce the scope covered by it so it's easier to review. |
I think having the new semantic model will help with my solution to this. Hope to continue with it if there's no rush, but feel free to assign to someone else if they really need this! |
Thanks @abidjappie. Feel free to ping me if you have the question about the model. Also, I'll write the documentation. About this rule, you can use |
@togami2864 thank you! I played around with the model yesterday and it definitely makes it a lot easier since I don't have to handle all the types of I used "Resolving" the selectors to their equivalent is still the main challenge, and I've found a few ways to achieve it but I still need to get it to pass the test cases. I'm using a |
I think that losing some of the data to the semantic model is going to make resolving them a bit difficult orz, e.g. // selector group 1
.a, .b { }
// selector group 2
.d .e { } Which would select: <!-- group 1 -->
<element class="a">
...
</element>
<element class="b">
...
</element>
<!-- group 2 -->
<element class="d">
<element class="e">
...
</element>
</element> These are both represented as (not true code): [{
Selectors: [ ".a", ".b" ]
},{
Selectors: [ ".d", ".e" ]
}] |
Currently, the model does not classify conditions in detail. biome/crates/biome_css_semantic/src/events.rs Lines 109 to 126 in a0f00fd
@abidjappie
And are there any other selectors or patterns need to be addressed besides the descendant combinator when implementing this rule? |
@togami2864 thanks for the response. How about something like this: /* Descendant combinator (space) */
.foo .bar {}
/* Selectors: [".foo .bar"] */
/* Resolved: [".foo .bar"] */
/* Child combinator (`>`) */
/* Probably treated same as child, column, next-sibling, etc. */
.foo > .bar {}
.foo || .bar {}
.foo + .bar {}
.foo ~ .bar {}
/* Selectors: [".foo>.bar"] - treat `>`, ` `, `||` etc. similarly */
/* Resolved: [".foo>.bar"] */
/* Selector list (comma) */
.a, .b { div {} }
/* Selectors: [".a",".b"], ["div"] */
/* Resolved: [".a", ".b", ".a div", ".b div"] */
/* `&` nesting selector */
.foo { .bar &:hover }
/* Selectors: [".foo"], [".bar &:hover"] */
/* Resolved: [".foo", ".bar .foo:hover"] */
/* Attribute, Class, ID selector */
type[attribute].class#id, div {}
/* Selectors: ["type[attribute].class#id", "div"] */
/* The details probably don't matter for these */ I think these cases would probably suffice for this rule. I'm not sure these are the kind of details we would want to add into the semantic model though? |
Description
Implmenet no-duplicate-selectors
Want to contribute? Lets you know you are interested! We will assign you to the issue to prevent several people to work on the same issue. Don't worry, we can unassign you later if you are no longer interested in the issue! Read our contributing guide and analyzer contributing guide.
The text was updated successfully, but these errors were encountered: