1

I recently set up Stylelint to run through my stylesheets but there's an error it's throwing that I'd rather keep as-is:

enter image description here

The error is that I'm not using a single space before the { and while I'd like this to be true for most other instances for legibility I was hoping to keep this one.

Is it possible to either modify the rule to allow these sorts of indentation patterns or otherwise disable a rule for a block of CSS? The latter is not ideal but I'll take what I can get.

Otherwise I'll likely just ignore it.

4

1 回答 1

1

我认为有问题的规则是block-opening-brace-space-before

如果您只想在多行块的左大括号之前强制使用一个空格并忽略单行块,那么您可以使用规则的always-multi-line主要选项来执行此操作:

/* Enforce a single space before this opening brace */
a {
  color: red;
}

/* Don't enforce anything before this opening brace */
a    { color: red; }

但是,没有选项可以专门忽略单行关键帧声明块的左大括号。如果这是您想要的,请提出功能请求问题。

是否可以修改规则以允许这些缩进模式

您可以创建一个插件强制对齐每个 @keyframe 中单行关键帧声明块的左大括号。

否则禁用CSS块的规则?

您可以使用stylelint-disable命令关闭block-opening-brace-space-before此代码块的规则。

于 2017-05-18T23:11:16.117 回答