Is it possible to disable certain eslint rules?
Wasn’t able to find anything specific inside resources/assets/build/ that might help with this.
For example, I’m having many issues with this specific rule: ‘no-descending-specificity’; it throws errors like:
Expected selector ".card.card-simple:hover .card-footer button" to come before selector ".img-split .img-split-el .img-split-cont:hover no-descending-specificity
.img-split-btn button"
This prevents me from continuing my work or just forces me to do things very differently which is not alway good. Any ideas about how to get around this rule, that I believe is a bit broken?
Both of these selectors target button, but the first one has higher specifity. Generally, you should structure your CSS so that it starts with lower specificity and moves to higher: Your arrangement inverts that, which is what Stylelint is complaining about.
Switching their order is the simplest fix, but if you replace the final item (currently button in both cases) with a selector that differs, that should also work. i.e.:
Shouldn’t this apply only to same parent elements? Why should specifity matter if the parent is different? Otherwise, your solution works indeed yeah. But am still confused as to why this throws the error here since the parent selector is different and we’r targeting a totally different thing at the end.
From an HTML perspective, yes, you are targeting different elements, but from a CSS perspective you aren’t: both selectors target a button. The way CSS works and the way those selectors are written, both of them could target the same element–you just happen to know they don’t because you wrote the HTML. This is exactly the kind of ambiguity CSS specificity is intended to resolve. It’s also why I usually try to write CSS selectors that are as simplistic as possible: ideally only 1 to 2 elements per selector.
In other words, think about your rules as describing the state of .navbar-toggler-icon instead of how .navbar-dark/light affects .navbar-toggler-icon. Without the dark.light options, your toggler icon has only two states: open, and collapsed. That would have rules like this:
Hey, thanks for your answer: I was trying to make it work like that from start to be honest: but your example does not work because .collapsed is not on the .navbar-toggler-icon element.
In which package.json did you added it?
Maybe sage changed, but for me I needed to edit the node_modules/stylelint-config-recommended/index.js file to get rid of it.
I have to agree with the op here. I understand spcifity but sometimes this is broken.
Specifically I’m running into issues using a:hover. Which ever one I put first it still throws an error.
Expected selector “.nav li a” to come before selector “.banner a:hover” no-descending-specificity
Expected selector “.banner a” to come before selector “.nav li a” no-descending-specificity