UNPKG

1.6 kBMarkdownView Raw
1# font-family-no-duplicate-names
2
3Disallow duplicate font family names.
4
5<!-- prettier-ignore -->
6```css
7a { font-family: serif, serif; }
8/** ↑ ↑
9 * These font family names */
10```
11
12This rule checks the `font` and `font-family` properties.
13
14This rule ignores `$sass`, `@less`, and `var(--custom-property)` variable syntaxes.
15
16**Caveat:** This rule will stumble on _unquoted_ multi-word font names and _unquoted_ font names containing escape sequences. Wrap these font names in quotation marks, and everything should be fine.
17
18## Options
19
20### `true`
21
22The following patterns are considered problems:
23
24<!-- prettier-ignore -->
25```css
26a { font-family: 'Times', Times, serif; }
27```
28
29<!-- prettier-ignore -->
30```css
31a { font: 1em "Arial", 'Arial', sans-serif; }
32```
33
34<!-- prettier-ignore -->
35```css
36a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif, sans-serif; }
37```
38
39The following patterns are _not_ considered problems:
40
41<!-- prettier-ignore -->
42```css
43a { font-family: Times, serif; }
44```
45
46<!-- prettier-ignore -->
47```css
48a { font: 1em "Arial", "sans-serif", sans-serif; }
49```
50
51<!-- prettier-ignore -->
52```css
53a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif; }
54```
55
56## Optional secondary options
57
58### `ignoreFontFamilyNames: ["/regex/", /regex/, "string"]`
59
60Given:
61
62```json
63["/^My Font /", "monospace"]
64```
65
66The following patterns are _not_ considered problems:
67
68<!-- prettier-ignore -->
69```css
70font-family: monospace, monospace
71```
72
73<!-- prettier-ignore -->
74```css
75font-family: "My Font Family", "My Font Family", monospace
76```