跳到主要内容

SCSS 规则

// stylelint.config.js

module.exports = {
extends: [
'stylelint-config-twbs-bootstrap',
],
};
注意

stylelint 规则参考 stylelint-config-twbs-bootstrap,但是由于需要整理的内容非常多,在开发过程中,仍以实际的 stylelint 检查为准。本章内容仅供参考

规则一览

提示

SCSS 的 stylelint 规则继承于 CSS 规则

危险

使用 .scss 语法,永远不要使用原始的 .sass 语法!

来源规则名称配置值描述
stylelint-config-recommended-scssannotation-no-unknownnull禁止未知的注解
stylelint-config-recommended-scssat-rule-no-unknownnull禁止未知的 at 规则
stylelint-config-recommended-scsscomment-no-emptynull禁止空注释
stylelint-config-recommended-scssfunction-no-unknownnull禁止未知的函数
stylelint-config-recommended-scssmedia-query-no-invalidnull禁止无效的媒体查询
stylelint-config-recommended-scssscss/at-rule-no-unknowntrue禁止未知的 SCSS at 规则
stylelint-config-recommended-scssscss/declaration-nested-properties-no-divided-groupstrue禁止嵌套属性被分成多个组
stylelint-config-recommended-scssscss/dollar-variable-no-missing-interpolationtrue禁止缺少插值的美元变量
stylelint-config-recommended-scssscss/function-unquote-no-unquoted-strings-insidetrue在 unquote 函数中禁止未引号的字符串 inside
stylelint-config-recommended-scssscss/load-no-partial-leading-underscoretrue禁止加载带有前导下划线的部分文件
stylelint-config-recommended-scssscss/load-partial-extension'never'禁止部分文件扩展名
stylelint-config-recommended-scssscss/no-duplicate-mixinstrue禁止重复的 mixin
stylelint-config-recommended-scssscss/operator-no-newline-aftertrue禁止操作符后换行
stylelint-config-recommended-scssscss/operator-no-newline-beforetrue禁止操作符前换行
stylelint-config-recommended-scssscss/operator-no-unspacedtrue禁止操作符没有空格
stylelint-config-standard-scssat-rule-empty-line-before["always", {"except": ["blockless-after-blockless", "first-nested"], "ignore": ["after-comment"], "ignoreAtRules": ["else"]}]at 规则前需要空行
stylelint-config-standard-scssimport-notation'string'导入 notation 使用字符串
stylelint-config-standard-scssscss/at-else-closing-brace-newline-after'always-last-in-chain'else 关闭括号后换行
stylelint-config-standard-scssscss/at-else-closing-brace-space-after'always-intermediate'else 关闭括号后空格
stylelint-config-standard-scssscss/at-else-empty-line-before'never'else 前禁止空行
stylelint-config-standard-scssscss/at-else-if-parentheses-space-before'always'else if 括号前空格
stylelint-config-standard-scssscss/at-function-parentheses-space-before'never'函数括号前禁止空格
stylelint-config-standard-scssscss/at-function-pattern["^(-?[a-z][a-z0-9]*)(-[a-z0-9]+)*$"]函数名称模式
stylelint-config-standard-scssscss/at-mixin-parentheses-space-before'never'mixin 括号前禁止空格
stylelint-config-standard-scssscss/dollar-variable-colon-space-before'never'美元变量冒号前禁止空格
stylelint-config-standard-scssscss/dollar-variable-pattern["^(-?[a-z][a-z0-9]*)(-[a-z0-9]+)*$"]美元变量名称模式
stylelint-config-standard-scssscss/percent-placeholder-pattern["^(-?[a-z][a-z0-9]*)(-[a-z0-9]+)*$"]占位符模式
stylelint-config-twbs-bootstrapno-invalid-position-at-import-rulenull禁止无效位置的 @import 规则
stylelint-config-twbs-bootstrapscss/at-extend-no-missing-placeholdernull禁止 extend 缺少占位符
stylelint-config-twbs-bootstrapscss/at-function-named-arguments'never'禁止函数使用命名参数
stylelint-config-twbs-bootstrapscss/at-if-closing-brace-newline-afternullif 关闭括号后换行
stylelint-config-twbs-bootstrapscss/at-if-closing-brace-space-afternullif 关闭括号后空格
stylelint-config-twbs-bootstrapscss/at-if-no-nullnull禁止 if 中使用 null
stylelint-config-twbs-bootstrapscss/at-mixin-argumentless-call-parentheses'always'无参数 mixin 调用时需要括号
stylelint-config-twbs-bootstrapscss/at-mixin-patternnullmixin 名称模式
stylelint-config-twbs-bootstrapscss/at-rule-conditional-no-parenthesesnull条件 at 规则禁止括号
stylelint-config-twbs-bootstrapscss/comment-no-emptynull禁止空注释
stylelint-config-twbs-bootstrapscss/dimension-no-non-numeric-valuestrue禁止尺寸使用非数字值
stylelint-config-twbs-bootstrapscss/dollar-variable-colon-space-after'at-least-one-space'美元变量冒号后至少一个空格
stylelint-config-twbs-bootstrapscss/dollar-variable-empty-line-beforenull美元变量前空行
stylelint-config-twbs-bootstrapscss/double-slash-comment-empty-line-beforenull双斜杠注释前空行
stylelint-config-twbs-bootstrapscss/double-slash-comment-whitespace-insidenull双斜杠注释内部空格
stylelint-config-twbs-bootstrapscss/function-quote-no-quoted-strings-insidenull在 quote 函数中禁止引号字符串 inside
stylelint-config-twbs-bootstrapscss/media-feature-value-dollar-variablenull媒体特征值使用美元变量
stylelint-config-twbs-bootstrapscss/no-global-function-namesnull禁止全局函数名
stylelint-config-twbs-bootstrapscss/selector-no-redundant-nesting-selectortrue禁止冗余的嵌套选择器

Vue 专属规则

// stylelint.config.js

module.exports = {
extends: [
'stylelint-config-recommended-vue/scss',
],
};
来源规则名称配置值描述
stylelint-config-recommended-vueselector-pseudo-class-no-unknown[true, { ignorePseudoClasses: ["deep", "global", "slotted"] }]禁止未知的伪类选择器,但忽略 Vue 特定的伪类(如 deepglobalslotted
stylelint-config-recommended-vueselector-pseudo-element-no-unknown[true, { ignorePseudoElements: ["v-deep", "v-global", "v-slotted"] }]禁止未知的伪元素选择器,但忽略 Vue 特定的伪元素(如 v-deepv-globalv-slotted