Rule property-sort-order will enforce the order in which declarations are written.
Options
order: 'alphabetical', 'concentric', 'recess', 'smacss', or [array of properties] (defaults to alphabetical. Unknown properties are sorted alphabetically)
ignore-custom-properties: true/false (defaults to false)
When enabled (assuming order: alphabetical), the following are allowed:
.foo {
content:'baz';
height:100vh;
width:100vw;
}
When enabled (assuming order: alphabetical), the following are disallowed:
.foo {
width:100vw;
height:100vh;
content:'baz';
}
Custom Sort Orders
You have the option to create your own custom property sort orders. These are specified in your .sass-lint.yml file as below:
property-sort-order:
-1
-
order:
- border
- display
- color
When the custom order is specified as above, the following are allowed:
.foo {
border:1px solid blue;
display: block;
color:red;
}
When the custom order is specified as above, the following are disallowed:
.foo {
display: block;
color:red;
border:1px solid blue;
}
Ignore Custom Properties
When ignore-custom-properties: false (assume order: 'alphabetical') the following would be allowed
.foo {
border:1px solid blue;
color:red;
composes: heading;
display: block;
}
When ignore-custom-properties: false (assume order: 'alphabetical') the following would be disallowed
.foo {
composes: heading;// not in alphabetical order
border:1px solid blue;
color:red;
display: block;
}
When ignore-custom-properties: true (assume order: 'alphabetical') the following would be allowed
.foo {
composes: heading;// custom properties ignored
border:1px solid blue;
color:red;
display: block;
}
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';
}
Clean Import Paths
Rule clean-import-paths will enforce whether or not @import paths should have leading underscores and/or filename extensions.
Options
leading-underscore: true/false (defaults to false)
filename-extension: true/false (defaults to false)
Examples
leading-underscore
When leading-underscore: false, the following are allowed. When leading-underscore: true, the following are disallowed:
@import'foo';
@import'bar/foo';
When leading-underscore: true, the following are allowed. When leading-underscore: false, the following are disallowed:
@import'_foo';
@import'_bar/foo';
filename-extension
When filename-extension: false, the following are allowed. When filename-extension: true, the following are disallowed:
@import'foo';
@import'bar/foo';
When filename-extension: true, the following are allowed. When filename-extension: false, the following are disallowed:
@import'foo.scss';
@import'bar/foo.scss';
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';
}
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';}
enforce the consistent use of either backticks, double, or single quotes (quotes)
JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example:
/*eslint-env es6*/
var double ="double";
var single ='single';
var backtick =`backtick`;// ES6 only
Each of these lines creates a string and, in some cases, can be used interchangeably. The choice of how to define strings in a codebase is a stylistic one outside of template literals (which allow embedded of expressions to be interpreted).
Many codebases require strings to be defined in a consistent manner.
Rule Details
This rule enforces the consistent use of either backticks, double, or single quotes.
Options
This rule has two options, a string option and an object option.
String option:
"double" (default) requires the use of double quotes wherever possible
"single" requires the use of single quotes wherever possible
"backtick" requires the use of backticks wherever possible
Object option:
"avoidEscape": true allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise
"allowTemplateLiterals": true allows strings to use backticks
Deprecated: The object property avoid-escape is deprecated; please use the object property avoidEscape instead.
double
Examples of incorrect code for this rule with the default "double" option:
/*eslint quotes: ["error", "double"]*/
var single ='single';
var unescaped ='a string containing "double" quotes';
var backtick =`back\ntick`;// you can use \n in single or double quoted strings
Examples of correct code for this rule with the default "double" option:
/*eslint quotes: ["error", "double"]*/
/*eslint-env es6*/
var double ="double";
var backtick =`back
tick`;// backticks are allowed due to newline
var backtick = tag`backtick`;// backticks are allowed due to tag
single
Examples of incorrect code for this rule with the "single" option:
/*eslint quotes: ["error", "single"]*/
var double ="double";
var unescaped ="a string containing 'single' quotes";
Examples of correct code for this rule with the "single" option:
/*eslint quotes: ["error", "single"]*/
/*eslint-env es6*/
var single ='single';
var backtick =`back${x}tick`;// backticks are allowed due to substitution
backticks
Examples of incorrect code for this rule with the "backtick" option:
/*eslint quotes: ["error", "backtick"]*/
var single ='single';
var double ="double";
var unescaped ='a string containing `backticks`';
Examples of correct code for this rule with the "backtick" option:
/*eslint quotes: ["error", "backtick"]*/
/*eslint-env es6*/
var backtick =`backtick`;
avoidEscape
Examples of additional correct code for this rule with the "double", { "avoidEscape": true } options:
{ "allowTemplateLiterals": false } will not disallow the usage of all template literals. If you want to forbid any instance of template literals, use no-restricted-syntax and target the TemplateLiteral selector.
When Not To Use It
If you do not need consistency in your string styles, you can safely disable this rule.
Source: http://eslint.org/docs/rules/
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: