UNPKG

2.44 kBMarkdownView Raw
1# declaration-property-value-allowed-list
2
3Specify a list of allowed property and value pairs within declarations.
4
5<!-- prettier-ignore -->
6```css
7a { 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
16If 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
18If 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
20The 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
22Be 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
24Given:
25
26```
27{
28 "transform": ["/scale/"],
29 "whitespace": ["nowrap"],
30 "/color/": ["/^green/"]
31}
32```
33
34The following patterns are considered violations:
35
36<!-- prettier-ignore -->
37```css
38a { whitespace: pre; }
39```
40
41<!-- prettier-ignore -->
42```css
43a { transform: translate(1, 1); }
44```
45
46<!-- prettier-ignore -->
47```css
48a { -webkit-transform: translate(1, 1); }
49```
50
51<!-- prettier-ignore -->
52```css
53a { color: pink; }
54```
55
56<!-- prettier-ignore -->
57```css
58a { background-color: pink; }
59```
60
61The following patterns are _not_ considered violations:
62
63<!-- prettier-ignore -->
64```css
65a { color: pink; }
66```
67
68<!-- prettier-ignore -->
69```css
70a { whitespace: nowrap; }
71```
72
73<!-- prettier-ignore -->
74```css
75a { transform: scale(1, 1); }
76```
77
78<!-- prettier-ignore -->
79```css
80a { -webkit-transform: scale(1, 1); }
81```
82
83<!-- prettier-ignore -->
84```css
85a { color: green; }
86```
87
88<!-- prettier-ignore -->
89```css
90a { background-color: green; }
91```
92
93<!-- prettier-ignore -->
94```css
95a { background: pink; }
96```