Skip to main content


¥Ignoring code


¥You can ignore:

  • 文件的一部分

    ¥parts of a file

  • 完全归档

    ¥files entirely


¥Parts of a file

你可以使用 CSS 中的配置注释暂时关闭规则。

¥You can temporarily turn off rules using configuration comments in your CSS.


¥For example, you can either turn all the rules off:

/* stylelint-disable */
a {}
/* stylelint-enable */


¥Or you can turn off individual rules:

/* stylelint-disable selector-max-id, declaration-no-important */
#id {
color: pink !important;
/* stylelint-enable selector-max-id, declaration-no-important */

你可以使用 /* stylelint-disable-line */ 注释关闭各个行的规则,之后你不需要显式地重新启用它们:

¥You can turn off rules for individual lines with a /* stylelint-disable-line */ comment, after which you do not need to explicitly re-enable them:

#id { /* stylelint-disable-line */
color: pink !important; /* stylelint-disable-line declaration-no-important */

你还可以仅使用 /* stylelint-disable-next-line */ 注释关闭下一行的规则,之后无需显式重新启用它们:

¥You can also turn off rules for the next line only with a /* stylelint-disable-next-line */ comment, after which you do not need to explicitly re-enable them:

#id {
/* stylelint-disable-next-line declaration-no-important */
color: pink !important;

Stylelint 支持复杂、重叠的禁用和启用模式:

¥Stylelint supports complex, overlapping disabling & enabling patterns:

/* stylelint-disable */
/* stylelint-enable foo */
/* stylelint-disable foo */
/* stylelint-enable */
/* stylelint-disable foo, bar */
/* stylelint-disable baz */
/* stylelint-enable baz, bar */
/* stylelint-enable foo */


¥Comments within selector and value lists are currently ignored.


¥You may also include a description at the end of the comment, after two hyphens:

/* stylelint-disable -- Reason for disabling Stylelint. */
/* stylelint-disable foo -- Reason for disabling the foo rule. */
/* stylelint-disable foo, bar -- Reason for disabling the foo and bar rules. */


¥There must be a space on both sides of the hyphens.


¥Files entirely

你可以使用 .stylelintignore 文件来忽略特定文件。例如:

¥You can use a .stylelintignore file to ignore specific files. For example:


.stylelintignore 文件中的模式必须与 .gitignore 语法 匹配。(node-ignore 在幕后解析你的模式。).stylelintignore 中的模式总是相对于 process.cwd() 进行分析。

¥The patterns in your .stylelintignore file must match .gitignore syntax. (Behind the scenes, node-ignore parses your patterns.) Your patterns in .stylelintignore are always analyzed relative to process.cwd().

Stylelint 在 process.cwd() 中查找 .stylelintignore 文件。你还可以使用 --ignore-path(在 CLI 中)和 ignorePath(在 JS 中)选项指定忽略模式文件的路径(绝对路径或相对于 process.cwd())。

¥Stylelint looks for a .stylelintignore file in process.cwd(). You can also specify a path to your ignore patterns file (absolute or relative to process.cwd()) using the --ignore-path (in the CLI) and ignorePath (in JS) options.

或者,你可以在配置对象中添加 ignoreFiles 属性

¥Alternatively, you can add an ignoreFiles property within your configuration object.