规则
¥Rules
有一百多个内置规则可以帮助你:
¥There are over one hundred built-in rules to help you:
我们在 标准配置 中启用了大部分规则 (✅),并且许多规则可以自动修复 (🔧)。
¥We turn on most of the rules in our standard config (✅) and many can be autofixed (🔧).
避免错误
¥Avoid errors
你可以使用这些 no 规则来避免错误。
¥You can avoid errors with these no rules.
已弃用
¥Deprecated
禁止使用这些 no-deprecated 规则的已弃用内容。
¥Disallow deprecated things with these no-deprecated rules.
at-rule-no-deprecated禁止使用已弃用的 at 规则。 | ✅ | 🔧 |
declaration-property-value-keyword-no-deprecated禁止在声明中对属性使用弃用的关键字。 | ✅ | 🔧 |
media-type-no-deprecated禁止使用已弃用的媒体类型。 | ✅ | |
property-no-deprecated禁止使用已弃用的属性。 | ✅ | 🔧 |
降序
¥Descending
禁止使用这些 no-descending 规则进行降序操作。
¥Disallow descending things with these no-descending rules.
no-descending-specificity禁止较低特异性的选择器覆盖较高特异性的选择器。 | ✅ |
重复
¥Duplicate
不允许使用这些 no-duplicate 规则重复。
¥Disallow duplicates with these no-duplicate rules.
declaration-block-no-duplicate-custom-properties禁止声明块内出现重复的自定义属性。 | ✅ | |
declaration-block-no-duplicate-properties禁止声明块内出现重复的属性。 | ✅ | 🔧 |
font-family-no-duplicate-names禁止字体系列中出现重复的名称。 | ✅ | |
keyframe-block-no-duplicate-selectors禁止关键帧块内出现重复的选择器。 | ✅ | |
no-duplicate-at-import-rules禁止重复的 @import 规则。 | ✅ | |
no-duplicate-selectors禁止重复的选择器。 | ✅ |
空的
¥Empty
使用这些 no-empty 规则禁止空东西。
¥Disallow empty things with these no-empty rules.
block-no-empty禁止空块。 | ✅ | |
comment-no-empty禁止空注释。 | ✅ | |
no-empty-source禁止空源。 | ✅ |
无效的
¥Invalid
禁止使用这些(有时是隐式的)no-invalid 规则的无效语法。
¥Disallow invalid syntax with these (sometimes implicit) no-invalid rules.
at-rule-prelude-no-invalid禁止在规则中使用无效的前置词。 | ✅ | |
color-no-invalid-hex禁止无效的十六进制颜色。 | ||
function-calc-no-unspaced-operator不允许在 calc 函数中使用无效的无空格运算符。 | ✅ | 🔧 |
keyframe-declaration-no-important在关键帧声明中不允许使用无效的 !important。 | ✅ | |
media-query-no-invalid禁止无效的媒体查询。 | ✅ | |
named-grid-areas-no-invalid禁止无效的命名网格区域。 | ✅ | |
no-invalid-double-slash-comments禁止无效的双斜杠注释。 | ✅ | |
no-invalid-position-at-import-rule不允许无效的仓位 @import 规则。 | ✅ | |
no-invalid-position-declaration禁止无效的位置声明。 | ✅ | |
string-no-newline禁止字符串中无效的换行符。 | ✅ | |
syntax-string-no-invalid禁止无效语法字符串。 | ✅ |
不规律的
¥Irregular
用这些 no-irregular 规则禁止不规则的事情。
¥Disallow irregular things with these no-irregular rules.
no-irregular-whitespace禁止不规则的空白。 | ✅ |
丢失的
¥Missing
禁止使用这些 no-missing 规则丢失东西。
¥Disallow missing things with these no-missing rules.
custom-property-no-missing-var-function不允许自定义属性缺少 var 函数。 | ✅ | |
font-family-no-missing-generic-family-keyword禁止字体系列中缺少通用系列关键字。 | ✅ | |
nesting-selector-no-missing-scoping-root禁止嵌套选择器缺少作用域根。 | ✅ |
非标准的
¥Non-standard
禁止使用这些 no-nonstandard 规则的非标准事物。
¥Disallow non-standard things with these no-nonstandard rules.
function-linear-gradient-no-nonstandard-direction禁止线性梯度函数使用非标准方向值。 |
覆盖
¥Overrides
禁止使用这些 no-overrides 规则进行覆盖。
¥Disallow overrides with these no-overrides rules.
declaration-block-no-shorthand-property-overrides禁止速记属性覆盖相关的普通属性。 | ✅ |
不匹配的
¥Unmatchable
禁止与这些 no-unmatchable 规则不匹配的事物。
¥Disallow unmatchable things with these no-unmatchable rules.
selector-anb-no-unmatchable禁止不匹配的 An+B 选择器。 | ✅ |
未知
¥Unknown
使用这些 no-unknown 规则禁止未知事物。
¥Disallow unknown things with these no-unknown rules.
annotation-no-unknown禁止未知注释。 | ✅ | |
at-rule-descriptor-no-unknown禁止使用未知的 at 规则描述符。 | ✅ | |
at-rule-descriptor-value-no-unknown禁止在规则中使用未知的描述符值。 | ✅ | |
at-rule-no-unknown禁止未知的 at 规则。 | ✅ | |
declaration-property-value-no-unknown不允许声明中的属性具有未知值。 | ✅ | |
function-no-unknown禁止未知功能。 | ||
media-feature-name-no-unknown禁止未知的媒体功能名称。 | ✅ | |
media-feature-name-value-no-unknown禁止媒体特性使用未知值。 | ✅ | |
no-unknown-animations禁止未知动画。 | ||
no-unknown-custom-media禁止未知的自定义媒体查询。 | ||
no-unknown-custom-properties禁止未知的自定义属性。 | ||
property-no-unknown禁止未知属性。 | ✅ | |
selector-pseudo-class-no-unknown禁止未知的伪类选择器。 | ✅ | |
selector-pseudo-element-no-unknown禁止未知的伪元素选择器。 | ✅ | |
selector-type-no-unknown禁止未知类型选择器。 | ✅ | |
unit-no-unknown禁止未知单位。 |
执行约定
¥Enforce conventions
你可以使用这些 no 和 list 规则强制执行约定。它们是使代码保持一致的强大规则。你需要配置其中的大部分以满足你的需求。
¥You can enforce conventions with these no and list rules. They are powerful rules for making your code consistent. You'll need to configure most of them to suit your needs.
允许、禁止和必需
¥Allowed, disallowed & required
允许、禁止或要求具有这些 allowed-list、disallowed-list、required-list 和 no 规则的事物。
¥Allow, disallow or require things with these allowed-list, disallowed-list, required-list and no rules.
at 规则
¥At-rule
at-rule-allowed-list指定允许的 at 规则列表。 | ||
at-rule-disallowed-list指定不允许的 at 规则列表。 | ||
at-rule-no-vendor-prefix禁止 at 规则使用浏览器前缀。 | ✅ | 🔧 |
at-rule-property-required-list为规则指定必需属性(或描述符)的列表。 |
颜色
¥Color
color-hex-alpha要求或禁止十六进制颜色的 Alpha 通道。 | ||
color-named要求(如果可能)或不允许命名颜色。 | ||
color-no-hex禁止使用十六进制颜色。 |
注释
¥Comment
comment-word-disallowed-list指定注释中禁止使用的单词列表。 |
声明
¥Declaration
declaration-no-important禁止在声明中使用 !important。 | ||
declaration-property-unit-allowed-list指定声明中允许的属性和单元对的列表。 | ||
declaration-property-unit-disallowed-list指定声明中不允许的属性和单元对的列表。 | ||
declaration-property-value-allowed-list指定声明中允许的属性和值对的列表。 | ||
declaration-property-value-disallowed-list指定声明中不允许的属性和值对的列表。 |
函数
¥Function
function-allowed-list指定允许的功能列表。 | ||
function-disallowed-list指定不允许的功能列表。 | ||
function-url-no-scheme-relative禁止与方案相关的 URL。 | ||
function-url-scheme-allowed-list指定允许的 URL 方案列表。 | ||
function-url-scheme-disallowed-list指定不允许的 URL 方案列表。 |
长度
¥Length
length-zero-no-unit不允许零长度单位。 | ✅ | 🔧 |
媒体特性
¥Media feature
media-feature-name-allowed-list指定允许的媒体功能名称列表。 | ||
media-feature-name-disallowed-list指定禁止的媒体功能名称列表。 | ||
media-feature-name-no-vendor-prefix禁止媒体功能名称使用浏览器前缀。 | ✅ | 🔧 |
media-feature-name-unit-allowed-list指定媒体功能中允许的名称和单位对的列表。 | ||
media-feature-name-value-allowed-list指定允许的媒体功能名称和值对的列表。 |
属性
¥Property
property-allowed-list指定允许的属性列表。 | ||
property-disallowed-list指定不允许的属性列表。 | ||
property-no-vendor-prefix禁止属性使用浏览器前缀。 | ✅ | 🔧 |
规则
¥Rule
rule-nesting-at-rule-required-list要求规则嵌套在特定的 @ 规则中。 | ||
rule-selector-property-disallowed-list指定规则中选择器不允许的属性列表。 |
选择器
¥Selector
selector-attribute-name-disallowed-list指定不允许的属性名称列表。 | ||
selector-attribute-operator-allowed-list指定允许的属性运算符列表。 | ||
selector-attribute-operator-disallowed-list指定不允许的属性运算符列表。 | ||
selector-combinator-allowed-list指定允许的组合器列表。 | ||
selector-combinator-disallowed-list指定不允许的组合器列表。 | ||
selector-disallowed-list指定不允许的选择器列表。 | ||
selector-no-qualifying-type禁止按类型限定选择器。 | ||
selector-no-vendor-prefix禁止选择器使用浏览器前缀。 | ✅ | 🔧 |
selector-pseudo-class-allowed-list指定允许的伪类选择器的列表。 | ||
selector-pseudo-class-disallowed-list指定不允许的伪类选择器列表。 | ||
selector-pseudo-element-allowed-list指定允许的伪元素选择器的列表。 | ||
selector-pseudo-element-disallowed-list指定不允许的伪元素选择器的列表。 |
单位
¥Unit
unit-allowed-list指定允许的单位列表。 | ||
unit-disallowed-list指定不允许的单位列表。 |
值
¥Value
value-no-vendor-prefix不允许值使用浏览器前缀。 | ✅ | 🔧 |
大小写
¥Case
使用这些 case 规则指定单词的小写或大写。
¥Specify lowercase or uppercase for words with these case rules.
function-name-case指定函数名称的小写或大写。 | ✅ | 🔧 |
selector-type-case指定类型选择器的小写或大写。 | ✅ | 🔧 |
value-keyword-case指定关键字值的小写或大写。 | ✅ | 🔧 |
空行
¥Empty lines
使用这些 empty-line-before 规则在构造之前强制执行或禁止空行。
¥Enforce or disallow empty lines before constructs with these empty-line-before rules.
at-rule-empty-line-before要求或不允许 at 规则前有空行。 | ✅ | 🔧 |
comment-empty-line-before要求或禁止注释前有空行。 | ✅ | 🔧 |
custom-property-empty-line-before要求或禁止自定义属性前有空行。 | ✅ | 🔧 |
declaration-empty-line-before要求或不允许声明前有空行。 | ✅ | 🔧 |
rule-empty-line-before要求或不允许规则前有空行。 | ✅ | 🔧 |
最大和最小
¥Max & min
使用这些 max 和 min 规则应用限制。
¥Apply limits with these max and min rules.
declaration-block-single-line-max-declarations限制单行声明块内的声明数量。 | ✅ | |
declaration-property-max-values限制声明中属性列表的值的数量。 | ||
max-nesting-depth限制嵌套深度。 | ||
number-max-precision限制数字中允许的小数位数。 | ✅ | |
selector-max-attribute限制选择器中属性选择器的数量。 | ||
selector-max-class限制选择器中类的数量。 | ||
selector-max-combinators限制选择器中组合器的数量。 | ||
selector-max-compound-selectors限制选择器中复合选择器的数量。 | ||
selector-max-id限制一个选择器中 ID 选择器的数量。 | ||
selector-max-pseudo-class限制选择器中伪类的数量。 | ||
selector-max-specificity限制选择器的特殊性。 | ||
selector-max-type限制一个选择器中类型选择器的数量。 | ||
selector-max-universal限制一个选择器中通用选择器的数量。 | ||
time-min-milliseconds限制时间值的最小毫秒数。 |
符号
¥Notation
使用这些 notation(有时是隐含的)规则强制执行具有多个事物的一种表示形式。
¥Enforce one representation of things that have multiple with these notation (sometimes implicit) rules.
alpha-value-notation指定 alpha 值的百分比或数字表示法。 | ✅ | 🔧 |
color-function-alias-notation为颜色函数指定别名符号。 | ✅ | 🔧 |
color-function-notation指定颜色函数的现代或传统表示法。 | ✅ | 🔧 |
color-hex-length指定十六进制颜色的短或长表示法。 | ✅ | 🔧 |
font-weight-notation指定字体粗细的数字或命名符号。 | 🔧 | |
hue-degree-notation指定色调的数字或角度符号。 | ✅ | 🔧 |
import-notation为 @import 规则指定字符串或 URL 表示法。 | ✅ | 🔧 |
keyframe-selector-notation为关键帧选择器指定关键字或百分比表示法。 | ✅ | 🔧 |
lightness-notation指定亮度的数字或百分比符号。 | ✅ | 🔧 |
media-feature-range-notation指定媒体功能范围的上下文或前缀表示法。 | ✅ | 🔧 |
selector-not-notation为 :not() 伪类选择器指定简单或复杂的表示法。 | ✅ | 🔧 |
selector-pseudo-element-colon-notation为适用的伪元素选择器指定单冒号或双冒号表示法。 | ✅ | 🔧 |
模式
¥Pattern
使用这些 pattern 规则强制执行命名约定。
¥Enforce naming conventions with these pattern rules.
comment-pattern指定注释的模式。 | ||
container-name-pattern为容器名称指定模式。 | ✅ | |
custom-media-pattern指定自定义媒体查询名称的模式。 | ✅ | |
custom-property-pattern指定自定义属性的模式。 | ✅ | |
keyframes-name-pattern指定关键帧名称的模式。 | ✅ | |
layer-name-pattern指定层名称的模式。 | ✅ | |
selector-class-pattern指定类选择器的模式。 | ✅ | |
selector-id-pattern指定 ID 选择器的模式。 | ✅ | |
selector-nested-pattern指定嵌套在规则中的规则选择器的模式。 |
引号
¥Quotes
要求或禁止使用这些 quotes 规则进行引号。
¥Require or disallow quotes with these quotes rules.
font-family-name-quotes要求或禁止对字体系列名称使用引号。 | ✅ | 🔧 |
function-url-quotes要求或不允许网址加引号。 | ✅ | 🔧 |
selector-attribute-quotes要求或禁止对属性值加引号。 | ✅ | 🔧 |
冗余
¥Redundant
禁止使用这些 no-redundant 规则进行冗余。
¥Disallow redundancy with these no-redundant rules.
block-no-redundant-nested-style-rules禁止在块内嵌套冗余样式规则。 | ✅ | |
declaration-block-no-redundant-longhand-properties禁止在声明块中使用多余的普通属性。 | ✅ | 🔧 |
shorthand-property-no-redundant-values禁止简写属性中存在冗余值。 | ✅ | 🔧 |
内部空格
¥Whitespace inside
使用此 whitespace-inside 规则要求或禁止内部有空格。
¥Require or disallow whitespace on the inside with this whitespace-inside rule.
comment-whitespace-inside要求或禁止注释标记内部有空格。 | ✅ | 🔧 |