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 ignore: ["inside-block"]
to selector-disallowed-list
#6294
Comments
&
&
I've closed this issue because of not using the issue template. Please provide more details like background, reason, use cases, etc. |
@yairEO Thanks for using the template. I understand your motivation. Your request seems to be satisfied by validators like the Sass: See also our document about validators. |
&
ignore: ["inside-block"]
to selector-disallowed-list
This is an interesting one. According to the latest draft spec
I think the CSSTree validator is currently flagging it as doesn't parse nesting outright yet, e.g.: Stylelint is a good fit for CSS that is valid, but probably wasn't what the author intended to write. It'd be inline with the other I can see us adding a whole suite of rules for nesting when the specification does stabilise, though. For example, there is plenty of other valid nesting CSS that a person would probably want to limit: a {
&& {}
} Or enforce a particular notation, e.g. these two are equivalent: a {
@media (orientation: landscape) { color: red; }
}
a {
@media (orientation: landscape) { & { color: red; } }
} I suggest that anyone who is interested in these create plugins that we can port over to built-in rules once the specification stabilises. In the meantime, we can add an It's not a perfect solution as the option will apply to all the items in the array, but it'll probably address @yairEO immediate use case. |
The spec will be implemented in new browser, while many of today's projects need to support older browsers, of probably 2+ years old, and in that case, even if the spec says something, it's irrelevant for those mentioned projects since that CSS results a bug, which a rule should prevent. |
@yairEO 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 option in the Developer guide. |
Glad I found this. I was about to create this issue. Happy for you to raise the PR. Otherwise, I can do it if you don't mind as we'd like this fix for a different use case. Ours is to disallow root level classes used in our UI lib, to be used at our application codebase to avoid global styling override issues. We just want to allow overriding if done inside a block of a page level class. The solution just involves disallowing selectors with a ruleNode.parent.type !== 'root' and it works pretty well if given the right regexp. |
That's correct. It'd just be the case of returning early if the
@mattmanuel90 as @yairEO hasn't indicated they're working on it, you're welcome to create a pull request yourself. |
I'm a single person, not "they".. I don't have the time capacity as I already am the author of dozens of open-source projects and have a fulltime job and also need to find the time watching funny cats YouTubes while eating watermelons and thus more busy than Elon MusK |
What is the problem you're trying to solve?
I also want to disallow top-level selectors which are starting with
&
because that's invalid CSS code(common to
SASS
precompiler language but is not restricted to it)What solution would you like to see?
either top-level flexible regex rule or an explicit rule for anything starting specifically with
&
The text was updated successfully, but these errors were encountered: