UNPKG

1.79 kBMarkdownView Raw
1# media-feature-name-value-whitelist
2
3**_Deprecated: Instead use the [`media-feature-name-value-allowed-list`](../media-feature-name-value-allowed-list/README.md) rule._**
4
5Specify a list of allowed media feature name and value pairs.
6
7<!-- prettier-ignore -->
8```css
9@media screen and (min-width: 768px) {}
10/** ↑ ↑
11 * These features and values */
12```
13
14## Options
15
16```js
17{
18 "unprefixed-media-feature-name": ["array", "of", "values"],
19 "/unprefixed-media-feature-name/": ["/regex/", "non-regex", /real-regex/]
20}
21```
22
23If a media feature name is found in the object, only its allowed-listed values are
24allowed. If the media feature name is not included in the object, anything goes.
25
26If a name or value is surrounded with `/` (e.g. `"/width$/"`), it is interpreted
27as a regular expression. For example, `/width$/` will match `max-width` and
28`min-width`.
29
30Given:
31
32```
33{
34 "min-width": ["768px", "1024px"],
35 "/resolution/": ["/dpcm$/"]
36}
37```
38
39The following patterns are considered violations:
40
41<!-- prettier-ignore -->
42```css
43@media screen and (min-width: 1000px) {}
44```
45
46<!-- prettier-ignore -->
47```css
48@media screen and (min-resolution: 2dpi) {}
49```
50
51<!-- prettier-ignore -->
52```css
53@media screen and (min-width > 1000px) {}
54```
55
56The following patterns are _not_ considered violations:
57
58<!-- prettier-ignore -->
59```css
60@media screen and (min-width: 768px) {}
61```
62
63<!-- prettier-ignore -->
64```css
65@media screen and (min-width: 1024px) {}
66```
67
68<!-- prettier-ignore -->
69```css
70@media screen and (orientation: portrait) {}
71```
72
73<!-- prettier-ignore -->
74```css
75@media screen and (min-resolution: 2dpcm) {}
76```
77
78<!-- prettier-ignore -->
79```css
80@media screen and (resolution: 10dpcm) {}
81```
82
83<!-- prettier-ignore -->
84```css
85@media screen and (768px < min-width) {}
86```