Rule no-css-comments will enforce the use of Sass single-line comments and disallow CSS comments. Bang comments (/*! */, will be printed even in minified mode) are still allowed.
Examples
When enabled the following are allowed:
// This is a good comment
// =========
// This is a good comment
// =========
//////////////////
// This is a good comment
//////////////////
/*! This is a good bang comment */
/*!
* This is a good bang comment
**/
When enabled the following are disallowed:
/* This comment will appear in your compiled css */
/*
* Mulitline comments are bad
*/
Hex Length
Rule hex-length will enforce the length of hexadecimal values
Options
style: short/long (defaults to short)
Examples
When style: short, the following are allowed. When style: long, the following are disallowed:
$foo-color:#456;
.bar {
background:linear-gradient(top,#3ff,#ddd);
}
.baz {
color:#fff;
}
When style: long, the following are allowed. When style: short, the following are disallowed:
$foo-color:#445566;
.bar {
background:linear-gradient(top,#33ffff,#dddddd);
}
.baz {
color:#ffffff;
}
In both cases the following will be allowed as the values cannot be shortened:
$quz-color:#abcdef;
.qux {
color:#123456;
}
Class Name Format
Rule class-name-format will enforce a convention for class names.
Options
allow-leading-underscore: true/false (defaults to true)
convention: 'hyphenatedlowercase' (default), camelcase, snakecase, strictbem,
hyphenatedbem,
or a Regular Expression that the class name must match (e.g. ^[_A-Z]+$)
convention-explanation: Custom explanation to display to the user if a class doesn't adhere to the convention
This rule is triggered on any header that has a punctuation character as the
last character in the line:
# This is a header.
To fix this, remove any trailing punctuation:
# This is a header
Note: The punctuation parameter can be used to specify what characters class
as punctuation at the end of the header. For example, you can set it to
'.,;:!' to allow headers with question marks in them, such as might be used
in an FAQ.
MD022 - Headers should be surrounded by blank lines
Tags: headers, blank_lines
Aliases: blanks-around-headers
This rule is triggered when headers (any style) are either not preceded or not
followed by a blank line:
# Header 1
Some text
Some more text
## Header 2
To fix this, ensure that all headers have a blank line both before and after
(except where the header is at the beginning or end of the document):
# Header 1
Some text
Some more text
## Header 2
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
not parse headers that don't have a blank line before, and will parse them as
regular text.
No Color Literals
Rule no-color-literals will disallow the use of color literals and basic color functions in any declarations other than variables or maps/lists.
The list of affected color functions are as follows:
* rgb
* rgba
* hsl
* hsla
Other color functions, such as adjust-color and mix, may be used, but the original color must be passed in as a variable.
Options
allow-map-identifiers: true/false (defaults to true)
allow-rgba: true/false (defaults to false)
allow-variable-identifiers: true/false (defaults to true)
Examples
When enabled and default options are used the following are disallowed.
.literal {
color:mediumslateblue;
}
.linear-gradient-func {
background:linear-gradient(top,#fff,white);
}
.box-shadow {
box-shadow:1px1pxblack,1px1pxblack;
}
.background {
background:1px solid white;
}
.hex {
color:#fff;
}
// rgb function passed directly as function argument
.adj {
color:adjust-color(rgb(255,0,0),$blue:5);
}
// hsl function passed directly as function argument
When enabled and allow-rgba is set to true, the following will be allowed:
// rgba in variables is still fine
$rgba:rgba(255,0,0,.5);
$red:rgb(255,255,255,);
// rgba can be used directly to alter a variables opacity
.color {
color:rgba($red,.3);
}
In addition, when enabled and allow-rgba is set to true, the following will be disallowed:
.color {
// you must use variables and not literals
color:rgba(0,0,0,.3);
color:rgba(black,.3);
}
[allow-variable-identifiers: false]
When enabled and allow-variable-identifiers is set to false, the following will be disallowed
// variable uses a color literal as an identifier
$black:#000
// variable using a color literal as an identifier is passed to a function
.test {
color:adjust-color($off-red,$blue:5)
}
When enabled and allow-variable-identifiers is set to false, the following will be allowed
// variable not directly using a color literal as an identifier
$primary-black:#000
[allow-map-identifiers: false]
When enabled and allow-map-identifiers is set to false, the following will be disallowed
// map identifiers red, blue and orange share their name with a
// color literal and therefore shouldn't be used
$colors:(
red:#f00,
blue:(
orange:$orange
)
)
When enabled and allow-map-identifiers is set to false, the following will be allowed
$colors:(
primary-red:#f00,
map-blue:(
off-orange:$orange
)
)
Empty Line Between Blocks
Rule empty-line-between-blocks will enforce whether or not nested blocks should include a space between the last non-comment declaration or not.
Options
include: true/false (defaults to true)
allow-single-line-rulesets: true/false (defaults to true)
Examples
include
When include: true, the following are allowed. When include: false, the following are disallowed:
.foo {
content:'foo';
.bar {
content:'bar';
// Waldo
&--baz {
content:'baz';
}
}
}
When include: false, the following are allowed. When include: true, the following are disallowed:
.foo {
content:'foo';
.bar {
content:'bar';
// Waldo
&--baz {
content:'baz';
}
}
}
allow-single-line-rulesets
When allow-single-line-rulesets: true, the following are allowed. When allow-single-line-rulesets: false, the following are disallowed:
.foo {content:'foo';}
.bar {content:'bar';}
.baz {content:'baz';}
Empty Line Between Blocks
Rule empty-line-between-blocks will enforce whether or not nested blocks should include a space between the last non-comment declaration or not.
Options
include: true/false (defaults to true)
allow-single-line-rulesets: true/false (defaults to true)
Examples
include
When include: true, the following are allowed. When include: false, the following are disallowed:
.foo {
content:'foo';
.bar {
content:'bar';
// Waldo
&--baz {
content:'baz';
}
}
}
When include: false, the following are allowed. When include: true, the following are disallowed:
.foo {
content:'foo';
.bar {
content:'bar';
// Waldo
&--baz {
content:'baz';
}
}
}
allow-single-line-rulesets
When allow-single-line-rulesets: true, the following are allowed. When allow-single-line-rulesets: false, the following are disallowed:
.foo {content:'foo';}
.bar {content:'bar';}
.baz {content:'baz';}
Class Name Format
Rule class-name-format will enforce a convention for class names.
Options
allow-leading-underscore: true/false (defaults to true)
convention: 'hyphenatedlowercase' (default), camelcase, snakecase, strictbem,
hyphenatedbem,
or a Regular Expression that the class name must match (e.g. ^[_A-Z]+$)
convention-explanation: Custom explanation to display to the user if a class doesn't adhere to the convention
This rule is triggered on any header that has a punctuation character as the
last character in the line:
# This is a header.
To fix this, remove any trailing punctuation:
# This is a header
Note: The punctuation parameter can be used to specify what characters class
as punctuation at the end of the header. For example, you can set it to
'.,;:!' to allow headers with question marks in them, such as might be used
in an FAQ.
Leading Zero
Rule leading-zero will enforce whether or not decimal numbers should include a leading zero.
Options
include: true/false (defaults to false)
Examples
When include: false, the following are allowed. When include: true, the following are disallowed:
.foo {
font-size:.5em;
}
When include: true, the following are allowed. When include: false, the following are disallowed:
.foo {
font-size:0.5em;
}
No Color Literals
Rule no-color-literals will disallow the use of color literals and basic color functions in any declarations other than variables or maps/lists.
The list of affected color functions are as follows:
* rgb
* rgba
* hsl
* hsla
Other color functions, such as adjust-color and mix, may be used, but the original color must be passed in as a variable.
Options
allow-map-identifiers: true/false (defaults to true)
allow-rgba: true/false (defaults to false)
allow-variable-identifiers: true/false (defaults to true)
Examples
When enabled and default options are used the following are disallowed.
.literal {
color:mediumslateblue;
}
.linear-gradient-func {
background:linear-gradient(top,#fff,white);
}
.box-shadow {
box-shadow:1px1pxblack,1px1pxblack;
}
.background {
background:1px solid white;
}
.hex {
color:#fff;
}
// rgb function passed directly as function argument
.adj {
color:adjust-color(rgb(255,0,0),$blue:5);
}
// hsl function passed directly as function argument
When enabled and allow-rgba is set to true, the following will be allowed:
// rgba in variables is still fine
$rgba:rgba(255,0,0,.5);
$red:rgb(255,255,255,);
// rgba can be used directly to alter a variables opacity
.color {
color:rgba($red,.3);
}
In addition, when enabled and allow-rgba is set to true, the following will be disallowed:
.color {
// you must use variables and not literals
color:rgba(0,0,0,.3);
color:rgba(black,.3);
}
[allow-variable-identifiers: false]
When enabled and allow-variable-identifiers is set to false, the following will be disallowed
// variable uses a color literal as an identifier
$black:#000
// variable using a color literal as an identifier is passed to a function
.test {
color:adjust-color($off-red,$blue:5)
}
When enabled and allow-variable-identifiers is set to false, the following will be allowed
// variable not directly using a color literal as an identifier
$primary-black:#000
[allow-map-identifiers: false]
When enabled and allow-map-identifiers is set to false, the following will be disallowed
// map identifiers red, blue and orange share their name with a
// color literal and therefore shouldn't be used
$colors:(
red:#f00,
blue:(
orange:$orange
)
)
When enabled and allow-map-identifiers is set to false, the following will be allowed
$colors:(
primary-red:#f00,
map-blue:(
off-orange:$orange
)
)
Class Name Format
Rule class-name-format will enforce a convention for class names.
Options
allow-leading-underscore: true/false (defaults to true)
convention: 'hyphenatedlowercase' (default), camelcase, snakecase, strictbem,
hyphenatedbem,
or a Regular Expression that the class name must match (e.g. ^[_A-Z]+$)
convention-explanation: Custom explanation to display to the user if a class doesn't adhere to the convention
Settings:
- convention: ^[_A-Z]+$
- convention-explanation: 'Class must contain only uppercase letters and underscores'
When enabled, the following are allowed:
.SCREAMING_SNAKE_CASE {
content:'';
}
.foo {
@extend .SCREAMING_SNAKE_CASE;
}
When enabled, the following are disallowed:
(Each line with a class will report Class must contain only uppercase letters and underscores when linted.)
.HYPHENATED-UPPERCASE {
content:'';
}
.snake_case {
content:'';
}
.foo {
@extend .camelCase;
}
Class Name Format
Rule class-name-format will enforce a convention for class names.
Options
allow-leading-underscore: true/false (defaults to true)
convention: 'hyphenatedlowercase' (default), camelcase, snakecase, strictbem,
hyphenatedbem,
or a Regular Expression that the class name must match (e.g. ^[_A-Z]+$)
convention-explanation: Custom explanation to display to the user if a class doesn't adhere to the convention
MD022 - Headers should be surrounded by blank lines
Tags: headers, blank_lines
Aliases: blanks-around-headers
This rule is triggered when headers (any style) are either not preceded or not
followed by a blank line:
# Header 1
Some text
Some more text
## Header 2
To fix this, ensure that all headers have a blank line both before and after
(except where the header is at the beginning or end of the document):
# Header 1
Some text
Some more text
## Header 2
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
not parse headers that don't have a blank line before, and will parse them as
regular text.
Single Line Per Selector
Rule single-line-per-selector will enforce whether selectors should be placed on a new line.
Examples
When enabled, the following are allowed:
.foo,
.bar {
content:'baz';
}
When enabled, the following are disallowed:
.foo, .bar {
content:'baz';
}
Leading Zero
Rule leading-zero will enforce whether or not decimal numbers should include a leading zero.
Options
include: true/false (defaults to false)
Examples
When include: false, the following are allowed. When include: true, the following are disallowed:
.foo {
font-size:.5em;
}
When include: true, the following are allowed. When include: false, the following are disallowed: