Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # no-descending-specificity
  2. Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
  3. <!-- prettier-ignore -->
  4. ```css
  5. #container a { top: 10px; } a { top: 0; }
  6. /** ↑ ↑
  7. * The order of these selectors represents descending specificity */
  8. ```
  9. 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.
  10. 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.
  11. 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.
  12. ## How it works
  13. **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.**
  14. 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`.
  15. 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.
  16. 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>`.
  17. This rule only compares rules that are within the same media context. So `a {} @media print { #baz a {} }` is fine.
  18. This rule resolves nested selectors before calculating the specificity of the selectors.
  19. ## DOM Limitations
  20. 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.
  21. This can lead to valid linting errors appearing to be invalid at first glance.
  22. For example the following will cause an error:
  23. <!-- prettier-ignore -->
  24. ```css
  25. .component1 a {}
  26. .component1 a:hover {}
  27. .component2 a {}
  28. ```
  29. This is a correct error because the `a:hover` on line 2 has a higher specificity than the `a` on line 3.
  30. 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.
  31. 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.
  32. ## Options
  33. ### `true`
  34. The following patterns are considered violations:
  35. <!-- prettier-ignore -->
  36. ```css
  37. b a {}
  38. a {}
  39. ```
  40. <!-- prettier-ignore -->
  41. ```css
  42. a + a {}
  43. a {}
  44. ```
  45. <!-- prettier-ignore -->
  46. ```css
  47. b > a[foo] {}
  48. a[foo] {}
  49. ```
  50. <!-- prettier-ignore -->
  51. ```css
  52. a {
  53. & > b {}
  54. }
  55. b {}
  56. ```
  57. <!-- prettier-ignore -->
  58. ```css
  59. @media print {
  60. #c a {}
  61. a {}
  62. }
  63. ```
  64. The following patterns are _not_ considered violations:
  65. <!-- prettier-ignore -->
  66. ```css
  67. a {}
  68. b a {}
  69. ```
  70. <!-- prettier-ignore -->
  71. ```css
  72. a {}
  73. a + a {}
  74. ```
  75. <!-- prettier-ignore -->
  76. ```css
  77. a[foo] {}
  78. b > a[foo] {}
  79. ```
  80. <!-- prettier-ignore -->
  81. ```css
  82. b {}
  83. a {
  84. & > b {}
  85. }
  86. ```
  87. <!-- prettier-ignore -->
  88. ```css
  89. a::before {}
  90. a:hover::before {}
  91. a {}
  92. a:hover {}
  93. ```
  94. <!-- prettier-ignore -->
  95. ```css
  96. @media print {
  97. a {}
  98. #c a {}
  99. }
  100. ```
  101. <!-- prettier-ignore -->
  102. ```css
  103. a {}
  104. @media print {
  105. #baz a {}
  106. }
  107. ```
  108. ### `ignore: ["selectors-within-list"]`
  109. Ignores selectors within list of selectors.
  110. The following patterns are considered violations:
  111. <!-- prettier-ignore -->
  112. ```css
  113. b a {}
  114. h1 {}
  115. h2 {}
  116. h3 {}
  117. a {}
  118. ```
  119. The following patterns are _not_ considered violations:
  120. <!-- prettier-ignore -->
  121. ```css
  122. b a {}
  123. h1, h2, h3, a {}
  124. ```