declaration-property-value-allowed-list
在宣告中指定允許的屬性和值配對清單。
a { text-transform: uppercase; }
/** ↑ ↑
* These properties and these values */
message
次要選項 可以接受此規則的參數。
選項
物件
:{ "未加前綴屬性名稱": ["陣列", "值", "/正規表示法/", /正規表示法/]|"值"|"/正規表示法/"|/正規表示法/ }
如果在物件中找到屬性名稱,則僅允許列出的屬性值。此規則會針對所有不符合的值提出抱怨。(如果物件中未包含屬性名稱,則任何值都允許。)
如果屬性名稱以 "/"
圍繞(例如 "/^animation/"
),則會將其解譯為正規表示法。這允許輕鬆鎖定速記,例如:/^animation/
會符合 animation
、animation-duration
、animation-timing-function
等。
值也適用相同規則。請記住,正規表示法值會與宣告的整個值進行比對,而不是特定部分。例如,像 "10px solid rgba( 255 , 0 , 0 , 0.5 )"
這樣的值不會符合 "/^solid/"
(請注意行邊界的開頭),但會符合 "/\\s+solid\\s+/"
或 "/\\bsolid\\b/"
。
使用正規表示法比對時,請小心不要意外考慮引號字串值和 url()
引數。例如,"/red/"
會符合 "1px dotted red"
以及 "\"red\""
和 "white url(/mysite.com/red.png)"
等值。
已提供
{
"transform": ["/scale/"],
"whitespace": "nowrap",
"/color/": ["/^green/"]
}
以下模式被視為問題
a { whitespace: pre; }
a { transform: translate(1, 1); }
a { -webkit-transform: translate(1, 1); }
a { color: pink; }
a { background-color: pink; }
以下模式不會被視為問題
a { whitespace: nowrap; }
a { transform: scale(1, 1); }
a { -webkit-transform: scale(1, 1); }
a { color: green; }
a { background-color: green; }