1 | # font-family-no-duplicate-names
|
2 |
|
3 | Disallow duplicate font family names.
|
4 |
|
5 |
|
6 | ```css
|
7 | a { font-family: serif, serif; }
|
8 | /** ↑ ↑
|
9 | * These font family names */
|
10 | ```
|
11 |
|
12 | This rule checks the `font` and `font-family` properties.
|
13 |
|
14 | This 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 |
|
22 | The following patterns are considered problems:
|
23 |
|
24 |
|
25 | ```css
|
26 | a { font-family: 'Times', Times, serif; }
|
27 | ```
|
28 |
|
29 |
|
30 | ```css
|
31 | a { font: 1em "Arial", 'Arial', sans-serif; }
|
32 | ```
|
33 |
|
34 |
|
35 | ```css
|
36 | a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif, sans-serif; }
|
37 | ```
|
38 |
|
39 | The following patterns are _not_ considered problems:
|
40 |
|
41 |
|
42 | ```css
|
43 | a { font-family: Times, serif; }
|
44 | ```
|
45 |
|
46 |
|
47 | ```css
|
48 | a { font: 1em "Arial", "sans-serif", sans-serif; }
|
49 | ```
|
50 |
|
51 |
|
52 | ```css
|
53 | a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif; }
|
54 | ```
|
55 |
|
56 | ## Optional secondary options
|
57 |
|
58 | ### `ignoreFontFamilyNames: ["/regex/", /regex/, "string"]`
|
59 |
|
60 | Given:
|
61 |
|
62 | ```json
|
63 | ["/^My Font /", "monospace"]
|
64 | ```
|
65 |
|
66 | The following patterns are _not_ considered problems:
|
67 |
|
68 |
|
69 | ```css
|
70 | font-family: monospace, monospace
|
71 | ```
|
72 |
|
73 |
|
74 | ```css
|
75 | font-family: "My Font Family", "My Font Family", monospace
|
76 | ```
|