@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/alpha-value-notation
|
|
3
|
+
title: "Alpha values are percentages"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "old browsers accept only numbers for alpha in `rgba()`"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
exceptProperties: { type: "string[]", default: ["opacity", "fill-opacity", "flood-opacity", "stop-opacity", "stroke-opacity"], description: "properties whose alpha is a number" }
|
|
10
|
+
ported_from: [stylelint/alpha-value-notation]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
The alpha channel of a colour function is written as a percentage (`50%`, not `0.5`). The opacity properties (`opacity`, `fill-opacity`, `flood-opacity`, `stop-opacity`, `stroke-opacity`) take numbers instead.
|
|
15
|
+
|
|
16
|
+
**Why:** One notation for alpha makes values easier to compare at a glance.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/alpha-value-notation
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### CSS
|
|
25
|
+
|
|
26
|
+
#### Don't
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
a {
|
|
30
|
+
color: rgb(0 0 0 / 0.5);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### Do
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
a {
|
|
38
|
+
color: rgb(0 0 0 / 50%);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Differences from the source
|
|
43
|
+
|
|
44
|
+
Ported with stylelint-config-standard's setting, `percentage`; the `number` setting is not offered.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/annotation-no-unknown
|
|
3
|
+
title: "No unknown `!` annotations"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the intended annotation is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreAnnotations: { type: "string[]", default: [], description: "annotations to accept; `/regex/` for a pattern" }
|
|
10
|
+
ported_from: [stylelint/annotation-no-unknown]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
A declaration ends in no `!` annotation other than `!important`.
|
|
15
|
+
|
|
16
|
+
**Why:** A misspelt annotation such as `!imprtant` makes the browser drop the whole declaration.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/annotation-no-unknown
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Correct the spelling to `!important`, or remove the annotation.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### CSS
|
|
29
|
+
|
|
30
|
+
#### Don't
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
a {
|
|
34
|
+
color: green !imprtant;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Do
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
a {
|
|
42
|
+
color: green !important;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-descriptor-no-unknown
|
|
3
|
+
title: "No unknown descriptors inside at-rules"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "whether to remove or move the declaration is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/at-rule-descriptor-no-unknown]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Inside `@font-face`, `@counter-style`, `@property`, `@font-palette-values`, `@page`, `@view-transition`, `@color-profile` and `@font-feature-values`, every declaration is a descriptor that at-rule defines.
|
|
13
|
+
|
|
14
|
+
**Why:** An at-rule ignores descriptors it does not define, so a misplaced property silently does nothing.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/at-rule-descriptor-no-unknown
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How to fix
|
|
21
|
+
|
|
22
|
+
1. Check the descriptor name against the at-rule's specification.
|
|
23
|
+
2. Fix its spelling, or move the declaration into a style rule where it applies.
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### CSS
|
|
28
|
+
|
|
29
|
+
#### Don't
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
@font-face {
|
|
33
|
+
font-family: "Inter";
|
|
34
|
+
src: url("inter.woff2");
|
|
35
|
+
color: red;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Do
|
|
40
|
+
|
|
41
|
+
```css
|
|
42
|
+
@font-face {
|
|
43
|
+
font-family: "Inter";
|
|
44
|
+
src: url("inter.woff2");
|
|
45
|
+
}
|
|
46
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-descriptor-value-no-unknown
|
|
3
|
+
title: "No unknown keyword values for at-rule descriptors"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the intended value is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/at-rule-descriptor-value-no-unknown]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Descriptors that take a fixed set of keywords — `font-display`, `system`, `inherits`, `navigation` and the like — use one of them, and the `syntax` of `@property` is a string.
|
|
13
|
+
|
|
14
|
+
**Why:** The browser drops a descriptor with a value it does not recognise, so the at-rule falls back to its default.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/at-rule-descriptor-value-no-unknown
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How to fix
|
|
21
|
+
|
|
22
|
+
1. Replace the value with one the descriptor accepts.
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
### CSS
|
|
27
|
+
|
|
28
|
+
#### Don't
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@font-face {
|
|
32
|
+
font-family: "Inter";
|
|
33
|
+
src: url("inter.woff2");
|
|
34
|
+
font-display: quick;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Do
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: "Inter";
|
|
43
|
+
src: url("inter.woff2");
|
|
44
|
+
font-display: swap;
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Differences from the source
|
|
49
|
+
|
|
50
|
+
Checks keyword-valued descriptors and the `@property` `syntax` type only; stylelint validates every descriptor value against the full CSSTree grammar, whose data derives from MDN data (CC0), which codelaw does not ship.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-no-deprecated
|
|
3
|
+
title: "No deprecated at-rules"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
options:
|
|
8
|
+
ignoreAtRules: { type: "string[]", default: [], description: "at-rules to accept; `/regex/` for a pattern" }
|
|
9
|
+
ported_from: [stylelint/at-rule-no-deprecated]
|
|
10
|
+
since: 0.1.0
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
The sheet uses no at-rule that was removed from or deprecated by the CSS specifications: `@viewport`, `@document` and `@nest`.
|
|
14
|
+
|
|
15
|
+
**Why:** Browsers dropped or never shipped these at-rules, so what they wrap does not apply.
|
|
16
|
+
|
|
17
|
+
```codelaw
|
|
18
|
+
native: css/at-rule-no-deprecated
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
### CSS
|
|
24
|
+
|
|
25
|
+
#### Don't
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
.card {
|
|
29
|
+
@nest .theme-dark & {
|
|
30
|
+
color: white;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Do
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
.card {
|
|
39
|
+
.theme-dark & {
|
|
40
|
+
color: white;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Differences from the source
|
|
46
|
+
|
|
47
|
+
Only `@nest` has a fix (drop the keyword); `@viewport` and `@document` are reported without one.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Cases: css/at-rule-no-unknown
|
|
2
|
+
|
|
3
|
+
### case: @charset is not an at-rule here
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
@charset "utf-8";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```expect
|
|
10
|
+
(none)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### case: vendor-prefixed known at-rules
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
@-webkit-keyframes fade {
|
|
17
|
+
from {
|
|
18
|
+
opacity: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```expect
|
|
24
|
+
(none)
|
|
25
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-no-unknown
|
|
3
|
+
title: "No unknown at-rules"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the intended at-rule is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreAtRules: { type: "string[]", default: [], description: "at-rules to accept, such as a preprocessor's; `/regex/` for a pattern" }
|
|
10
|
+
ported_from: [stylelint/at-rule-no-unknown]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Every at-rule is one the CSS specifications define (a vendor prefix is allowed).
|
|
15
|
+
|
|
16
|
+
**Why:** A browser skips an at-rule it does not know, block and all, so a typo silently disables its contents.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/at-rule-no-unknown
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Correct the at-rule name.
|
|
25
|
+
2. If a build tool handles it (`@tailwind`, `@include`), add it to `ignoreAtRules`.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### CSS
|
|
30
|
+
|
|
31
|
+
#### Don't
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@keyframe fade {
|
|
35
|
+
from {
|
|
36
|
+
opacity: 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Do
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
@keyframes fade {
|
|
45
|
+
from {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-no-vendor-prefix
|
|
3
|
+
title: "No vendor-prefixed at-rules"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "browsers that need the prefix lose the rule"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreAtRules: { type: "string[]", default: [], description: "at-rules to accept; `/regex/` for a pattern" }
|
|
10
|
+
ported_from: [stylelint/at-rule-no-vendor-prefix]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
At-rules a build tool prefixes, such as `@-webkit-keyframes`, 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/at-rule-no-vendor-prefix
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### CSS
|
|
25
|
+
|
|
26
|
+
#### Don't
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
@-webkit-keyframes fade {
|
|
30
|
+
from {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Do
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
@keyframes fade {
|
|
40
|
+
from {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/at-rule-prelude-no-invalid
|
|
3
|
+
title: "At-rule preludes follow their grammar"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "the intended prelude is the author's call"
|
|
7
|
+
stability: preview
|
|
8
|
+
options:
|
|
9
|
+
ignoreAtRules: { type: "string[]", default: ["media"], description: "at-rules not to check; `@media` is left to `css/media-query-no-invalid`" }
|
|
10
|
+
ported_from: [stylelint/at-rule-prelude-no-invalid]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
The prelude of an at-rule — what comes between its name and its block — has the shape the at-rule needs: a dashed name for `@property`, a valid name for `@keyframes` and `@counter-style`, layer names for `@layer`, a URL for `@import`, nothing for `@font-face`.
|
|
15
|
+
|
|
16
|
+
**Why:** A browser drops an at-rule whose prelude is invalid, with everything inside it.
|
|
17
|
+
|
|
18
|
+
```codelaw
|
|
19
|
+
native: css/at-rule-prelude-no-invalid
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Rewrite the prelude in the form the at-rule's specification gives.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### CSS
|
|
29
|
+
|
|
30
|
+
#### Don't
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
@property size {
|
|
34
|
+
syntax: "<length>";
|
|
35
|
+
inherits: false;
|
|
36
|
+
initial-value: 0px;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Do
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
@property --size {
|
|
44
|
+
syntax: "<length>";
|
|
45
|
+
inherits: false;
|
|
46
|
+
initial-value: 0px;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Differences from the source
|
|
51
|
+
|
|
52
|
+
Checks `@property`, `@font-palette-values`, `@position-try`, `@counter-style`, `@keyframes`, `@layer`, `@import`, `@namespace`, `@charset` and the at-rules that take no prelude; `@supports`, `@container`, `@page` and `@scope` preludes are not checked, as stylelint checks them with the CSSTree grammar codelaw does not ship.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/block-no-redundant-nested-style-rules
|
|
3
|
+
title: "No `& { \u2026 }` wrapper"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "declarations moved out of the wrapper change place relative to the nested rules around it"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/block-no-redundant-nested-style-rules]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
A nested style rule whose selector is only `&` is not used: its declarations go straight in the parent block.
|
|
13
|
+
|
|
14
|
+
**Why:** `& { … }` selects the same elements as its parent, so the wrapper only adds nesting.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/block-no-redundant-nested-style-rules
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### CSS
|
|
23
|
+
|
|
24
|
+
#### Don't
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
a {
|
|
28
|
+
& {
|
|
29
|
+
color: red;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### Do
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
a {
|
|
38
|
+
color: red;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/color-function-alias-notation
|
|
3
|
+
title: "`rgb()` and `hsl()`, not `rgba()` and `hsla()`"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "browsers before 2018 ignore an alpha channel in `rgb()`"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/color-function-alias-notation]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Colours use `rgb()` and `hsl()`; their aliases `rgba()` and `hsla()` are not used.
|
|
13
|
+
|
|
14
|
+
**Why:** The aliases are exactly equivalent today; one spelling is easier to search and read.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/color-function-alias-notation
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### CSS
|
|
23
|
+
|
|
24
|
+
#### Don't
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
a {
|
|
28
|
+
color: rgba(0 0 0 / 50%);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Do
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
a {
|
|
36
|
+
color: rgb(0 0 0 / 50%);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Differences from the source
|
|
41
|
+
|
|
42
|
+
Ported with stylelint-config-standard's setting, `without-alpha`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/color-function-notation
|
|
3
|
+
title: "Space-separated colour functions"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: suggest
|
|
6
|
+
fix_reason: "browsers before 2018 understand only the comma syntax"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint/color-function-notation]
|
|
9
|
+
since: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
`rgb()`, `rgba()`, `hsl()` and `hsla()` use the modern space-separated syntax, with ` / ` before the alpha, not commas.
|
|
13
|
+
|
|
14
|
+
**Why:** The modern syntax is the one newer colour functions (`lab()`, `oklch()`) share.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: css/color-function-notation
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### CSS
|
|
23
|
+
|
|
24
|
+
#### Don't
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
a {
|
|
28
|
+
color: rgb(0, 0, 0);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Do
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
a {
|
|
36
|
+
color: rgb(0 0 0);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Differences from the source
|
|
41
|
+
|
|
42
|
+
Ported with stylelint-config-standard's setting, `modern`; values with `var()` inside are skipped.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/color-hex-length
|
|
3
|
+
title: "Short hex colours"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/color-hex-length]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Hex colours use the short form when there is one: `#fff`, not `#ffffff`.
|
|
12
|
+
|
|
13
|
+
**Why:** The short form says the same in fewer characters.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/color-hex-length
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
a {
|
|
27
|
+
color: #ffffff;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Do
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
a {
|
|
35
|
+
color: #fff;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Differences from the source
|
|
40
|
+
|
|
41
|
+
Ported with stylelint-config-standard's setting, `short`.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/comment-no-empty
|
|
3
|
+
title: "No empty comments"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint/comment-no-empty]
|
|
8
|
+
since: 0.1.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Every comment has some text.
|
|
12
|
+
|
|
13
|
+
**Why:** An empty comment carries nothing and is usually left over from an edit.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: css/comment-no-empty
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### CSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
/**/
|
|
27
|
+
a {
|
|
28
|
+
color: red;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Do
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
a {
|
|
36
|
+
color: red;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: css/container-name-pattern
|
|
3
|
+
title: "Container names are kebab-case"
|
|
4
|
+
languages: [css]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "renaming must update every use of 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/container-name-pattern]
|
|
11
|
+
since: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Names given in `container-name`, `container` and `@container` 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/container-name-pattern
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## How to fix
|
|
23
|
+
|
|
24
|
+
1. Rename the container to match the pattern.
|
|
25
|
+
2. Update every `@container` query that uses it.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### CSS
|
|
30
|
+
|
|
31
|
+
#### Don't
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
.card {
|
|
35
|
+
container-name: cardGrid;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Do
|
|
40
|
+
|
|
41
|
+
```css
|
|
42
|
+
.card {
|
|
43
|
+
container-name: card-grid;
|
|
44
|
+
}
|
|
45
|
+
```
|