Skip to main content

font-family-no-duplicate-names

禁止字体系列中出现重复名称。

¥Disallow duplicate names within font families.

a { font-family: serif, serif; }
/** ↑ ↑

* These font family names */

此规则检查 fontfont-family 属性。

¥This rule checks the font and font-family properties.

此规则忽略 $sass@lessvar(--custom-property) 变量语法。

¥This rule ignores $sass, @less, and var(--custom-property) variable syntaxes.

[!警告] 此规则将无法识别未加引号的多字字体名称和包含转义序列的未加引号的字体名称。将这些字体名称用引号引起来,一切都应该没问题。

¥[!WARNING] 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.

选项

¥Options

true

以下模式被视为问题:

¥The following patterns are considered problems:

a { font-family: 'Times', Times, serif; }
a { font: 1em "Arial", 'Arial', sans-serif; }
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif, sans-serif; }

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { font-family: Times, serif; }
a { font: 1em "Arial", "sans-serif", sans-serif; }
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif; }

可选的辅助选项

¥Optional secondary options

ignoreFontFamilyNames: ["/regex/", /regex/, "string"]

鉴于:

¥Given:

["/^My Font /", "monospace"]

以下模式不被视为问题:

¥The following patterns are not considered problems:

font-family: monospace, monospace
font-family: "My Font Family", "My Font Family", monospace