-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no-duplicate-dollar-variables doesn't respect scopes #277
Comments
Thanks! The way the rule was created is that it looks for variables in the whole stylesheet's scope. I think that the rule could be changed to be a bit more clever to not warn for your use case. So, this would warn (overwriting a variable from outer scope): $a: 1;
.foo {
$a: 2;
}
.bar {
$a: 3;
} ...but this would not warn (the variable is not defined in the outer scope): .foo {
$a: 2;
}
.bar {
$a: 3;
} |
Another false positive example I ran across today that might be a different use case @if $value == $light {
$ring-color: $dark;
} @else {
$ring-color: $value;
// ^^^^^^^^^^^ Unexpected duplicate dollar variable $ring-color (scss/no-duplicate-dollar-variables)
} and $ring-color: $value !default;
@if $value == $light {
$ring-color: $dark;
// ^^^^^^^^^^^ Unexpected duplicate dollar variable $ring-color (scss/no-duplicate-dollar-variables)
} |
@ChrisMBarr those are not actually false positives, to avoid that you can use the ignore options of the rule: |
This is now fixed in v3.15.0 Thanks everyone for helping out! |
WIth 3.18 the rule triggers:
I had assumed that the media query defines a scope. |
no-duplicate-dollar-variables
rule reports variables with the same name but declared in different scopes. The snippet below produces errorUnexpected duplicate dollar variable $padding-x scss/no-duplicate-dollar-variables
.For me it's pretty obvious that this shouldn't be reported. Am I wrong?
The text was updated successfully, but these errors were encountered: