Disallow duplicate dollar variables within a stylesheet.
$a: 1;
$a: 2;
/** ↑
* These are duplicates */
A dollar variable is considered a duplicate if it shadows a variable of the same name (see the Sass documentation). Two dollar variables are not duplicates if their scopes are unrelated.
.one {
$a: 1;
/** ↑
* Not a duplicate */
}
.two {
$a: 2;
/** ↑
* Not a duplicate */
}
A dollar variable is not considered a duplicate if it contains the !default
keyword (see the Sass documentation). Two dollar variables are duplicates if they both contain !default
keyword.
$a: 1;
$a: 5 !default;
/** ↑
* Not a duplicate */
$b: 1 !default;
$b: 5 !default;
/** ↑
* These are duplicates */
The following patterns are considered violations:
$a: 1;
$a: 2;
$a: 1;
$b: 2;
$a: 3;
$a: 1;
.b {
$a: 1;
}
$a: 1;
.b {
.c {
$a: 1;
}
}
$a: 1;
@mixin b {
$a: 1;
}
The following patterns are not considered violations:
$a: 1;
$b: 2;
$a: 1;
.b {
$b: 2;
}
Ignores dollar variables that are inside both nested and non-nested at-rules (@media
, @mixin
, etc.).
Given:
{ "ignoreInside": ["at-rule"] }
The following patterns are not considered warnings:
$a: 1;
@mixin c {
$a: 1;
}
$a: 1;
.b {
@mixin c {
$a: 1;
}
}
Ignores dollar variables that are inside nested at-rules (@media
, @mixin
, etc.).
Given:
{ "ignoreInside": ["nested-at-rule"] }
The following patterns are not considered warnings:
$a: 1;
.b {
@mixin c {
$a: 1;
}
}
Ignores all variables that are inside specified at-rules.
Given:
{ "ignoreInsideAtRules": ["if", "mixin"] }
The following patterns are not considered warnings:
$a: 1;
@mixin b {
$a: 2;
}
$a: 1;
@if (true) {
$a: 2;
}
Ignore all variables containing the !default
keyword.
Given:
{ "ignoreDefaults": true }
The following patterns are not considered warnings:
$a: 5 !default;
$a: $a + 1;
$a: 15 !default;
Given:
{ "ignoreDefaults": false }
The following patterns are considered warnings:
$a: 5 !default;
$a: 1;