メインコンテンツへスキップ

unit-allowed-list

許可された単位のリストを指定します。

a { width: 100px; }
/** ↑
* These units */

message セカンダリオプションは、このルールの引数を受け入れることができます。

オプション

array|string: ["array", "of", "units"]|"unit"

以下を前提とします

["px", "em", "deg"]

次のパターンは問題とみなされます

a { width: 100%; }
a { font-size: 10rem; }
a { animation: animation-name 5s ease; }

次のパターンは問題とはみなされません

a { font-size: 1.2em; }
a { line-height: 1.2; }
a { height: 100px; }
a { height: 100PX; }
a { transform: rotate(30deg); }

オプションのセカンダリオプション

ignoreProperties: { "unit": ["property", "/regex/", /regex/]|"property"|"/regex/"|/regex/ }

指定されたプロパティを持つ宣言の値の単位を無視します。

たとえば、["px", "em"]の場合。

以下を前提とします

{
"rem": ["line-height", "/^border/"],
"%": ["width"]
}

次のパターンは問題とはみなされません

a { line-height: 0.1rem; }
a { border-bottom-width: 6rem; }
a { width: 100%; }

次のパターンは問題とみなされます

a { margin: 0 20rem; }
a { -moz-border-radius-topright: 20rem; }
a { height: 100%; }

ignoreFunctions: ["function", "/regex/", /regex/]|"function"|"/regex/"|/regex/

指定された関数内にある単位を無視します。

たとえば、["px", "em"]の場合。

以下を前提とします

["/^hsl/", "calc"]

次のパターンは問題とはみなされません

a {
border: 1px solid hsl(162deg, 51%, 35%, 0.8);
}
a {
background-image: linear-gradient(hsla(162deg, 51%, 35%, 0.8), hsla(62deg, 51%, 35%, 0.8));
}
a {
width: calc(100% - 10px);
}