@codelaw/rules-css 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +23 -0
  2. package/NOTICE +45 -0
  3. package/README.md +181 -2
  4. package/codelaw-pack.toml +6 -0
  5. package/data/css/at-rules.json +97 -0
  6. package/data/css/deprecated.json +178 -0
  7. package/data/css/descriptors.json +121 -0
  8. package/data/css/functions.json +49 -0
  9. package/data/css/keywords.json +332 -0
  10. package/data/css/media.json +271 -0
  11. package/data/css/prefixed.json +266 -0
  12. package/data/css/properties-groups.json +183 -0
  13. package/data/css/properties.json +1326 -0
  14. package/data/css/property-keywords.json +394 -0
  15. package/data/css/selectors.json +281 -0
  16. package/data/css/shorthands.json +351 -0
  17. package/data/css/type-selectors.json +447 -0
  18. package/data/css/units.json +123 -0
  19. package/package.json +14 -4
  20. package/presets/css/conventions.toml +4 -0
  21. package/presets/css/recommended.toml +44 -0
  22. package/presets/css/standard.toml +31 -0
  23. package/rules/css/alpha-value-notation.cases.md +37 -0
  24. package/rules/css/alpha-value-notation.md +44 -0
  25. package/rules/css/annotation-no-unknown.md +44 -0
  26. package/rules/css/at-rule-descriptor-no-unknown.md +46 -0
  27. package/rules/css/at-rule-descriptor-value-no-unknown.md +50 -0
  28. package/rules/css/at-rule-no-deprecated.cases.md +13 -0
  29. package/rules/css/at-rule-no-deprecated.md +47 -0
  30. package/rules/css/at-rule-no-unknown.cases.md +25 -0
  31. package/rules/css/at-rule-no-unknown.md +49 -0
  32. package/rules/css/at-rule-no-vendor-prefix.md +44 -0
  33. package/rules/css/at-rule-prelude-no-invalid.md +52 -0
  34. package/rules/css/block-no-redundant-nested-style-rules.md +40 -0
  35. package/rules/css/color-function-alias-notation.md +42 -0
  36. package/rules/css/color-function-notation.md +42 -0
  37. package/rules/css/color-hex-length.cases.md +13 -0
  38. package/rules/css/color-hex-length.md +41 -0
  39. package/rules/css/comment-no-empty.md +38 -0
  40. package/rules/css/container-name-pattern.md +45 -0
  41. package/rules/css/custom-media-pattern.md +41 -0
  42. package/rules/css/custom-property-no-missing-var-function.cases.md +61 -0
  43. package/rules/css/custom-property-no-missing-var-function.md +46 -0
  44. package/rules/css/custom-property-pattern.md +45 -0
  45. package/rules/css/declaration-block-no-duplicate-custom-properties.md +44 -0
  46. package/rules/css/declaration-block-no-duplicate-properties.cases.md +61 -0
  47. package/rules/css/declaration-block-no-duplicate-properties.md +44 -0
  48. package/rules/css/declaration-block-no-redundant-longhand-properties.md +49 -0
  49. package/rules/css/declaration-block-no-shorthand-property-overrides.md +44 -0
  50. package/rules/css/declaration-property-value-keyword-no-deprecated.md +40 -0
  51. package/rules/css/declaration-property-value-no-unknown.cases.md +16 -0
  52. package/rules/css/declaration-property-value-no-unknown.md +46 -0
  53. package/rules/css/font-family-no-duplicate-names.cases.md +31 -0
  54. package/rules/css/font-family-no-duplicate-names.md +37 -0
  55. package/rules/css/font-family-no-missing-generic-family-keyword.cases.md +62 -0
  56. package/rules/css/font-family-no-missing-generic-family-keyword.md +44 -0
  57. package/rules/css/function-calc-no-unspaced-operator.cases.md +33 -0
  58. package/rules/css/function-calc-no-unspaced-operator.md +42 -0
  59. package/rules/css/hue-degree-notation.md +41 -0
  60. package/rules/css/import-notation.md +37 -0
  61. package/rules/css/keyframe-block-no-duplicate-selectors.md +54 -0
  62. package/rules/css/keyframe-declaration-no-important.md +50 -0
  63. package/rules/css/keyframe-selector-notation.md +61 -0
  64. package/rules/css/keyframes-name-pattern.md +49 -0
  65. package/rules/css/layer-name-pattern.md +41 -0
  66. package/rules/css/length-zero-no-unit.cases.md +41 -0
  67. package/rules/css/length-zero-no-unit.md +39 -0
  68. package/rules/css/lightness-notation.md +41 -0
  69. package/rules/css/media-feature-name-no-unknown.md +48 -0
  70. package/rules/css/media-feature-name-no-vendor-prefix.md +50 -0
  71. package/rules/css/media-feature-name-value-no-unknown.md +46 -0
  72. package/rules/css/media-feature-range-notation.cases.md +61 -0
  73. package/rules/css/media-feature-range-notation.md +45 -0
  74. package/rules/css/media-query-no-invalid.cases.md +60 -0
  75. package/rules/css/media-query-no-invalid.md +48 -0
  76. package/rules/css/media-type-no-deprecated.md +48 -0
  77. package/rules/css/named-grid-areas-no-invalid.md +47 -0
  78. package/rules/css/nesting-selector-no-missing-scoping-root.md +44 -0
  79. package/rules/css/no-descending-specificity.cases.md +69 -0
  80. package/rules/css/no-descending-specificity.md +57 -0
  81. package/rules/css/no-duplicate-at-import-rules.md +35 -0
  82. package/rules/css/no-duplicate-selector.cases.md +67 -0
  83. package/rules/css/no-duplicate-selector.md +48 -0
  84. package/rules/css/no-empty-block.cases.md +42 -0
  85. package/rules/css/no-empty-block.md +42 -0
  86. package/rules/css/no-empty-source.md +40 -0
  87. package/rules/css/no-important.md +43 -0
  88. package/rules/css/no-invalid-double-slash-comments.md +44 -0
  89. package/rules/css/no-invalid-position-at-import-rule.md +48 -0
  90. package/rules/css/no-invalid-position-declaration.cases.md +35 -0
  91. package/rules/css/no-invalid-position-declaration.md +40 -0
  92. package/rules/css/no-irregular-whitespace.md +38 -0
  93. package/rules/css/no-unknown-property.cases.md +53 -0
  94. package/rules/css/no-unknown-property.md +45 -0
  95. package/rules/css/number-max-precision.md +41 -0
  96. package/rules/css/property-no-deprecated.md +40 -0
  97. package/rules/css/property-no-vendor-prefix.md +40 -0
  98. package/rules/css/selector-anb-no-unmatchable.md +42 -0
  99. package/rules/css/selector-class-pattern.md +45 -0
  100. package/rules/css/selector-id-pattern.md +45 -0
  101. package/rules/css/selector-no-vendor-prefix.md +40 -0
  102. package/rules/css/selector-not-notation.md +42 -0
  103. package/rules/css/selector-pseudo-class-no-unknown.cases.md +53 -0
  104. package/rules/css/selector-pseudo-class-no-unknown.md +44 -0
  105. package/rules/css/selector-pseudo-element-colon-notation.cases.md +13 -0
  106. package/rules/css/selector-pseudo-element-colon-notation.md +41 -0
  107. package/rules/css/selector-pseudo-element-no-unknown.md +44 -0
  108. package/rules/css/selector-type-no-unknown.cases.md +41 -0
  109. package/rules/css/selector-type-no-unknown.md +45 -0
  110. package/rules/css/shorthand-property-no-redundant-values.cases.md +34 -0
  111. package/rules/css/shorthand-property-no-redundant-values.md +37 -0
  112. package/rules/css/string-no-newline.cases.md +27 -0
  113. package/rules/css/string-no-newline.md +45 -0
  114. package/rules/css/syntax-string-no-invalid.md +46 -0
  115. package/rules/css/value-no-vendor-prefix.md +40 -0
  116. package/rules/graph/no-unused-css-classes.md +55 -0
@@ -0,0 +1,42 @@
1
+ # Cases: css/no-empty-block
2
+
3
+ ### case: a block holding a comment is not empty
4
+
5
+ ```css
6
+ a {
7
+ /* todo */
8
+ }
9
+ ```
10
+
11
+ ```expect
12
+ (none)
13
+ ```
14
+
15
+ ### case: a named layer block orders the cascade
16
+
17
+ ```css
18
+ @layer base {}
19
+ ```
20
+
21
+ ```expect
22
+ (none)
23
+ ```
24
+
25
+ ### case: an empty block nested in a rule
26
+
27
+ ```css
28
+ a {
29
+ color: red;
30
+ &:hover {}
31
+ }
32
+ ```
33
+
34
+ ```expect
35
+ 3:3 css/no-empty-block
36
+ ```
37
+
38
+ ```fixed
39
+ a {
40
+ color: red;
41
+ }
42
+ ```
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: css/no-empty-block
3
+ title: "No empty blocks"
4
+ languages: [css]
5
+ fix: auto
6
+ stability: preview
7
+ ported_from: [stylelint/block-no-empty]
8
+ since: 0.1.0
9
+ ---
10
+
11
+ No rule or at-rule has an empty block. A block holding only a comment is not empty, and `@layer name {}` is allowed because it fixes the layer's place in the cascade order.
12
+
13
+ **Why:** An empty block does nothing; it is usually left over from an edit or a placeholder that was never filled.
14
+
15
+ ```codelaw
16
+ native: css/no-empty-block
17
+ ```
18
+
19
+ ## Examples
20
+
21
+ ### CSS
22
+
23
+ #### Don't
24
+
25
+ ```css
26
+ .unused {}
27
+ a {
28
+ color: red;
29
+ }
30
+ ```
31
+
32
+ #### Do
33
+
34
+ ```css
35
+ a {
36
+ color: red;
37
+ }
38
+ ```
39
+
40
+ ## Differences from the source
41
+
42
+ `@layer name {}` is not reported: removing it would change the order of cascade layers.
@@ -0,0 +1,40 @@
1
+ ---
2
+ id: css/no-empty-source
3
+ title: "No empty stylesheets"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "whether to delete the file or fill it is the author's call"
7
+ stability: preview
8
+ ported_from: [stylelint/no-empty-source]
9
+ since: 0.1.0
10
+ ---
11
+
12
+ A stylesheet (or `<style>` element) holds something besides whitespace.
13
+
14
+ **Why:** An empty stylesheet is a wasted request or a file left behind.
15
+
16
+ ```codelaw
17
+ native: css/no-empty-source
18
+ ```
19
+
20
+ ## How to fix
21
+
22
+ 1. Delete the file and what links it, or add the styles it was meant to hold.
23
+
24
+ ## Examples
25
+
26
+ ### CSS
27
+
28
+ #### Don't
29
+
30
+ ```css
31
+
32
+ ```
33
+
34
+ #### Do
35
+
36
+ ```css
37
+ a {
38
+ color: red;
39
+ }
40
+ ```
@@ -0,0 +1,43 @@
1
+ ---
2
+ id: css/no-important
3
+ title: "No `!important`"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "the selector or layer that should win instead is a design call"
7
+ stability: preview
8
+ since: 0.1.0
9
+ ---
10
+
11
+ No declaration is marked `!important`.
12
+
13
+ **Why:** `!important` overrides the cascade, and the only way to override it is another `!important`, which escalates.
14
+
15
+ ```codelaw
16
+ native: css/no-important
17
+ ```
18
+
19
+ ## How to fix
20
+
21
+ 1. Find the rule `!important` was overriding.
22
+ 2. Make this rule win by specificity, order or a cascade layer instead.
23
+ 3. Remove `!important`.
24
+
25
+ ## Examples
26
+
27
+ ### CSS
28
+
29
+ #### Don't
30
+
31
+ ```css
32
+ a {
33
+ color: red !important;
34
+ }
35
+ ```
36
+
37
+ #### Do
38
+
39
+ ```css
40
+ a.highlight {
41
+ color: red;
42
+ }
43
+ ```
@@ -0,0 +1,44 @@
1
+ ---
2
+ id: css/no-invalid-double-slash-comments
3
+ title: "No `//` comments"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "turning it into a comment changes what applies"
7
+ stability: preview
8
+ ported_from: [stylelint/no-invalid-double-slash-comments]
9
+ since: 0.1.0
10
+ ---
11
+
12
+ The sheet has no `//` comments: CSS has only `/* … */` comments.
13
+
14
+ **Why:** CSS reads `//` as part of a selector or property, so the rule or declaration after it is dropped.
15
+
16
+ ```codelaw
17
+ native: css/no-invalid-double-slash-comments
18
+ ```
19
+
20
+ ## How to fix
21
+
22
+ 1. Wrap the comment in `/* … */`, or delete it.
23
+
24
+ ## Examples
25
+
26
+ ### CSS
27
+
28
+ #### Don't
29
+
30
+ ```css
31
+ a {
32
+ // color: red;
33
+ top: 0;
34
+ }
35
+ ```
36
+
37
+ #### Do
38
+
39
+ ```css
40
+ a {
41
+ /* color: red; */
42
+ top: 0;
43
+ }
44
+ ```
@@ -0,0 +1,48 @@
1
+ ---
2
+ id: css/no-invalid-position-at-import-rule
3
+ title: "`@import` comes first"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "moving the import makes its rules apply, which changes the page"
7
+ stability: preview
8
+ options:
9
+ ignoreAtRules: { type: "string[]", default: [], description: "at-rules that may come before `@import`" }
10
+ ported_from: [stylelint/no-invalid-position-at-import-rule]
11
+ since: 0.1.0
12
+ ---
13
+
14
+ Every `@import` comes before all other statements except `@charset` and `@layer` statements, and is not nested.
15
+
16
+ **Why:** Browsers ignore an `@import` that comes later, so the stylesheet is never loaded.
17
+
18
+ ```codelaw
19
+ native: css/no-invalid-position-at-import-rule
20
+ ```
21
+
22
+ ## How to fix
23
+
24
+ 1. Move the `@import` to the top of the stylesheet.
25
+
26
+ ## Examples
27
+
28
+ ### CSS
29
+
30
+ #### Don't
31
+
32
+ ```css
33
+ a {
34
+ color: red;
35
+ }
36
+
37
+ @import url("theme.css");
38
+ ```
39
+
40
+ #### Do
41
+
42
+ ```css
43
+ @import url("theme.css");
44
+
45
+ a {
46
+ color: red;
47
+ }
48
+ ```
@@ -0,0 +1,35 @@
1
+ # Cases: css/no-invalid-position-declaration
2
+
3
+ ### case: nested group rules and descriptor at-rules
4
+
5
+ ```css
6
+ a {
7
+ @media print {
8
+ color: black;
9
+ }
10
+ }
11
+
12
+ @font-face {
13
+ font-family: "Inter";
14
+ }
15
+
16
+ @page {
17
+ margin: 1in;
18
+ }
19
+ ```
20
+
21
+ ```expect
22
+ (none)
23
+ ```
24
+
25
+ ### case: directly inside a top-level @media
26
+
27
+ ```css
28
+ @media print {
29
+ color: black;
30
+ }
31
+ ```
32
+
33
+ ```expect
34
+ 2:3 css/no-invalid-position-declaration
35
+ ```
@@ -0,0 +1,40 @@
1
+ ---
2
+ id: css/no-invalid-position-declaration
3
+ title: "Declarations sit inside rules"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "the selector it was meant for is the author's call"
7
+ stability: preview
8
+ ported_from: [stylelint/no-invalid-position-declaration]
9
+ since: 0.1.0
10
+ ---
11
+
12
+ A declaration sits inside a style rule, in an at-rule nested inside one, or in an at-rule that takes descriptors — never at the top level or directly inside a top-level `@media`.
13
+
14
+ **Why:** A declaration with no rule around it applies to nothing; the browser drops it.
15
+
16
+ ```codelaw
17
+ native: css/no-invalid-position-declaration
18
+ ```
19
+
20
+ ## How to fix
21
+
22
+ 1. Move the declaration into the style rule it belongs to.
23
+
24
+ ## Examples
25
+
26
+ ### CSS
27
+
28
+ #### Don't
29
+
30
+ ```css
31
+ color: red;
32
+ ```
33
+
34
+ #### Do
35
+
36
+ ```css
37
+ a {
38
+ color: red;
39
+ }
40
+ ```
@@ -0,0 +1,38 @@
1
+ ---
2
+ id: css/no-irregular-whitespace
3
+ title: "No irregular whitespace"
4
+ languages: [css]
5
+ fix: suggest
6
+ fix_reason: "replacing it changes which elements the selector matches"
7
+ stability: preview
8
+ ported_from: [stylelint/no-irregular-whitespace]
9
+ since: 0.1.0
10
+ ---
11
+
12
+ Outside comments and strings, the sheet uses only ordinary whitespace: no no-break spaces, zero-width spaces or other Unicode spaces.
13
+
14
+ **Why:** An irregular space is part of the name around it, so `.menu .item` is one class name and the selector matches nothing.
15
+
16
+ ```codelaw
17
+ native: css/no-irregular-whitespace
18
+ ```
19
+
20
+ ## Examples
21
+
22
+ ### CSS
23
+
24
+ #### Don't
25
+
26
+ ```css
27
+ .menu .item {
28
+ color: red;
29
+ }
30
+ ```
31
+
32
+ #### Do
33
+
34
+ ```css
35
+ .menu .item {
36
+ color: red;
37
+ }
38
+ ```
@@ -0,0 +1,53 @@
1
+ # Cases: css/no-unknown-property
2
+
3
+ ### case: descriptors inside @font-face are not properties
4
+
5
+ ```css
6
+ @font-face {
7
+ font-family: "Inter";
8
+ font-display: swap;
9
+ unicode-range: U+0000-00FF;
10
+ }
11
+ ```
12
+
13
+ ```expect
14
+ (none)
15
+ ```
16
+
17
+ ### case: vendor-prefixed and custom properties are skipped
18
+
19
+ ```css
20
+ a {
21
+ -webkit-tap-highlight-color: transparent;
22
+ --brand-colr: red;
23
+ }
24
+ ```
25
+
26
+ ```expect
27
+ (none)
28
+ ```
29
+
30
+ ### case: old IE hacks are skipped
31
+
32
+ ```css
33
+ a {
34
+ *zoom: 1;
35
+ _height: 1px;
36
+ }
37
+ ```
38
+
39
+ ```expect
40
+ (none)
41
+ ```
42
+
43
+ ### case: no close known name, no fix
44
+
45
+ ```css
46
+ a {
47
+ wibble: 1;
48
+ }
49
+ ```
50
+
51
+ ```expect
52
+ 2:3 css/no-unknown-property
53
+ ```
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: css/no-unknown-property
3
+ title: "No unknown properties"
4
+ languages: [css]
5
+ fix: suggest
6
+ fix_reason: "the closest known name is a guess at what was meant"
7
+ stability: preview
8
+ options:
9
+ ignoreProperties: { type: "string[]", default: [], description: "properties to accept; `/regex/` for a pattern" }
10
+ checkPrefixed: { type: "boolean", default: false, description: "also check vendor-prefixed properties" }
11
+ ported_from: [stylelint/property-no-unknown]
12
+ since: 0.1.0
13
+ ---
14
+
15
+ Every property is a known CSS property. Custom properties, vendor-prefixed properties and descriptors inside at-rules such as `@font-face` are skipped.
16
+
17
+ **Why:** The browser drops a declaration whose property it does not know, so a typo silently loses the style.
18
+
19
+ ```codelaw
20
+ native: css/no-unknown-property
21
+ ```
22
+
23
+ ## Examples
24
+
25
+ ### CSS
26
+
27
+ #### Don't
28
+
29
+ ```css
30
+ a {
31
+ colr: red;
32
+ }
33
+ ```
34
+
35
+ #### Do
36
+
37
+ ```css
38
+ a {
39
+ color: red;
40
+ }
41
+ ```
42
+
43
+ ## Differences from the source
44
+
45
+ The property table is `known-css-properties` plus the names stylelint keeps from before it moved to CSSTree, not CSSTree's MDN-derived data. A fix is offered when a known property is one or two edits away.
@@ -0,0 +1,41 @@
1
+ ---
2
+ id: css/number-max-precision
3
+ title: "At most four decimal places"
4
+ languages: [css]
5
+ fix: suggest
6
+ fix_reason: "rounding changes the value slightly"
7
+ stability: preview
8
+ options:
9
+ precision: { type: "integer", default: 4, description: "the most decimal places allowed" }
10
+ ignoreUnits: { type: "string[]", default: [], description: "units whose numbers are not checked" }
11
+ ported_from: [stylelint/number-max-precision]
12
+ since: 0.1.0
13
+ ---
14
+
15
+ Numbers have at most four decimal places.
16
+
17
+ **Why:** Extra precision is noise no screen can render.
18
+
19
+ ```codelaw
20
+ native: css/number-max-precision
21
+ ```
22
+
23
+ ## Examples
24
+
25
+ ### CSS
26
+
27
+ #### Don't
28
+
29
+ ```css
30
+ a {
31
+ line-height: 1.333333;
32
+ }
33
+ ```
34
+
35
+ #### Do
36
+
37
+ ```css
38
+ a {
39
+ line-height: 1.3333;
40
+ }
41
+ ```
@@ -0,0 +1,40 @@
1
+ ---
2
+ id: css/property-no-deprecated
3
+ title: "No deprecated properties"
4
+ languages: [css]
5
+ fix: suggest
6
+ fix_reason: "older browsers may support only the deprecated name"
7
+ stability: preview
8
+ options:
9
+ ignoreProperties: { type: "string[]", default: [], description: "properties to accept; `/regex/` for a pattern" }
10
+ ported_from: [stylelint/property-no-deprecated]
11
+ since: 0.1.0
12
+ ---
13
+
14
+ The sheet uses no property the specifications deprecated, such as `word-wrap`, `grid-gap`, `page-break-*` or `clip`.
15
+
16
+ **Why:** Deprecated properties are kept only as aliases or not at all, and may stop working.
17
+
18
+ ```codelaw
19
+ native: css/property-no-deprecated
20
+ ```
21
+
22
+ ## Examples
23
+
24
+ ### CSS
25
+
26
+ #### Don't
27
+
28
+ ```css
29
+ a {
30
+ word-wrap: break-word;
31
+ }
32
+ ```
33
+
34
+ #### Do
35
+
36
+ ```css
37
+ a {
38
+ overflow-wrap: break-word;
39
+ }
40
+ ```
@@ -0,0 +1,40 @@
1
+ ---
2
+ id: css/property-no-vendor-prefix
3
+ title: "No vendor-prefixed properties"
4
+ languages: [css]
5
+ fix: suggest
6
+ fix_reason: "browsers that need the prefix lose the declaration"
7
+ stability: preview
8
+ options:
9
+ ignoreProperties: { type: "string[]", default: [], description: "properties to accept; `/regex/` for a pattern" }
10
+ ported_from: [stylelint/property-no-vendor-prefix]
11
+ since: 0.1.0
12
+ ---
13
+
14
+ Properties a build tool prefixes, such as `-webkit-transform`, are written without the prefix.
15
+
16
+ **Why:** Prefixing is a build step; hand-written prefixes go stale and duplicate code.
17
+
18
+ ```codelaw
19
+ native: css/property-no-vendor-prefix
20
+ ```
21
+
22
+ ## Examples
23
+
24
+ ### CSS
25
+
26
+ #### Don't
27
+
28
+ ```css
29
+ a {
30
+ -webkit-transform: scale(2);
31
+ }
32
+ ```
33
+
34
+ #### Do
35
+
36
+ ```css
37
+ a {
38
+ transform: scale(2);
39
+ }
40
+ ```
@@ -0,0 +1,42 @@
1
+ ---
2
+ id: css/selector-anb-no-unmatchable
3
+ title: "No An+B selector that matches nothing"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "the intended position is the author's call"
7
+ stability: preview
8
+ ported_from: [stylelint/selector-anb-no-unmatchable]
9
+ since: 0.1.0
10
+ ---
11
+
12
+ `:nth-child()`, `:nth-of-type()` and their `last` forms are not given an argument that is always zero, such as `0`, `0n` or `0n+0`.
13
+
14
+ **Why:** Positions start at 1, so these selectors never match.
15
+
16
+ ```codelaw
17
+ native: css/selector-anb-no-unmatchable
18
+ ```
19
+
20
+ ## How to fix
21
+
22
+ 1. Use the position that was meant; the first element is `1`.
23
+
24
+ ## Examples
25
+
26
+ ### CSS
27
+
28
+ #### Don't
29
+
30
+ ```css
31
+ li:nth-child(0) {
32
+ color: red;
33
+ }
34
+ ```
35
+
36
+ #### Do
37
+
38
+ ```css
39
+ li:nth-child(1) {
40
+ color: red;
41
+ }
42
+ ```
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: css/selector-class-pattern
3
+ title: "Class selectors are kebab-case"
4
+ languages: [css]
5
+ fix: manual
6
+ fix_reason: "renaming must update the markup and scripts that use the class"
7
+ stability: preview
8
+ options:
9
+ pattern: { type: "string", default: "^([a-z][a-z0-9]*)(-[a-z0-9]+)*$", description: "a regular expression names must match" }
10
+ ported_from: [stylelint/selector-class-pattern]
11
+ since: 0.1.0
12
+ ---
13
+
14
+ Class names in selectors match a pattern, kebab-case by default.
15
+
16
+ **Why:** A consistent naming scheme makes names predictable across a codebase.
17
+
18
+ ```codelaw
19
+ native: css/selector-class-pattern
20
+ ```
21
+
22
+ ## How to fix
23
+
24
+ 1. Rename the class to match the pattern.
25
+ 2. Update the markup and scripts that use it.
26
+
27
+ ## Examples
28
+
29
+ ### CSS
30
+
31
+ #### Don't
32
+
33
+ ```css
34
+ .navBar {
35
+ color: red;
36
+ }
37
+ ```
38
+
39
+ #### Do
40
+
41
+ ```css
42
+ .nav-bar {
43
+ color: red;
44
+ }
45
+ ```