Skip to content

Latest commit

 

History

History
118 lines (84 loc) · 1.9 KB

double-slash-comment-inline.md

File metadata and controls

118 lines (84 loc) · 1.9 KB

Pattern: Malformed //-comment as inline comment

Issue: -

Description

Require or disallow //-comments to be inline comments.

a {
  width: 10px; // inline-comment
/*
 * Such comments */

An inline comment in terms of this rule is a comment that is placed on the same line with any other code, either before or after it.

This rule only works with SCSS-like single-line comments and ignores CSS comments (/* */).

Examples

string: "always"|"never"

"always"

//-comments must always be inline comments.

The following patterns are considered warnings:

// comment
a { width: 10px; }
a {
  // comment
  width: 10px;
}

The following patterns are not considered warnings:

a { // comment
  width: 10px;
}
a {
  width: 10px; // comment
}
a, // comment
b {
  width: 10px;
}

"never"

//-comments must never be inline comments.

The following patterns are considered warnings:

a {
  width: 10px; // comment
}
a, // comment
b {
  width: 10px;
}

The following patterns are not considered warnings:

// comment
a { width: 10px; }
a {
  // comment
  width: 10px;
}

Configuration

ignore: ["stylelint-commands"]

"stylelint-commands"

Ignore //-comments that deliver commands to stylelint, e.g. // stylelint-disable color-no-hex.

For example, with "always":

The following patterns are not considered warnings:

a {
  background: pink;
  // stylelint-disable color-no-hex
  color: pink;
}

Further Reading