UNPKG

1.81 kBMarkdownView Raw
1# alpha-value-notation
2
3Specify percentage or number notation for alpha-values.
4
5<!-- prettier-ignore -->
6```css
7 a { color: rgb(0 0 0 / 0.5) }
8/** ↑
9 * This notation */
10```
11
12The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
13
14## Options
15
16`string`: `"number"|"percentage"`
17
18### `"number"`
19
20Alpha-values _must always_ use the number notation.
21
22The following patterns are considered violations:
23
24<!-- prettier-ignore -->
25```css
26a { opacity: 50% }
27```
28
29<!-- prettier-ignore -->
30```css
31a { color: rgb(0 0 0 / 50%) }
32```
33
34The following patterns are _not_ considered violations:
35
36<!-- prettier-ignore -->
37```css
38a { opacity: 0.5 }
39```
40
41<!-- prettier-ignore -->
42```css
43a { color: rgb(0 0 0 / 0.5) }
44```
45
46### `"percentage"`
47
48Alpha-values _must always_ use percentage notation.
49
50The following patterns are considered violations:
51
52<!-- prettier-ignore -->
53```css
54a { opacity: 0.5 }
55```
56
57<!-- prettier-ignore -->
58```css
59a { color: rgb(0 0 0 / 0.5) }
60```
61
62The following patterns are _not_ considered violations:
63
64<!-- prettier-ignore -->
65```css
66a { opacity: 50% }
67```
68
69<!-- prettier-ignore -->
70```css
71a { color: rgb(0 0 0 / 50%) }
72```
73
74## Optional secondary options
75
76### `exceptProperties: ["/regex/", /regex/, "string"]`
77
78Reverse the primary option for matching properties.
79
80For example with `"percentage"`.
81
82Given:
83
84```
85["opacity"]
86```
87
88The following patterns are considered violations:
89
90<!-- prettier-ignore -->
91```css
92a { opacity: 50% }
93```
94
95<!-- prettier-ignore -->
96```css
97a { color: rgb(0 0 0 / 0.5) }
98```
99
100The following patterns are _not_ considered violations:
101
102<!-- prettier-ignore -->
103```css
104a { opacity: 0.5 }
105```
106
107<!-- prettier-ignore -->
108```css
109a { color: rgb(0 0 0 / 50%) }
110```