stylelint-scss
Version:
A collection of SCSS-specific rules for Stylelint
203 lines (152 loc) • 2.5 kB
Markdown
# dollar-variable-first-in-block
Require `$`-variable declarations to be placed first in a block (root or a rule).
## Options
### `true`
The following patterns are considered violations:
```scss
"1.css";
$var: 200px;
```
```scss
a {
width: 100px;
$var: 1;
}
```
The following patterns are _not_ considered warnings:
```scss
$var: 100px;
"1.css";
```
```scss
a {
$var: 1;
color: red;
}
```
## Optional secondary options
### `ignore: ["comments", "imports"]`
### `"comments"`
The following patterns are _not_ considered violations:
```scss
// Comment
$var: 1;
```
```scss
a {
// Comment
$var: 1;
color: red;
}
```
### `"imports"`
The following patterns are _not_ considered violations:
```scss
"1.css";
$var: 1;
```
```scss
"sass:color";
$primary-color: #f26e21 !default;
$secondary-color: color.change($primary-color, $alpha: 0.08) !default;
```
```scss
"src/list";
$var1: 100px;
```
### `except: ["root", "at-rule", "function", "mixin", "if-else", "loops"]`
### `"root"`
The following patterns are _not_ considered warnings:
```scss
// Imports
"1.css";
// Variables
$var: 1;
```
```scss
/* Imports */
"1.css";
// Variables
$var1: 1;
$var2: 1;
a {
width: 100px;
}
```
### `"at-rule"`
The following patterns are _not_ considered warnings:
```scss
-root .class {
width: 100px;
$var: 1;
}
```
### `"function"`
The following patterns are _not_ considered warnings:
```scss
function-name($numbers1, $numbers2) {
$var1: 1;
$number in $numbers1 {
$var1: $var1 + $number;
}
$var: 2;
$number in $numbers2 {
$var2: $var2 + $number;
}
$var1 + $var2;
}
```
### `"mixin"`
The following patterns are _not_ considered warnings:
```scss
mixin-name {
width: 100px;
$var: 1000px;
height: $var1;
}
```
### `"if-else"`
The following patterns are _not_ considered warnings:
```scss
$direction == up {
width: 100px;
$var: 1000px;
}
```
```scss
$direction == up {
width: 100px;
} {
height: 100px;
$var: 1000px;
}
```
```scss
$direction == up {
width: 100px;
$var1: 1000px;
} {
height: 100px;
$var2: 1000px;
}
```
### `"loops"`
The following patterns are _not_ considered warnings:
```scss
$size in $sizes {
width: 100px;
$var: 1000px;
}
```
```scss
$i from 1 through 3 {
width: 100px;
$var: 1000px;
}
```
```scss
$value > $base {
width: 100px;
$var: 1000px;
}
```