清除 IDE 分析警告“无法在 scss 文件中为 mixin @content 指令中使用的变量找到变量”?

Clear IDE analysis warning `Cannot find variable` in scss file for variables used within a mixin @content directive?

我正在清理 theme.scss 文件中的所有分析警告。虽然我不确定如何清除这个...

我有一个名为 accent-colors@mixin,它只是通过 key/value 遍历 sass 颜色图,并用 @content 包装指令输入.accent-#{$key} 父 class 选择器。

@mixin accent-colors {
  @each $key, $value in $accent-colors {
    $accent-name: $key !global;
    $accent-color: $value !global;
    .accent-#{$key} & {
      @content
    }
  }
}

@mixin accent-colors 位于单独的文件 _mixins.scss 中,该文件使用 @import "mixins".

导入到 theme.scss

@content 指令允许通过 @include accent-colors { }

将变量传递给它

这是一个例子...

.button
  @include accent-colors {
    color: $accent-color;
  }
}

上面的 sass 代码工作正常,但我在 theme.scss 文件的 IDE (phpstorm) 中收到此分析警告...

有没有办法在我的 theme.scss 文件中抑制这个 IDE 分析警告?


非常感谢

您可以通过评论抑制它:

.button {
  //noinspection SassScssUnresolvedVariable
  @include accent-colors {
    color: $accent-color;
  }
}

https://www.jetbrains.com/help/phpstorm/disabling-and-enabling-inspections.html#suppress-in-editor