function-linear-gradient-no-nonstandard-direction
禁止线性梯度函数使用非标准方向值。
¥Disallow non-standard direction values for linear gradient functions.
.foo { background: linear-gradient(to top, #fff, #000); }
/** ↑
* This (optional) first argument is the "direction" */
有效且标准的方向值是以下之一:
¥A valid and standard direction value is one of the following:
-
一个角度
¥an angle
-
to加一个边或角(to top、to bottom、to left、to right;to top right、to right top、to bottom left等)¥
toplus a side-or-corner (to top,to bottom,to left,to right;to top right,to right top,to bottom left, etc.)
一个常见的错误(匹配过时的非标准语法)是仅使用边或角而不使用前面的 to。
¥A common mistake (matching outdated non-standard syntax) is to use just a side-or-corner without the preceding to.
此规则与以下内容重叠:
¥This rule overlaps with:
我们建议对 CSS 使用这些规则,对类似 CSS 的语言(例如 SCSS 和 Less)使用此规则。
¥We recommend using these rules for CSS and this rule for CSS-like languages, such as SCSS and Less.
选项
¥Options
true
{
"function-linear-gradient-no-nonstandard-direction": true
}
以下模式被视为问题:
¥The following patterns are considered problems:
.foo { background: linear-gradient(top, #fff, #000); }
.foo { background: linear-gradient(bottom, #fff, #000); }
.foo { background: linear-gradient(left, #fff, #000); }
.foo { background: linear-gradient(45, #fff, #000); }
.foo { background: linear-gradient(to top top, #fff, #000); }
以下模式不被视为问题:
¥The following patterns are not considered problems:
.foo { background: linear-gradient(to top, #fff, #000); }
.foo { background: linear-gradient(to bottom right, #fff, #000); }
.foo { background: linear-gradient(45deg, #fff, #000); }
.foo { background: linear-gradient(1.57rad, #fff, #000); }
/* Direction defaults to "to bottom" */
.foo { background: linear-gradient(#fff, #000); }