-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: max-specificity rule #24
base: main
Are you sure you want to change the base?
Conversation
We added Due to these pseudo-classes, it makes a poor proxy for controlling selector complexity and for disallowing ID selectors. For example, both these selectors have a specificity of :where(#id),
:where(a.complex[attr], #id) {} And makes a poorer proxy for disallowing other types of selectors as it groups them:
It'd be good to hear if people have another use for this rule. If you do keep it, the implementation should probably consider these specificity-changing pseudo-classes and nesting, which is Baseline 2023. In Stylelint, we use a, b {
& c {}
}
/* should be desugared to */
:is(a, b) c {}
/* be we currently desugar to */
a c, b c {} This can lead to different specificities, and our calculations may not match the browser. |
Interesting. I think I'll need to dig into this a bit more. |
Take a look at bramus/specificity. It appears to to cover all the key aspects of selector specificity calculation according to the latest CSS specifications. Since it’s built on top of CSSTree, it might be a good candidate for adoption instead of implementing a custom specificity calculation from scratch (see calculate.js). |
Hi @nzakas!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.
To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page. Read more about contributing to ESLint here |
Prerequisites checklist
What is the purpose of this pull request?
Implement a
max-specificity
rule.What changes did you make? (Give an overview)
max-specificity
ruleRelated Issues
fixes #19
Is there anything you'd like reviewers to focus on?
This is a rough draft, I'd like some feedback on the design.
a
,b
, andc
to match the spec? Or would it better to just have them enter an array?