跳到主要内容

Stylelint

npm version Build Status npm downloads

Stylelint 是一个强大、先进的 CSS 代码检查器(linter),可以帮助你规避 CSS 代码中的错误并保持一致的编码风格。

亮点​

Stylelint 的强大源于:

  • 拥有超过 170 条内置规则 赖检查最新的 CSS 语法和功能
  • 支持 插件 以创建你自己的规则
  • 自动 修复 大多数代码格式上的问题
  • 经过 15000 多次的 充分的单元测试
  • 支持扩展或创建 可共享的配置
  • 非强制约束(unopinionated),可根据你自己的需求进行自定义
  • 像 Prettier 一样可以 美化打印 效果
  • 拥有一个 不断增长的社区,并且被 Google、GitHub 和 WordPress 所使用

还可以被扩展为:

  • 解析 类似 CSS 的语法,例如 SCSS、Sass、Less 以及 SugarSS
  • 能够从 HTML、Markdown 和 CSS-in-JS 对象以及模板文本中提取 内嵌的样式代码

How it'll help you​

It'll help you avoid errors, for example styles that are:

  • invalid, e.g. malformed hex colors and named grid areas
  • valid but with unintended consequences, e.g. duplicated selectors and overridden properties

And enforce conventions, for example:

  • what units, functions, at-rules etc are allowed
  • consistent patterns for selector names, at-rule names, custom properties etc
  • maximum specificity or maximum quantity of each selector type
  • your preferred notation for color functions, font weight etc

There are also rules for enforcing stylistic consistency, but we now recommend you use Stylelint alongside a pretty printer like Prettier. Linters and pretty printers are complementary tools that work together.

示例输出​

Example

使用指南​

贡献者​

Stylelint 项目由志愿者维护。代码是由 这些了不起的人 所贡献的,没有他们,Stylelint 就不会存在。请贡献您的一份力量。

Sponsors​

Thank you to all our sponsors! Become a sponsor.

Backers​

Thank you to all our backers! Become a backer.

Website hosting​

Deploys by Netlify

开源协议​

The MIT License.