@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.
- package/LICENSE +23 -0
- package/NOTICE +45 -0
- package/README.md +181 -2
- package/codelaw-pack.toml +6 -0
- package/data/css/at-rules.json +97 -0
- package/data/css/deprecated.json +178 -0
- package/data/css/descriptors.json +121 -0
- package/data/css/functions.json +49 -0
- package/data/css/keywords.json +332 -0
- package/data/css/media.json +271 -0
- package/data/css/prefixed.json +266 -0
- package/data/css/properties-groups.json +183 -0
- package/data/css/properties.json +1326 -0
- package/data/css/property-keywords.json +394 -0
- package/data/css/selectors.json +281 -0
- package/data/css/shorthands.json +351 -0
- package/data/css/type-selectors.json +447 -0
- package/data/css/units.json +123 -0
- package/package.json +14 -4
- package/presets/css/conventions.toml +4 -0
- package/presets/css/recommended.toml +44 -0
- package/presets/css/standard.toml +31 -0
- package/rules/css/alpha-value-notation.cases.md +37 -0
- package/rules/css/alpha-value-notation.md +44 -0
- package/rules/css/annotation-no-unknown.md +44 -0
- package/rules/css/at-rule-descriptor-no-unknown.md +46 -0
- package/rules/css/at-rule-descriptor-value-no-unknown.md +50 -0
- package/rules/css/at-rule-no-deprecated.cases.md +13 -0
- package/rules/css/at-rule-no-deprecated.md +47 -0
- package/rules/css/at-rule-no-unknown.cases.md +25 -0
- package/rules/css/at-rule-no-unknown.md +49 -0
- package/rules/css/at-rule-no-vendor-prefix.md +44 -0
- package/rules/css/at-rule-prelude-no-invalid.md +52 -0
- package/rules/css/block-no-redundant-nested-style-rules.md +40 -0
- package/rules/css/color-function-alias-notation.md +42 -0
- package/rules/css/color-function-notation.md +42 -0
- package/rules/css/color-hex-length.cases.md +13 -0
- package/rules/css/color-hex-length.md +41 -0
- package/rules/css/comment-no-empty.md +38 -0
- package/rules/css/container-name-pattern.md +45 -0
- package/rules/css/custom-media-pattern.md +41 -0
- package/rules/css/custom-property-no-missing-var-function.cases.md +61 -0
- package/rules/css/custom-property-no-missing-var-function.md +46 -0
- package/rules/css/custom-property-pattern.md +45 -0
- package/rules/css/declaration-block-no-duplicate-custom-properties.md +44 -0
- package/rules/css/declaration-block-no-duplicate-properties.cases.md +61 -0
- package/rules/css/declaration-block-no-duplicate-properties.md +44 -0
- package/rules/css/declaration-block-no-redundant-longhand-properties.md +49 -0
- package/rules/css/declaration-block-no-shorthand-property-overrides.md +44 -0
- package/rules/css/declaration-property-value-keyword-no-deprecated.md +40 -0
- package/rules/css/declaration-property-value-no-unknown.cases.md +16 -0
- package/rules/css/declaration-property-value-no-unknown.md +46 -0
- package/rules/css/font-family-no-duplicate-names.cases.md +31 -0
- package/rules/css/font-family-no-duplicate-names.md +37 -0
- package/rules/css/font-family-no-missing-generic-family-keyword.cases.md +62 -0
- package/rules/css/font-family-no-missing-generic-family-keyword.md +44 -0
- package/rules/css/function-calc-no-unspaced-operator.cases.md +33 -0
- package/rules/css/function-calc-no-unspaced-operator.md +42 -0
- package/rules/css/hue-degree-notation.md +41 -0
- package/rules/css/import-notation.md +37 -0
- package/rules/css/keyframe-block-no-duplicate-selectors.md +54 -0
- package/rules/css/keyframe-declaration-no-important.md +50 -0
- package/rules/css/keyframe-selector-notation.md +61 -0
- package/rules/css/keyframes-name-pattern.md +49 -0
- package/rules/css/layer-name-pattern.md +41 -0
- package/rules/css/length-zero-no-unit.cases.md +41 -0
- package/rules/css/length-zero-no-unit.md +39 -0
- package/rules/css/lightness-notation.md +41 -0
- package/rules/css/media-feature-name-no-unknown.md +48 -0
- package/rules/css/media-feature-name-no-vendor-prefix.md +50 -0
- package/rules/css/media-feature-name-value-no-unknown.md +46 -0
- package/rules/css/media-feature-range-notation.cases.md +61 -0
- package/rules/css/media-feature-range-notation.md +45 -0
- package/rules/css/media-query-no-invalid.cases.md +60 -0
- package/rules/css/media-query-no-invalid.md +48 -0
- package/rules/css/media-type-no-deprecated.md +48 -0
- package/rules/css/named-grid-areas-no-invalid.md +47 -0
- package/rules/css/nesting-selector-no-missing-scoping-root.md +44 -0
- package/rules/css/no-descending-specificity.cases.md +69 -0
- package/rules/css/no-descending-specificity.md +57 -0
- package/rules/css/no-duplicate-at-import-rules.md +35 -0
- package/rules/css/no-duplicate-selector.cases.md +67 -0
- package/rules/css/no-duplicate-selector.md +48 -0
- package/rules/css/no-empty-block.cases.md +42 -0
- package/rules/css/no-empty-block.md +42 -0
- package/rules/css/no-empty-source.md +40 -0
- package/rules/css/no-important.md +43 -0
- package/rules/css/no-invalid-double-slash-comments.md +44 -0
- package/rules/css/no-invalid-position-at-import-rule.md +48 -0
- package/rules/css/no-invalid-position-declaration.cases.md +35 -0
- package/rules/css/no-invalid-position-declaration.md +40 -0
- package/rules/css/no-irregular-whitespace.md +38 -0
- package/rules/css/no-unknown-property.cases.md +53 -0
- package/rules/css/no-unknown-property.md +45 -0
- package/rules/css/number-max-precision.md +41 -0
- package/rules/css/property-no-deprecated.md +40 -0
- package/rules/css/property-no-vendor-prefix.md +40 -0
- package/rules/css/selector-anb-no-unmatchable.md +42 -0
- package/rules/css/selector-class-pattern.md +45 -0
- package/rules/css/selector-id-pattern.md +45 -0
- package/rules/css/selector-no-vendor-prefix.md +40 -0
- package/rules/css/selector-not-notation.md +42 -0
- package/rules/css/selector-pseudo-class-no-unknown.cases.md +53 -0
- package/rules/css/selector-pseudo-class-no-unknown.md +44 -0
- package/rules/css/selector-pseudo-element-colon-notation.cases.md +13 -0
- package/rules/css/selector-pseudo-element-colon-notation.md +41 -0
- package/rules/css/selector-pseudo-element-no-unknown.md +44 -0
- package/rules/css/selector-type-no-unknown.cases.md +41 -0
- package/rules/css/selector-type-no-unknown.md +45 -0
- package/rules/css/shorthand-property-no-redundant-values.cases.md +34 -0
- package/rules/css/shorthand-property-no-redundant-values.md +37 -0
- package/rules/css/string-no-newline.cases.md +27 -0
- package/rules/css/string-no-newline.md +45 -0
- package/rules/css/syntax-string-no-invalid.md +46 -0
- package/rules/css/value-no-vendor-prefix.md +40 -0
- package/rules/graph/no-unused-css-classes.md +55 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/font-family-no-missing-generic-family-keyword
|
|
3
|
+
title: "Font lists end with a generic family"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "which generic family suits the fonts is a design call"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreFontFamilies: { type: "string[]", default: [], description: "families that need no generic fallback, such as icon fonts" }
|
|
10
|
+
ported_from: [stylelint/font-family-no-missing-generic-family-keyword]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
A `font-family` list (or the family part of `font`) includes a generic family such as `sans-serif`, `serif` or `monospace`. `@font-face`, values using `var()` and system fonts (`font: caption`) are skipped.
|
|
15
|
+
|
|
16
|
+
**Why:** When none of the named fonts is available the browser falls back to its default font, which may look nothing like the design.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/font-family-no-missing-generic-family-keyword
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Add the generic family closest to the listed fonts at the end of the list.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### CSS
|
|
29
|
+
|
|
30
|
+
#### Don't
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
a {
|
|
34
|
+
font-family: Helvetica, Arial;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Do
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
a {
|
|
42
|
+
font-family: Helvetica, Arial, sans-serif;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Cases: css/function-calc-no-unspaced-operator
|
|
2
|
+
|
|
3
|
+
### case: signs, names and exponents
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
a {
|
|
7
|
+
width: calc(1px - -2px);
|
|
8
|
+
height: calc(var(--a-b) * 2);
|
|
9
|
+
top: calc(1e-3px + 1px);
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```expect
|
|
14
|
+
(none)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### case: a sign after a value reads as a second value
|
|
18
|
+
|
|
19
|
+
```css
|
|
20
|
+
a {
|
|
21
|
+
width: calc(100% -10px);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```expect
|
|
26
|
+
2:20 css/function-calc-no-unspaced-operator
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```fixed
|
|
30
|
+
a {
|
|
31
|
+
width: calc(100% - 10px);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/function-calc-no-unspaced-operator
|
|
3
|
+
title: "Spaces around `+` and `-` in math functions"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "the fix makes an invalid, dropped declaration apply, which changes the page"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/function-calc-no-unspaced-operator]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Inside `calc()` and the other math functions, `+` and `-` have whitespace on both sides.
|
|
13
|
+
|
|
14
|
+
**Why:** Without the spaces `-10px` reads as a negative number and `100%-10px` as one token, so the expression is invalid and the declaration is dropped.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/function-calc-no-unspaced-operator
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### CSS
|
|
23
|
+
|
|
24
|
+
#### Don't
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
a {
|
|
28
|
+
width: calc(100%-10px);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Do
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
a {
|
|
36
|
+
width: calc(100% - 10px);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Differences from the source
|
|
41
|
+
|
|
42
|
+
Whitespace other than a single space around an operator is left to the formatter.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/hue-degree-notation
|
|
3
|
+
title: "Hues are angles"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/hue-degree-notation]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
The hue of `hsl()`, `hwb()`, `lch()` and `oklch()` is written as an angle (`120deg`), not a bare number.
|
|
12
|
+
|
|
13
|
+
**Why:** An explicit unit makes the value's meaning plain.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/hue-degree-notation
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
a {
|
|
27
|
+
color: hsl(120 60% 50%);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Do
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
a {
|
|
35
|
+
color: hsl(120deg 60% 50%);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Differences from the source
|
|
40
|
+
|
|
41
|
+
Ported with stylelint-config-standard's setting, `angle`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/import-notation
|
|
3
|
+
title: "`@import` with `url()`"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/import-notation]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`@import` names its stylesheet with `url()`, not a bare string.
|
|
12
|
+
|
|
13
|
+
**Why:** One notation for imports is easier to search and read.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/import-notation
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
@import "theme.css";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Do
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
@import url("theme.css");
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Differences from the source
|
|
36
|
+
|
|
37
|
+
Ported with stylelint-config-standard's setting, `url`.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/keyframe-block-no-duplicate-selectors
|
|
3
|
+
title: "No keyframe selector twice in one `@keyframes`"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "which keyframe was meant can't be known from the code"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/keyframe-block-no-duplicate-selectors]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
A `@keyframes` block names each keyframe selector once.
|
|
13
|
+
|
|
14
|
+
**Why:** Two blocks for one keyframe merge silently, which is usually a copy-paste slip.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/keyframe-block-no-duplicate-selectors
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How to fix
|
|
21
|
+
|
|
22
|
+
1. Merge the two blocks, or change one selector to the keyframe it was meant for.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
### CSS
|
|
27
|
+
|
|
28
|
+
#### Don't
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@keyframes fade {
|
|
32
|
+
0% {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
0% {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Do
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
@keyframes fade {
|
|
46
|
+
0% {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
100% {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/keyframe-declaration-no-important
|
|
3
|
+
title: "No `!important` in keyframes"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "removing `!important` makes an ignored declaration apply, which changes the animation"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/keyframe-declaration-no-important]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
No declaration inside a `@keyframes` block is marked `!important`.
|
|
13
|
+
|
|
14
|
+
**Why:** Browsers ignore a keyframe declaration marked `!important`, so the property is not animated.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/keyframe-declaration-no-important
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### CSS
|
|
23
|
+
|
|
24
|
+
#### Don't
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
@keyframes fade {
|
|
28
|
+
from {
|
|
29
|
+
opacity: 0 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
to {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Do
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
@keyframes fade {
|
|
42
|
+
from {
|
|
43
|
+
opacity: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
to {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/keyframe-selector-notation
|
|
3
|
+
title: "Percentages for keyframe selectors"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/keyframe-selector-notation]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Keyframe selectors are percentages (`0%`, `100%`) unless every selector of the `@keyframes` is a keyword (`from`, `to`).
|
|
12
|
+
|
|
13
|
+
**Why:** Mixing `from` with `50%` makes the timeline harder to read.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/keyframe-selector-notation
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
@keyframes fade {
|
|
27
|
+
from {
|
|
28
|
+
opacity: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
50% {
|
|
32
|
+
opacity: 0.5;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
to {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Do
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
@keyframes fade {
|
|
45
|
+
0% {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
50% {
|
|
50
|
+
opacity: 0.5;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
100% {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Differences from the source
|
|
60
|
+
|
|
61
|
+
Ported with stylelint-config-standard's setting, `percentage-unless-within-keyword-only-block`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/keyframes-name-pattern
|
|
3
|
+
title: "Keyframes names are kebab-case"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "renaming must update every `animation` that uses the name"
|
|
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/keyframes-name-pattern]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
The name of each `@keyframes` matches 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/keyframes-name-pattern
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Rename the keyframes to match the pattern.
|
|
25
|
+
2. Update every `animation` and `animation-name` that uses it.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### CSS
|
|
30
|
+
|
|
31
|
+
#### Don't
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@keyframes fadeIn {
|
|
35
|
+
from {
|
|
36
|
+
opacity: 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Do
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
@keyframes fade-in {
|
|
45
|
+
from {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/layer-name-pattern
|
|
3
|
+
title: "Layer names are kebab-case"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "renaming must update every use of the layer"
|
|
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/layer-name-pattern]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Cascade layer names, in `@layer` and in `@import … layer()`, match a pattern: kebab-case segments joined by dots, by default.
|
|
15
|
+
|
|
16
|
+
**Why:** A consistent naming scheme makes names predictable across a codebase.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/layer-name-pattern
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Rename the layer to match the pattern.
|
|
25
|
+
2. Update every `@layer` and `@import` that names it.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### CSS
|
|
30
|
+
|
|
31
|
+
#### Don't
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@layer baseStyles;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Do
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
@layer base-styles;
|
|
41
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Cases: css/length-zero-no-unit
|
|
2
|
+
|
|
3
|
+
### case: where the unit matters
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
a {
|
|
7
|
+
--gap: 0px;
|
|
8
|
+
line-height: 0px;
|
|
9
|
+
flex: 1 1 0px;
|
|
10
|
+
width: calc(0px + 1em);
|
|
11
|
+
font: 12px/0px serif;
|
|
12
|
+
grid-template-columns: 0fr;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```expect
|
|
17
|
+
(none)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### case: zero lengths in a media query
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
@media (min-width: 0px) {
|
|
24
|
+
a {
|
|
25
|
+
margin: 0em;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```expect
|
|
31
|
+
1:20 css/length-zero-no-unit
|
|
32
|
+
3:13 css/length-zero-no-unit
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```fixed
|
|
36
|
+
@media (min-width: 0) {
|
|
37
|
+
a {
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/length-zero-no-unit
|
|
3
|
+
title: "No units on zero lengths"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
options:
|
|
8
|
+
ignore: { type: "string[]", default: ["custom-properties"], description: "`custom-properties` skips custom property values" }
|
|
9
|
+
ported_from: [stylelint/length-zero-no-unit]
|
|
10
|
+
since: 0.1.0
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
A zero length is written `0`, without a unit. Custom properties, `line-height`, `flex`, the line height in `font`, math functions and `fr` are skipped, as a unit matters there.
|
|
14
|
+
|
|
15
|
+
**Why:** `0px`, `0em` and `0` are the same length; the unit is noise.
|
|
16
|
+
|
|
17
|
+
```codelaw
|
|
18
|
+
native: css/length-zero-no-unit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
### CSS
|
|
24
|
+
|
|
25
|
+
#### Don't
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
a {
|
|
29
|
+
margin: 0px;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### Do
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
a {
|
|
37
|
+
margin: 0;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/lightness-notation
|
|
3
|
+
title: "Lightness is a percentage"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/lightness-notation]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
The lightness of `lab()`, `lch()`, `oklab()` and `oklch()` is written as a percentage.
|
|
12
|
+
|
|
13
|
+
**Why:** The functions use different number scales for lightness (0–1 and 0–100); a percentage reads the same in all of them.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/lightness-notation
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
a {
|
|
27
|
+
color: oklch(0.7 0.1 200deg);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Do
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
a {
|
|
35
|
+
color: oklch(70% 0.1 200deg);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Differences from the source
|
|
40
|
+
|
|
41
|
+
Ported with stylelint-config-standard's setting, `percentage`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/media-feature-name-no-unknown
|
|
3
|
+
title: "No unknown media features"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the intended feature is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreMediaFeatureNames: { type: "string[]", default: [], description: "features to accept; `/regex/` for a pattern" }
|
|
10
|
+
ported_from: [stylelint/media-feature-name-no-unknown]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Every media feature in `@media` and `@custom-media` is one the Media Queries specifications define. Vendor-prefixed features and custom media (`(--name)`) are skipped.
|
|
15
|
+
|
|
16
|
+
**Why:** A media feature the browser does not know never matches, so the block never applies.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/media-feature-name-no-unknown
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Correct the feature name.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### CSS
|
|
29
|
+
|
|
30
|
+
#### Don't
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
@media (min-widht: 600px) {
|
|
34
|
+
a {
|
|
35
|
+
color: red;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Do
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
@media (min-width: 600px) {
|
|
44
|
+
a {
|
|
45
|
+
color: red;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/media-feature-name-no-vendor-prefix
|
|
3
|
+
title: "No vendor-prefixed media features"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the value needs converting to a `dppx` resolution"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/media-feature-name-no-vendor-prefix]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Media queries use no vendor-prefixed `device-pixel-ratio` feature.
|
|
13
|
+
|
|
14
|
+
**Why:** The standard `resolution` feature covers it in every current browser.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/media-feature-name-no-vendor-prefix
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How to fix
|
|
21
|
+
|
|
22
|
+
1. Replace the feature with `min-resolution`, `max-resolution` or `resolution`, and its value `n` with `ndppx`.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
### CSS
|
|
27
|
+
|
|
28
|
+
#### Don't
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@media (-webkit-min-device-pixel-ratio: 2) {
|
|
32
|
+
a {
|
|
33
|
+
color: red;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Do
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
@media (min-resolution: 2dppx) {
|
|
42
|
+
a {
|
|
43
|
+
color: red;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Differences from the source
|
|
49
|
+
|
|
50
|
+
Reported without a fix: stylelint only drops the prefix, which leaves a non-standard feature.
|