UNPKG

2.46 kBMarkdownView Raw
1# color-function-notation
2
3Specify modern or legacy notation for applicable color-functions.
4
5<!-- prettier-ignore -->
6```css
7 a { color: rgb(0 0 0 / 0.2) }
8/** ↑
9 * This notation */
10```
11
12Modern color-functions use a comma-free syntax because functions in CSS are used to group/name a syntax chunk. They should work by the same rules that CSS grammar does in general: values are optional and re-orderable when possible, space-separated, and commas are used to separate repetitions only.
13
14For legacy reasons, `rgb()` and `hsl()` also supports an alternate syntax that separates all of its arguments with commas. Also for legacy reasons, the `rgba()` and `hsla()` functions exist using the same comma-based syntax.
15
16The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix some of the problems reported by this rule when the primary option is `"modern"`.
17
18## Options
19
20`string`: `"modern"|"legacy"`
21
22### `"modern"`
23
24Applicable color-functions _must always_ use modern notation.
25
26The following patterns are considered violations:
27
28<!-- prettier-ignore -->
29```css
30a { color: rgb(0, 0, 0) }
31```
32
33<!-- prettier-ignore -->
34```css
35a { color: rgba(12, 122, 231, 0.2) }
36```
37
38<!-- prettier-ignore -->
39```css
40a { color: hsla(270, 60%, 50%, 15%) }
41```
42
43<!-- prettier-ignore -->
44```css
45a { color: hsl(.75turn, 60%, 70%) }
46```
47
48The following patterns are _not_ considered violations:
49
50<!-- prettier-ignore -->
51```css
52a { color: rgb(0 0 0) }
53```
54
55<!-- prettier-ignore -->
56```css
57a { color: rgb(12 122 231 / 0.2) }
58```
59
60<!-- prettier-ignore -->
61```css
62a { color: hsl(270 60% 50% / 15%) }
63```
64
65<!-- prettier-ignore -->
66```css
67a { color: hsl(.75turn 60% 70%) }
68```
69
70### `"legacy"`
71
72Applicable color-functions _must always_ use the legacy notation.
73
74The following patterns are considered violations:
75
76<!-- prettier-ignore -->
77```css
78a { color: rgb(0 0 0) }
79```
80
81<!-- prettier-ignore -->
82```css
83a { color: rgb(12 122 231 / 0.2) }
84```
85
86<!-- prettier-ignore -->
87```css
88a { color: hsl(270 60% 50% / 15%) }
89```
90
91<!-- prettier-ignore -->
92```css
93a { color: hsl(.75turn 60% 70%) }
94```
95
96The following patterns are _not_ considered violations:
97
98<!-- prettier-ignore -->
99```css
100a { color: rgb(0, 0, 0) }
101```
102
103<!-- prettier-ignore -->
104```css
105a { color: rgba(12, 122, 231, 0.2) }
106```
107
108<!-- prettier-ignore -->
109```css
110a { color: hsla(270, 60%, 50%, 15%) }
111```
112
113<!-- prettier-ignore -->
114```css
115a { color: hsl(.75turn, 60%, 70%) }
116```