Sha256: 4bc3864b2211290b6bf56746047b941830846e76135612ec292b19b9b767fe64

Contents?: true

Size: 1.84 KB

Versions: 24

Compression:

Stored size: 1.84 KB

Contents

# no-duplicate-dollar-variables

Disallow duplicate dollar variables within a stylesheet.

```scss
$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](https://sass-lang.com/documentation/variables#shadowing)). Two dollar variables are not duplicates if their scopes are unrelated.

```scss
.one {
  $a: 1;
  /** ↑
   * Not a duplicate */
}
.two {
  $a: 2;
  /** ↑
   * Not a duplicate */
}
```

## Options

### `true`

The following patterns are considered violations:

```scss
$a: 1;
$a: 2;
```

```scss
$a: 1;
$b: 2;
$a: 3;
```

```scss
$a: 1;
.b {
  $a: 1;
}
```

```scss
$a: 1;
.b {
  .c {
    $a: 1;
  }
}
```

```scss
$a: 1;
@mixin b {
  $a: 1;
}
```

The following patterns are _not_ considered violations:

```scss
$a: 1;
$b: 2;
```

```scss
$a: 1;
.b {
  $b: 2;
}
```

### `ignoreInside: ["at-rule", "nested-at-rule"]`

#### `"at-rule"`

Ignores dollar variables that are inside both nested and non-nested at-rules (`@media`, `@mixin`, etc.).

Given:

```json
{ "ignoreInside": ["at-rule"] }
```

The following patterns are _not_ considered warnings:

```scss
$a: 1;
@mixin c {
  $a: 1;
}
```

```scss
$a: 1;
.b {
  @mixin c {
    $a: 1;
  }
}
```

#### `"nested-at-rule"`

Ignores dollar variables that are inside nested at-rules (`@media`, `@mixin`, etc.).

Given:

```json
{ "ignoreInside": ["nested-at-rule"] }
```

The following patterns are _not_ considered warnings:

```scss
$a: 1;
.b {
  @mixin c {
    $a: 1;
  }
}
```

### `ignoreInsideAtRules: ["array", "of", "at-rules"]`

Ignores all variables that are inside specified at-rules.

Given:

```json
{ "ignoreInsideAtRules": ["if", "mixin"] }
```

The following patterns are _not_ considered warnings:

```scss
$a: 1;

@mixin b {
  $a: 2;
}
```

```scss
$a: 1;

@if (true) {
  $a: 2;
}
```

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-4.1.8 node_modules/stylelint-scss/src/rules/no-duplicate-dollar-variables/README.md
trusty-cms-4.1.7 node_modules/stylelint-scss/src/rules/no-duplicate-dollar-variables/README.md
trusty-cms-4.1.6 node_modules/stylelint-scss/src/rules/no-duplicate-dollar-variables/README.md
trusty-cms-4.1.5 node_modules/stylelint-scss/src/rules/no-duplicate-dollar-variables/README.md