You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stylelint order/order报错:声明应位于规则之前问题咨询

报错含义

Expected declaration to come before rule - order/order 是Stylelint排序插件stylelint-order抛出的校验错误,规则要求:同一选择器的代码块内,当前选择器自身的CSS属性声明,必须书写在嵌套规则、@规则之前,不能穿插在规则后面。
你的代码中,在嵌套子规则img {width: 10rem;}之后才写margin-bottom: spacing("single");这个自身属性声明,不符合排序要求,因此报错指向该行。

修复方式

把当前选择器的所有普通属性声明,统一挪到嵌套规则、@规则的前面即可,修正后代码如下:

.home-feat2 {
    background-color: stencilColor("color-greyLight");
    margin-bottom: spacing("single");
    img {width: 10rem;}
    @include breakpoint("medium") {
        margin-bottom: 3rem;
    }
}

符合该规则的SCSS代码块常规书写顺序为:

  • 当前选择器的所有CSS属性声明
  • 嵌套的子选择器规则
  • 媒体查询、mixin调用等@规则

内容的提问来源于stack exchange,提问作者Deo3560

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.31 21:18:21