長度為零-不允許單位
禁止零長度的單位。
a { top: 0px; }
/** ↑↑
* This zero and this type of length unit */
長度指的是距離測量。長度是一種維度,是一種數字,後接一個單位識別碼。不過,對於零長度,單位識別碼是可選的。長度單位有:em
、ex
、ch
、vw
、vh
、cm
、mm
、in
、pt
、pc
、px
、rem
、vmin
和 vmax
。
此規則會忽略數學函數中的長度(例如 calc
)。
fix 選項
可以自動修正此規則所報告的所有問題。
選項
true
以下模式被視為問題
a { top: 0px }
a { top: 0.000em }
以下模式不是問題
a { top: 0 } /* no unit */
a { transition-delay: 0s; } /* dimension */
a { top: 2in; }
a { top: 1.001vh }
可選的次要選項
ignore: ["custom-properties"]
"custom-properties"
忽略自訂屬性中零長度的單位。
以下模式不是問題
a { --x: 0px; }
ignoreFunctions: ["/regex/", /regex/, "string"]
給定
["var", "/^--/"]
以下模式不是問題
a { top: var(--foo, 0px); }
a { top: --bar(0px); }