Skip to main content

规则

¥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.

降序

¥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.

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 规则。
string-no-newline
禁止字符串中无效的换行符。

不规律的

¥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
禁止字体系列中缺少通用系列关键字。

非标准的

¥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-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-properties
禁止未知的自定义属性。
property-no-unknown
禁止未知属性。
selector-pseudo-class-no-unknown
禁止未知的伪类选择器。
selector-pseudo-element-no-unknown
禁止未知的伪元素选择器。
selector-type-no-unknown
禁止未知类型选择器。
unit-no-unknown
禁止未知单位。

执行约定

¥Enforce conventions

你可以使用这些 nolist 规则强制执行约定。它们是使代码保持一致的强大规则。你需要配置其中的大部分以满足你的需求。

¥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-listdisallowed-listrequired-listno 规则的事物。

¥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
指定 at 规则所需属性的列表。

颜色

¥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-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

使用这些 maxmin 规则应用限制。

¥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-notation
指定颜色函数的现代或传统表示法。
🔧
color-hex-length
指定十六进制颜色的短或长表示法。
🔧
font-weight-notation
指定字体粗细的数字或命名符号。
🔧
hue-degree-notation
指定色调的数字或角度符号。
🔧
import-notation
@import 规则指定字符串或 URL 表示法。
🔧
keyframe-selector-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
指定注释的模式。
custom-media-pattern
指定自定义媒体查询名称的模式。
custom-property-pattern
指定自定义属性的模式。
keyframes-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.

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
要求或禁止注释标记内部有空格。
🔧