清除 scss 文件中针对 mixin @content 指令中使用的变量的 IDE 分析警告“找不到变量”?

问题描述

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

我有一个名为 @mixinaccent-colors,它简单地按键/值循环遍历颜色的 sass 映射,并使用 @content 父类包装 .accent-#{$key} 指令输入选择器。

@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 中,该文件使用 theme.scss 导入到 @import "mixins" 中。

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

这是一个例子...

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

上述 sass 代码运行良好,但我在 IDE (phpstorm) 的 theme.scss 文件中收到此分析警告...

enter image description here

有没有办法在我的 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