Stylelint - 第一个嵌套块之前的新行

Stylelint - new line before first nested block

如何使用 stylelint 'rule-empty-line-before' 只为第一个嵌套块生成新行:

示例:

a {
    margin: 0;
    padding: 0;

    b {
       margin: 0;
    }
    c {
      margin: 0;
    }
}

以下向所有嵌套块添加新行:

"rule-empty-line-before": [
            "never-multi-line",
            {
                "except": ["inside-block"]
            }
        ],

您可以使用以下方式强制执行此约定:

"rule-empty-line-before": [
  "always", {
    "except": ["inside-block-and-after-rule"]
  }
],

来自文档的 "About rules" section

We recommend that you set your primary option (e.g. "always" or "never") to whatever is your most common occurrence and define your exceptions with the except optional secondary options.

在您的案例中最常见的情况是 "always",块内的规则和另一条规则之后的规则是例外。 (inside-block-and-after-rule 辅助选项记录在 in the rule README 中。)