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
相关产品推荐
相关产品推荐

