跳到主要内容

media-query-no-invalid

Disallow invalid media queries.

@media not(min-width: 300px) {}
/** ↑
* This media query */

Media queries must be grammatically valid according to the Media Queries Level 5 specification.

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:

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)) {}