useGenericFontNames
¥Summary
-
规则生效日期:
v1.8.0¥Rule available since:
v1.8.0 -
诊断类别:
lint/a11y/useGenericFontNames¥Diagnostic Category:
lint/a11y/useGenericFontNames -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "a11y": { "useGenericFontNames": "error" } } }}¥Description
禁止在字体系列中缺少通用系列关键字。
¥Disallow a missing generic family keyword within font families.
通用字体系列可以是:
¥The generic font family can be:
-
放置在字体系列列表中的任何位置
¥placed anywhere in the font family list
-
如果使用与属性继承或系统字体相关的关键字,则省略
¥omitted if a keyword related to property inheritance or a system font is used
此规则检查字体和字体系列属性。以下特殊情况被忽略:
¥This rule checks the font and font-family properties. The following special situations are ignored:
-
具有关键字值的属性,例如
inherit、initial。¥Property with a keyword value such as
inherit,initial. -
最后一个值是 CSS 变量。
¥The last value being a CSS variable.
-
@font-face规则中的font-family属性。¥
font-familyproperty in an@font-facerule.
¥Examples
¥Invalid
a { font-family: Arial; }code-block.css:1:18 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Generic font family missing.
> 1 │ a { font-family: Arial; }
│ ^^^^^
2 │
ℹ Consider adding a generic font family as a fallback.
ℹ For examples and more information, see the MDN Web Docs
- serif
- sans-serif
- monospace
- etc.
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont; }code-block.css:1:43 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Generic font family missing.
> 1 │ a { font: normal 14px/32px -apple-system, BlinkMacSystemFont; }
│ ^^^^^^^^^^^^^^^^^^
2 │
ℹ Consider adding a generic font family as a fallback.
ℹ For examples and more information, see the MDN Web Docs
- serif
- sans-serif
- monospace
- etc.
¥Valid
a { font-family: "Lucida Grande", "Arial", sans-serif; }a { font-family: inherit; }a { font-family: sans-serif; }a { font-family: var(--font); }@font-face { font-family: Gentium; }¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号