1 | # selector-id-pattern
|
2 |
|
3 | Specify a pattern for ID selectors.
|
4 |
|
5 |
|
6 | ```css
|
7 | .foo, #bar.baz a, #hoo[disabled] { color: pink; }
|
8 | /** ↑ ↑
|
9 | * These ID selectors */
|
10 | ```
|
11 |
|
12 | ## Options
|
13 |
|
14 | `regex|string`
|
15 |
|
16 | A string will be translated into a RegExp like so `new RegExp(yourString)` — so be sure to escape properly.
|
17 |
|
18 | The selector value _after `#`_ will be checked. No need to include `#` in your pattern.
|
19 |
|
20 | Given the string:
|
21 |
|
22 | ```
|
23 | "foo-[a-z]+"
|
24 | ```
|
25 |
|
26 | The following patterns are considered violations:
|
27 |
|
28 |
|
29 | ```css
|
30 | #foop {}
|
31 | ```
|
32 |
|
33 |
|
34 | ```css
|
35 | #foo-BAR {}
|
36 | ```
|
37 |
|
38 |
|
39 | ```css
|
40 | div > .zing + #foo-BAR {}
|
41 | ```
|
42 |
|
43 | The following patterns are _not_ considered violations:
|
44 |
|
45 |
|
46 | ```css
|
47 | #foo-bar {}
|
48 | ```
|
49 |
|
50 |
|
51 | ```css
|
52 | div > .zing + #foo-bar {}
|
53 | ```
|
54 |
|
55 |
|
56 | ```css
|
57 | .foop {}
|
58 | ```
|
59 |
|
60 |
|
61 | ```css
|
62 | [foo='bar'] {}
|
63 | ```
|