UNPKG

941 BMarkdownView Raw
1# selector-id-pattern
2
3Specify a pattern for ID selectors.
4
5<!-- prettier-ignore -->
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
16A string will be translated into a RegExp like so `new RegExp(yourString)` — so be sure to escape properly.
17
18The selector value _after `#`_ will be checked. No need to include `#` in your pattern.
19
20Given the string:
21
22```
23"foo-[a-z]+"
24```
25
26The following patterns are considered violations:
27
28<!-- prettier-ignore -->
29```css
30#foop {}
31```
32
33<!-- prettier-ignore -->
34```css
35#foo-BAR {}
36```
37
38<!-- prettier-ignore -->
39```css
40div > .zing + #foo-BAR {}
41```
42
43The following patterns are _not_ considered violations:
44
45<!-- prettier-ignore -->
46```css
47#foo-bar {}
48```
49
50<!-- prettier-ignore -->
51```css
52div > .zing + #foo-bar {}
53```
54
55<!-- prettier-ignore -->
56```css
57.foop {}
58```
59
60<!-- prettier-ignore -->
61```css
62[foo='bar'] {}
63```