批量抑制
¥Bulk suppressions
[!WARNING] 此功能尚处于实验阶段,可能会发生重大变化。
¥[!WARNING] This feature is experimental, and might change significantly.
当现有代码库已经包含许多无法自动修复的问题时,启用严重级别为 error
的规则可能会很困难。你可以抑制这些遗留问题,以便仅对新代码强制执行该规则,然后按照你自己的节奏清除积压。
¥Turning on a rule with the severity of error
can be difficult when an established codebase already contains many problems that can't be auto-fixed. You can suppress those legacy problems so the rule is enforced only for new code, and then clear the backlog at your own pace.
--suppress [<rule>]
隐藏严重级别为 error
的问题并将其记录在文件中。
¥Suppress problems that have the severity of error
and record them in a file.
如果未指定规则,则所有问题都将被抑制。否则,仅抑制符合给定规则的问题,例如 --suppress rule1 --suppress rule2
。
¥If no rule is specified, all problems are suppressed. Otherwise, only problems with the given rules are suppressed, e.g., --suppress rule1 --suppress rule2
.
后续运行不使用 --suppress
标志将不会报告这些问题,除非同一文件中的同一规则存在更多问题。
¥Subsequent runs without the --suppress
flag will not report these problems, unless there are more problems for the same rule in the same file.
[!TIP] 我们建议将抑制文件提交到你的存储库,并在
--suppress
的同时使用--fix
选项。¥[!TIP] We recommend committing the suppressions file to your repository and using the
--fix
option alongside the--suppress
.
--suppress
不能与 stdin 输入结合使用(例如,通过 echo "..." | stylelint
管道代码)。
¥[!NOTE]
--suppress
can't be combined with stdin input (e.g., piping code via echo "..." | stylelint
).
--suppress-location <path>
抑制文件或目录的路径。默认为 stylelint-suppressions.json
。
¥Path to a suppressions file or directory. Defaults to stylelint-suppressions.json
.
如果你指定了目录路径,Stylelint 将在该目录中创建一个名为 stylelint-suppressions.json
的文件。
¥If you specify a directory path, Stylelint will create a file named stylelint-suppressions.json
in that directory.
[!IMPORTANT] 即使不使用
--suppress
标志,你也必须在所有后续运行中使用--suppress-location
。¥[!IMPORTANT] You must use
--suppress-location
on all subsequent runs, even when not using the--suppress
flag.