错误和警告
¥Errors & warnings
除了规则问题之外,Stylelint 还会显示以下错误和警告:
¥In addition to rule problems, Stylelint surfaces the following errors and warnings:
CSS 语法错误
¥CSS syntax error
Stylelint 内置的 CSS 解析器或所选的 自定义语法 无法解析你的代码。
¥The CSS parser built into Stylelint, or the chosen custom syntax, could not parse your code.
未封闭块
¥Unclosed block
你应该平衡大括号,通常是声明块。
¥You should balance your curly braces, typically of declaration blocks.
例如:
¥For example:
- a { color: red;
+ a { color: red; }
非封闭式括号
¥Unclosed bracket
你应该平衡方括号,通常是属性选择器和网格名称。
¥You should balance your square brackets, typically of attribute selectors and grid names.
例如:
¥For example:
- a[foo { grid: [bar; }
+ a[foo] { grid: [bar]; }
未闭合的字符串
¥Unclosed string
你应该平衡引号。
¥You should balance your quotation marks.
例如:
¥For example:
- a { content: " }
+ a { content: "" }
未知词
¥Unknown word
你应该:
¥You should:
-
连字符属性
¥hyphenate properties
-
用冒号分隔属性和值对
¥separate property and value pairs with colons
-
用分号分隔声明
¥separate declarations with semicolons
-
将选择器与规则中的声明块配对
¥pair selectors with declaration blocks in rules
例如:
¥For example:
a {
- margin top: 1px
- color red
+ margin-top: 1px;
+ color: red
}
解析错误
¥Parse error
Stylelint(或所选的 自定义语法)内置的 CSS 解析器成功解析了你的代码,但特定于构造的解析器之一无法解析该源中的媒体查询、选择器或值。
¥The CSS parser built into Stylelint (or the chosen custom syntax) successfully parsed your code, but one of the construct-specific parsers failed to parse either a media query, selector or value within that source.
特定于构造的解析器是:
¥The construct-specific parsers are:
-
@csstools/media-query-list-parser
-
postcss-selector-parser
-
postcss-value-parser
你应该检查你的构造是否格式良好,例如 括号是平衡的。
¥You should check that your constructs are wellformed, e.g. parentheses are balanced.
未知规则错误
¥Unknown rule error
配置对象 中有一个未知的规则。
¥There is an unknown rule in the configuration object.
你应该:
¥You should:
-
安装最新版本的 Stylelint (
npm i --save-dev stylelint
),因为我们最近可能添加了规则¥install the latest version of Stylelint (
npm i --save-dev stylelint
), as we may have recently added the rule -
通过搜索 规则清单 检查规则是否存在并正确命名
¥check that the rule exists and is correctly named by searching the list of rules
弃用警告
¥Deprecation warning
配置对象 中有一条已弃用的规则。
¥There is a deprecated rule in the configuration object.
你应该:
¥You should:
-
确定在 CHANGELOG 中哪个版本弃用了该规则
¥identify in the CHANGELOG which release deprecated the rule
-
采取那里建议的行动
¥take the action suggested there
无效选项警告
¥Invalid option warning
配置对象 中的规则配置错误。
¥There is a misconfigured rule in the configuration object.
你应该:
¥You should:
-
安装最新版本的 Stylelint (
npm i --save-dev stylelint
),因为我们最近可能添加了该选项¥install the latest version of Stylelint (
npm i --save-dev stylelint
), as we may have recently added the option -
通过阅读规则的自述文件检查该选项是否存在并且名称正确
¥check that the option exists and is correctly named by reading the rule's README
-
正确配置配置对象中的
rules
属性¥correctly configure the
rules
property in the configuration object