UNPKG

4.03 kBMarkdownView Raw
1# value-keyword-case
2
3Specify lowercase or uppercase for keywords values.
4
5<!-- prettier-ignore -->
6```css
7 a { display: block; }
8/** ↑
9 * These values */
10```
11
12This rule ignores [`<custom-idents>`](https://developer.mozilla.org/en/docs/Web/CSS/custom-ident) of known properties. Keyword values which are paired with non-properties (e.g. `$vars` and custom properties), and do not conform to the primary option, can be ignored using the `ignoreKeywords: []` secondary option.
13
14The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.
15
16## Options
17
18`string`: `"lower"|"upper"`
19
20### `"lower"`
21
22The following patterns are considered violations:
23
24<!-- prettier-ignore -->
25```css
26a {
27 display: Block;
28}
29```
30
31<!-- prettier-ignore -->
32```css
33a {
34 display: bLoCk;
35}
36```
37
38<!-- prettier-ignore -->
39```css
40a {
41 display: BLOCK;
42}
43```
44
45<!-- prettier-ignore -->
46```css
47a {
48 transition: -WEBKIT-TRANSFORM 2s;
49}
50```
51
52The following patterns are _not_ considered violations:
53
54<!-- prettier-ignore -->
55```css
56a {
57 display: block;
58}
59```
60
61<!-- prettier-ignore -->
62```css
63a {
64 transition: -webkit-transform 2s;
65}
66```
67
68### `"upper"`
69
70The following patterns are considered violations:
71
72<!-- prettier-ignore -->
73```css
74a {
75 display: Block;
76}
77```
78
79<!-- prettier-ignore -->
80```css
81a {
82 display: bLoCk;
83}
84```
85
86<!-- prettier-ignore -->
87```css
88a {
89 display: block;
90}
91```
92
93<!-- prettier-ignore -->
94```css
95a {
96 transition: -webkit-transform 2s;
97}
98```
99
100The following patterns are _not_ considered violations:
101
102<!-- prettier-ignore -->
103```css
104a {
105 display: BLOCK;
106}
107```
108
109<!-- prettier-ignore -->
110```css
111a {
112 transition: -WEBKIT-TRANSFORM 2s;
113}
114```
115
116## Optional secondary options
117
118### `ignoreKeywords: ["/regex/", /regex/, "non-regex"]`
119
120Ignore case of keywords values.
121
122For example, with `"lower"`.
123
124Given:
125
126```
127["Block", "/^(f|F)lex$/"]
128```
129
130The following patterns are considered violations:
131
132<!-- prettier-ignore -->
133```css
134a {
135 display: bLoCk;
136}
137```
138
139<!-- prettier-ignore -->
140```css
141a {
142 display: BLOCK;
143}
144```
145
146<!-- prettier-ignore -->
147```css
148a {
149 display: fLeX;
150}
151```
152
153<!-- prettier-ignore -->
154```css
155a {
156 display: FLEX;
157}
158```
159
160The following patterns are _not_ considered violations:
161
162<!-- prettier-ignore -->
163```css
164a {
165 display: block;
166}
167```
168
169<!-- prettier-ignore -->
170```css
171a {
172 display: Block;
173}
174```
175
176<!-- prettier-ignore -->
177```css
178a {
179 display: flex;
180}
181```
182
183<!-- prettier-ignore -->
184```css
185a {
186 display: Flex;
187}
188```
189
190### `ignoreProperties: ["/regex/", /regex/, "non-regex"]`
191
192Ignore case of the values of the listed properties.
193
194For example, with `"lower"`.
195
196```js
197["/^(b|B)ackground$/", "display"];
198```
199
200The following patterns are considered violations:
201
202<!-- prettier-ignore -->
203```css
204a {
205 text-align: LEFT;
206}
207```
208
209<!-- prettier-ignore -->
210```css
211a {
212 text-align: Left;
213}
214```
215
216The following patterns are _not_ considered violations:
217
218<!-- prettier-ignore -->
219```css
220a {
221 display: bloCk;
222}
223```
224
225<!-- prettier-ignore -->
226```css
227a {
228 display: BloCk;
229}
230```
231
232<!-- prettier-ignore -->
233```css
234a {
235 display: BLOCK;
236}
237```
238
239<!-- prettier-ignore -->
240```css
241a {
242 display: block;
243}
244```
245
246<!-- prettier-ignore -->
247```css
248a {
249 background: Red;
250}
251```
252
253<!-- prettier-ignore -->
254```css
255a {
256 Background: deepPink;
257}
258```
259
260### `ignoreFunctions: ["/regex/", /regex/, "non-regex"]`
261
262Ignore case of the values inside the listed functions.
263
264For example, with `"upper"`.
265
266```js
267["/^(f|F)oo$/", "t"];
268```
269
270The following patterns are considered violations:
271
272<!-- prettier-ignore -->
273```css
274a {
275 display: b(inline);
276}
277```
278
279```css
280a {
281 color: bar(--camelCase);
282}
283```
284
285The following patterns are _not_ considered violations:
286
287<!-- prettier-ignore -->
288```css
289a {
290 display: t(flex);
291}
292```
293
294<!-- prettier-ignore -->
295```css
296a {
297 display: t(fLeX);
298}
299```
300
301<!-- prettier-ignore -->
302```css
303a {
304 color: t(--camelCase);
305}
306```
307
308<!-- prettier-ignore -->
309```css
310a {
311 color: foo(--camelCase);
312}
313```
314
315<!-- prettier-ignore -->
316```css
317a {
318 color: Foo(--camelCase);
319}
320```