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
Add selector-shadow-no-unmatchable
#5575
Comments
@renet Thanks for using the template and sharing your suggestion in good detail.
That sounds very useful.
We don't have a built-in rule for this yet.
That's correct. The
Yes, this new rule would fall into the possible errors category under the selector heading.
The scope of rule will need clarifying. We may need one catch-all rule, or smaller more focused ones, e.g. one for web components and another for I'll label as discussion in case anyone else wants to chime in, but I recommend going ahead and experimenting within a plugin. The name |
If we were to add a rule what about encompassing all functions that require one "simple selector"? |
With the possibilities in #5907 and @Mouvedia's suggested feature above, it feels like there's lots of scope for linting selectors that are unmatchable in some way. Let's break these into small and more focused rules. Let's limit this issue to disallowing unmatchable shadow dom selectors.
I've labelled the issue as ready to implement. Please consider contributing if you have time. There are steps on how to add a new rule in the Developer guide. @Mouvedia Can you open a new issue for your suggestion so that we can flesh out the details? |
This is too specific (niche cross-browser + only one pseudo-class) to warrant its own rule. * to be tallied, 2 for now |
Yes, that sounds like a good scope for the rule. Let's open a new issue so that we flesh it out. |
|
selector-shadow-no-unmatchable
My team develops a web components library, which comes with the usage of css selectors like
:host
and::slotted()
. Especially the last one allows only for selectors on the 1st level (light DOM "skin"), as explained here. Thus, selecting any child of a slotted element is not possible, like for example:for a DOM like
But it's easy, especially for devs new to web components / the shadow DOM, to make that mistake and try to use selectors like these. Right now, there seems to be no rule that prevents a developer from making these mistakes.
A new rule that throws an error, if a developer tries to write a selector, that by definition can never select anything. Afaik, this would at least apply to selectors like:
If there's rules for what I am looking for, then I'm sorry, but I didn't find any. I assume, that the selector-disallowed-list rule might be used as a workaround to achieve what I want, but this rule is actually part of the set of rules used to "limit language features" and I expect the above examples to be explicitly not part of the language features. Thanks for any replies in advance!
The text was updated successfully, but these errors were encountered: