Document recommendation to turn no-descending-specificity off if using a lot of nesting
See original GitHub issueWhat steps are needed to reproduce the bug?
I think this isn’t specifically a bug, but the repo doesn’t have a discussion section. The problem I have is that I can’t find a way to sort my scss styles. I constantly get no-descending-specificity
and no-duplicate-selectors
errors.
.style-custom-scroll {
&::-webkit-scrollbar-track {
background-color: 'yellow';
}
&::-webkit-scrollbar-thumb {
&:active {
background-color: 'red';
}
&:hover {
background-color: 'blue';
}
}
&:active,
&:hover {
&::-webkit-scrollbar-track {
background-color: 'green';
}
}
}
This actually output no-descending-specificity
error:
- Expected selector “.style-custom-scroll:active” to come before selector no-descending-specificity “.style-custom-scroll::-webkit-scrollbar-thumb:active”
What Stylelint configuration is needed to reproduce the bug?
Dependencies:
"postcss": "^8.4.5",
"postcss-import": "^14.0.2",
"sass": "^1.48.0",
"stylelint": "^14.2.0",
"stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-config-standard": "^24.0.0",
"tailwindcss": "^3.0.14",
Config (package.json):
{
"extends":[
"stylelint-config-standard",
"stylelint-config-sass-guidelines"
],
"rules":{
"max-nesting-depth":[
5,
{
"ignore":[
"pseudo-classes"
]
}
],
"no-invalid-position-at-import-rule":[
true,
{
"ignoreAtRules":[
"use"
]
}
],
"scss/at-rule-no-unknown":[
true,
{
"ignoreAtRules":[
"tailwind",
"apply",
"layer",
"variants",
"responsive",
"screen"
]
}
]
}
}
How did you run Stylelint?
yarn run stylelint ./src/styles/base.scss --fix
Which version of Stylelint are you using?
14.2.0
What did you expect to happen?
I want to remove the errors.
What actually happened?
I get constantly no-descending-specificity
and no-duplicate-selectors
errors and I cant get out of them.
Does the bug relate to non-standard syntax?
No
Proposal to fix the bug
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Fix false positives for pseudo classes in no-descending ...
I'm wondering whether we should update the documentation to suggest people turn if off if they are writing deeply-nested code.
Read more >no-descending-specificity - Stylelint
It cannot catch every actual overriding selector, but it can catch certain common mistakes. We recommend turning this rule off if you use...
Read more >Deep nesting and recommendation for its usage - Elasticsearch
Now, it turned out that we had to use nested objects (documents) and it went around 4 levels deep almost per document.
Read more >Stylelint disable rule, "no-descending-specificity" null does not ...
What could be wrong here? Stylelint may not be using the configuration object that you added "no-descending-specificity": null to.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @jeddy3, thanks for the answer 🥇
The
body.style-custom-scroll
gives meselector-no-qualifying-type
. Right now the problem seems very obvious to me.I have a class called
style-custom-scroll
and I expect them have different behaviour if they are applied in a body tag or not. I think the problem here is that doing that is a bad practice. I just need to declare two or three diferent classes.For example:
So, as example, this would be the way it would be used:
This looks very similar to most css frameworks when you need to stylize a button:
This is my final result:
That’s a nice solution.