Skip to main content

no-invalid-double-slash-comments

禁止无效的双斜杠注释。

¥Disallow invalid double-slash comments.

a {
//color: pink;
}
/** ↑

* This comment */

CSS 和 可能会导致意想不到的结果 不支持禁止双斜杠注释 (//...)。

¥Disallow double-slash comments (//...) are not supported by CSS and could lead to unexpected results.

如果你使用的预处理器允许 // 单行注释(例如 Sass、Less、Stylus),则此规则不会诉说这些。它们由预处理器编译成标准 CSS 注释,因此 Stylelint 会认为它们有效。该规则仅诉说在常规 CSS 中使用 // 到 "注释掉" 单行代码的鲜为人知的方法。(如果你不知道这是可能的,请查看 "CSS 中的单行注释 (//)")。

¥If you are using a preprocessor that allows // single-line comments (e.g. Sass, Less, Stylus), this rule will not complain about those. They are compiled into standard CSS comments by your preprocessor, so Stylelint will consider them valid. This rule only complains about the lesser-known method of using // to "comment out" a single-line of code in regular CSS. (If you didn't know this was possible, have a look at "Single Line Comments (//) in CSS").

选项

¥Options

true

以下模式被视为问题:

¥The following patterns are considered problems:

a {
//color: pink;
}
//a { color: pink; }
// Comment {}
a {
color: pink;
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
/* color: pink; */
}
/* a { color: pink;  } */