1 | # declaration-property-value-allowed-list
|
2 |
|
3 | Specify a list of allowed property and value pairs within declarations.
|
4 |
|
5 |
|
6 | ```css
|
7 | a { text-transform: uppercase; }
|
8 | /** ↑ ↑
|
9 | * These properties and these values */
|
10 | ```
|
11 |
|
12 | ## Options
|
13 |
|
14 | `object`: `{ "unprefixed-property-name": ["array", "of", "values"], "unprefixed-property-name": ["/regex/", "non-regex"] }`
|
15 |
|
16 | If a property name is found in the object, only the listed property values are allowed. This rule complains about all non-matching values. (If the property name is not included in the object, anything goes.)
|
17 |
|
18 | If a property name is surrounded with `"/"` (e.g. `"/^animation/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^animation/` will match `animation`, `animation-duration`, `animation-timing-function`, etc.
|
19 |
|
20 | The same goes for values. Keep in mind that a regular expression value is matched against the entire value of the declaration, not specific parts of it. For example, a value like `"10px solid rgba( 255 , 0 , 0 , 0.5 )"` will _not_ match `"/^solid/"` (notice beginning of the line boundary) but _will_ match `"/\\s+solid\\s+/"` or `"/\\bsolid\\b/"`.
|
21 |
|
22 | Be careful with regex matching not to accidentally consider quoted string values and `url()` arguments. For example, `"/red/"` will match value such as `"1px dotted red"` as well as `"\"red\""` and `"white url(/mysite.com/red.png)"`.
|
23 |
|
24 | Given:
|
25 |
|
26 | ```
|
27 | {
|
28 | "transform": ["/scale/"],
|
29 | "whitespace": ["nowrap"],
|
30 | "/color/": ["/^green/"]
|
31 | }
|
32 | ```
|
33 |
|
34 | The following patterns are considered violations:
|
35 |
|
36 |
|
37 | ```css
|
38 | a { whitespace: pre; }
|
39 | ```
|
40 |
|
41 |
|
42 | ```css
|
43 | a { transform: translate(1, 1); }
|
44 | ```
|
45 |
|
46 |
|
47 | ```css
|
48 | a { -webkit-transform: translate(1, 1); }
|
49 | ```
|
50 |
|
51 |
|
52 | ```css
|
53 | a { color: pink; }
|
54 | ```
|
55 |
|
56 |
|
57 | ```css
|
58 | a { background-color: pink; }
|
59 | ```
|
60 |
|
61 | The following patterns are _not_ considered violations:
|
62 |
|
63 |
|
64 | ```css
|
65 | a { color: pink; }
|
66 | ```
|
67 |
|
68 |
|
69 | ```css
|
70 | a { whitespace: nowrap; }
|
71 | ```
|
72 |
|
73 |
|
74 | ```css
|
75 | a { transform: scale(1, 1); }
|
76 | ```
|
77 |
|
78 |
|
79 | ```css
|
80 | a { -webkit-transform: scale(1, 1); }
|
81 | ```
|
82 |
|
83 |
|
84 | ```css
|
85 | a { color: green; }
|
86 | ```
|
87 |
|
88 |
|
89 | ```css
|
90 | a { background-color: green; }
|
91 | ```
|
92 |
|
93 |
|
94 | ```css
|
95 | a { background: pink; }
|
96 | ```
|