media-query-no-invalid
禁止无效的媒体查询。
¥Disallow invalid media queries.
@media not(min-width: 300px) {}
/** ↑
* This media query */
根据 媒体查询级别 5 规范,媒体查询必须在语法上有效。
¥Media queries must be grammatically valid according to the Media Queries Level 5 specification.
此规则仅适用于 CSS。你不应该为类似 CSS 的语言(例如 Sass 或 Less)打开它,因为它们有自己的语法。
¥This rule is only appropriate for CSS. You should not turn it on for CSS-like languages, such as Sass or Less, as they have their own syntaxes.
它与验证功能名称和值的其他规则配合良好:
¥It works well with other rules that validate feature names and values:
message
次要选项 可以接受该规则的参数。
¥The message
secondary option can accept the arguments of this rule.
选项
¥Options
true
以下模式被视为问题:
¥The following patterns are considered problems:
@media not(min-width: 300px) {}
@media (width == 100px) {}
@media (color) and (hover) or (width) {}
以下模式不被视为问题:
¥The following patterns are not considered problems:
@media not (min-width: 300px) {}
@media (width = 100px) {}
@media ((color) and (hover)) or (width) {}
@media (color) and ((hover) or (width)) {}
可选的辅助选项
¥Optional secondary options
ignoreFunctions: ["/regex/", /regex/, "string"]
忽略指定的函数。
¥Ignore the specified functions.
鉴于:
¥Given:
["theme", "/^get.*$/"]
以下模式不被视为问题:
¥The following patterns are not considered problems:
@media (min-width: theme(screens.md)) {}
@media (max-width: get-default-width()) {}