UNPKG

1.03 kBMarkdownView Raw
1# selector-pseudo-class-whitelist
2
3Specify a whitelist of allowed pseudo-class selectors.
4
5<!-- prettier-ignore -->
6```css
7 a:hover {}
8/** ↑
9 * This pseudo-class selector */
10```
11
12This rule ignores selectors that use variable interpolation e.g. `:#{$variable} {}`.
13
14## Options
15
16`array|string|regex`: `["array", "of", "unprefixed", /pseudo-classes/ or "/regex/"]|"pseudo-class"|/regex/`
17
18If a string is surrounded with `"/"` (e.g. `"/^nth-/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^nth-/` will match `nth-child`, `nth-last-child`, `nth-of-type`, etc.
19
20Given:
21
22```
23["hover", "/^nth-/"]
24```
25
26The following patterns are considered violations:
27
28<!-- prettier-ignore -->
29```css
30a:focus {}
31```
32
33<!-- prettier-ignore -->
34```css
35a:first-of-type {}
36```
37
38The following patterns are _not_ considered violations:
39
40<!-- prettier-ignore -->
41```css
42a:hover {}
43```
44
45<!-- prettier-ignore -->
46```css
47a:nth-of-type(5) {}
48```
49
50<!-- prettier-ignore -->
51```css
52a:nth-child(2) {}
53```