font-weight-notation
要求使用数字或命名(在可能的情况下)的 font-weight 值。
a { font-weight: bold; }
/** ↑
* This notation */
a { font: italic small-caps 600 16px/3 cursive; }
/** ↑
* And this notation, too */
@font-face { font-weight: normal bold; }
/** ↑
* Multiple notations are available in @font-face */
此规则忽略 $sass、@less 和 var(--custom-property) 变量语法。
该 fix 选项 可以自动修复此规则报告的所有问题。
选项
string: "numeric"|"named-where-possible"
"numeric"
font-weight 值必须始终为数字。
以下模式被视为问题
a { font-weight: bold; }
a { font: italic normal 20px sans-serif; }
@font-face { font-weight: normal bold; }
以下模式不被视为问题
a { font-weight: 700; }
a { font: italic 400 20px; }
@font-face { font-weight: 400 700; }
"named-where-possible"
font-weight 值必须始终为关键字,前提是存在合适的关键字。
这意味着只有 400 和 700 会被拒绝,因为它们是唯一具有关键字等效项(normal 和 bold)的数字。
以下模式被视为问题
a { font-weight: 700; }
a { font: italic 400 20px sans-serif; }
以下模式不被视为问题
a { font-weight: bold; }
a { font: italic normal 20px sans-serif; }
可选的辅助选项
ignore: ["relative"]
忽略 相对 的关键字名称 bolder 和 lighter。
以下模式不被视为问题
a { font-weight: 400; }
a b { font-weight: lighter; }