1 | # unit-whitelist
|
2 |
|
3 | **_Deprecated: Instead use the [`unit-allowed-list`](../unit-allowed-list/README.md) rule._**
|
4 |
|
5 | Specify a list of allowed units.
|
6 |
|
7 |
|
8 | ```css
|
9 | a { width: 100px; }
|
10 | /** ↑
|
11 | * These units */
|
12 | ```
|
13 |
|
14 | ## Options
|
15 |
|
16 | `array|string`: `["array", "of", "units"]|"unit"`
|
17 |
|
18 | Given:
|
19 |
|
20 | ```
|
21 | ["px", "em", "deg"]
|
22 | ```
|
23 |
|
24 | The following patterns are considered violations:
|
25 |
|
26 |
|
27 | ```css
|
28 | a { width: 100%; }
|
29 | ```
|
30 |
|
31 |
|
32 | ```css
|
33 | a { font-size: 10rem; }
|
34 | ```
|
35 |
|
36 |
|
37 | ```css
|
38 | a { animation: animation-name 5s ease; }
|
39 | ```
|
40 |
|
41 | The following patterns are _not_ considered violations:
|
42 |
|
43 |
|
44 | ```css
|
45 | a { font-size: 1.2em; }
|
46 | ```
|
47 |
|
48 |
|
49 | ```css
|
50 | a { line-height: 1.2; }
|
51 | ```
|
52 |
|
53 |
|
54 | ```css
|
55 | a { height: 100px; }
|
56 | ```
|
57 |
|
58 |
|
59 | ```css
|
60 | a { height: 100PX; }
|
61 | ```
|
62 |
|
63 |
|
64 | ```css
|
65 | a { transform: rotate(30deg); }
|
66 | ```
|
67 |
|
68 | ## Optional secondary options
|
69 |
|
70 | ### `ignoreProperties: { unit: ["property", "/regex/", /regex/] }`
|
71 |
|
72 | Ignore units in the values of declarations with the specified properties.
|
73 |
|
74 | For example, with `["px", "em"]`.
|
75 |
|
76 | Given:
|
77 |
|
78 | ```
|
79 | {
|
80 | "rem": [ "line-height", "/^border/" ],
|
81 | "%": [ "width" ]
|
82 | }
|
83 | ```
|
84 |
|
85 | The following patterns are _not_ considered violations:
|
86 |
|
87 |
|
88 | ```css
|
89 | a { line-height: 0.1rem; }
|
90 | ```
|
91 |
|
92 |
|
93 | ```css
|
94 | a { border-bottom-width: 6rem; }
|
95 | ```
|
96 |
|
97 |
|
98 | ```css
|
99 | a { width: 100%; }
|
100 | ```
|
101 |
|
102 | The following patterns are considered violations:
|
103 |
|
104 |
|
105 | ```css
|
106 | a { margin: 0 20rem; }
|
107 | ```
|
108 |
|
109 |
|
110 | ```css
|
111 | a { -moz-border-radius-topright: 20rem; }
|
112 | ```
|
113 |
|
114 |
|
115 | ```css
|
116 | a { height: 100%; }
|
117 | ```
|