Showing 5,697 of 5,698 total issues
Expected selector ".swagger-ui-wrap p#colophon a" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a" (no-descending-specificity) Open
.swagger-ui-wrap p#colophon a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap form.form_box p a" to come before selector ".swagger-ui-wrap .model-signature .signature-nav a" (no-descending-specificity) Open
.swagger-ui-wrap form.form_box p a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Unexpected duplicate selector ".markdown-body ol,
.markdown-body ul", first used at line 360 (no-duplicate-selectors) Open
.markdown-body ol,
- Read upRead up
- Exclude checks
no-duplicate-selectors
Disallow duplicate selectors within a stylesheet.
<!-- prettier-ignore -->.foo {} .bar {} .foo {}
/** ↑ ↑
* These duplicates */
This rule checks for two types of duplication:
- Duplication of a single selector with a rule's selector list, e.g.
a, b, a {}
. - Duplication of a selector list within a stylesheet, e.g.
a, b {} a, b {}
. Duplicates are found even if the selectors come in different orders or have different spacing, e.g.a d, b > c {} b>c, a d {}
.
The same selector is allowed to repeat in the following circumstances:
- It is used in different selector lists, e.g.
a {} a, b {}
. - The duplicates are determined to originate in different stylesheets, e.g. you have concatenated or compiled files in a way that produces sourcemaps for PostCSS to read, e.g. postcss-import.
- The duplicates are in rules with different parent nodes, e.g. inside and outside of a media query.
This rule resolves nested selectors. So a b {} a { & b {} }
counts as a violation, because the resolved selectors end up with a duplicate.
Expected selector ".swagger-ui-wrap a" to come before selector ".swagger-ui-wrap h4 a:hover" (no-descending-specificity) Open
.swagger-ui-wrap a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap h2 a" to come before selector ".swagger-ui-wrap h4 a:hover" (no-descending-specificity) Open
.swagger-ui-wrap h2 a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap td" to come before selector ".swagger-ui-wrap table tbody tr:last-child td" (no-descending-specificity) Open
.swagger-ui-wrap td {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a" to come before selector ".swagger-ui-wrap ul#resources li.resource div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover" to come before selector ".swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a" to come before selector ".swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a" to come before selector ".swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap .markdown pre" to come before selector ".swagger-ui-wrap .model-signature pre:hover" (no-descending-specificity) Open
.swagger-ui-wrap .markdown pre {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover" to come before selector ".swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active,
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a" to come before selector ".swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active,
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover" to come before selector ".swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.
Expected selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a" to come before selector ".swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a" (no-descending-specificity) Open
.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a {
- Read upRead up
- Exclude checks
no-descending-specificity
Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
<!-- prettier-ignore -->#container a { top: 10px; } a { top: 0; }
/** ↑ ↑
* The order of these selectors represents descending specificity */
Source order is important in CSS, and when two selectors have the same specificity, the one that occurs last will take priority. However, the situation is different when one of the selectors has a higher specificity. In that case, source order does not matter: the selector with higher specificity will win out even if it comes first.
The clashes of these two mechanisms for prioritization, source order and specificity, can cause some confusion when reading stylesheets. If a selector with higher specificity comes before the selector it overrides, we have to think harder to understand it, because it violates the source order expectation. Stylesheets are most legible when overriding selectors always come after the selectors they override. That way both mechanisms, source order and specificity, work together nicely.
This rule enforces that practice as best it can, reporting fewer errors than it should. It cannot catch every actual overriding selector, but it can catch certain common mistakes.
How it works
This rule looks at the last compound selector in every full selector, and then compares it with other selectors in the stylesheet that end in the same way.
So .foo .bar
(whose last compound selector is .bar
) will be compared to .bar
and #baz .bar
, but not to #baz .foo
or .bar .foo
.
And a > li#wag.pit
(whose last compound selector is li#wag.pit
) will be compared to div li#wag.pit
and a > b > li + li#wag.pit
, but not to li
or li #wag
, etc.
Selectors targeting pseudo-elements are not considered comparable to similar selectors without the pseudo-element, because they target other elements on the rendered page. For example, a::before {}
will not be compared to a:hover {}
, because a::before
targets a pseudo-element whereas a:hover
targets the actual <a>
.
This rule only compares rules that are within the same media context. So a {} @media print { #baz a {} }
is fine.
This rule resolves nested selectors before calculating the specificity of the selectors.
DOM Limitations
The linter can only check the CSS to check for specificity order. It does not have access to the HTML or DOM in order to interpret the use of the CSS.
This can lead to valid linting errors appearing to be invalid at first glance.
For example the following will cause an error:
<!-- prettier-ignore -->.component1 a {}
.component1 a:hover {}
.component2 a {}
This is a correct error because the a:hover
on line 2 has a higher specificity than the a
on line 3.
This may lead to confusion because "the two selectors will never match the same a
in the DOM". However, since the linter does not have access to the DOM it can not evaluate this, and therefore correctly reports the error about descending specificity.
It may be possible to restructure your CSS to remove the error, otherwise it is recommended that you disable the rule for that line and leave a comment saying why the error should be ignored. Note that disabling the rule will cause additional valid errors from being reported.