stylelint_你好Stylelint

stylelint

stylelint

Stylelint is a great new modern unopinionated CSS linter. It's a must for any project beyond test.html.

Stylelint是一款很棒的新型现代无污染CSS短绒。 对于test.html以外的任何项目,这都是必须的。

After my last post about always adding generic font families I thought it should be a lint-able thing. So I looked into extending Stylelint. You can write new lint rules and tell Stylelint to use them. In my case, I thought requiring generic font families was broad enough that it should probably be a part of Stylelint core.

在上一篇关于总是添加通用字体系列的文章之后,我认为这应该是一件轻而易举的事情。 因此,我研究了扩展Stylelint的方法。 您可以编写新的皮棉规则,并告诉Stylelint使用它们。 就我而言,我认为要求通用字体系列足够广泛,以至于它应该成为Stylelint核心的一部分。

在您的项目中运行Stylelint (Running Stylelint in your project)

Installing Stylelint is actually not required in order to contribute a new rule, but hey!

为了贡献新规则,实际上不需要安装Stylelint,但是,嘿!

As one would expect in this day and age..

正如今天所期望的那样。

$ npm install -g stylelint

Running Stylelint requires a config. Remember, it's unopinionated, you have to express your opinion. I think the best place to start is using the example config which is actually a separate project, stylelint-config-standard

运行Stylelint需要配置。 请记住,这是没有意见的,您必须表达自己的意见。 我认为最好的起点是使用示例配置,它实际上是一个单独的项目, stylelint-config-standard

$ cd /your/project/root
$ curl https://raw.githubusercontent.com/stylelint/stylelint-config-standard/master/index.js > styelint.config.js

And now, linting...

现在,棉绒...

$ stylelint src/*.css

Oh boy, a new todo!

哦,男孩,一个新的待办事项!

running stylelint

在任何旧CSS上运行Stylelint (Running Stylelint on any old CSS)

If you're like me, you have a lot of stuff all over the place. Not necessarily nicely setup as a project with a build script and all that. I want to lint a CSS no matter where it may reside.

如果您像我,那么到处都有很多东西。 不一定很好地将其设置为带有构建脚本的项目。 无论它可能驻留在哪里,我都希望为CSS添加绒毛。

So a globaly accessible config is in order. (Stylelint CLI itself is already global.) One that doesn't have dependencies.

因此,全局可访问配置是适当的。 (Stylelint CLI本身已经是全局的。)一个没有依赖项的。

cd ~/

# same as above, grab the "standard" config
$ curl https://raw.githubusercontent.com/stylelint/stylelint-config-standard/master/index.js > styelint.config.js

The "standard" config depends on the "recommended", so I just grab the rules from it and paste them in styelint.config.js. In effect I merely inline the dependency. My styelint.config.js now looks like...

“标准”配置取决于“推荐”,因此我只是从中获取规则并将其粘贴到styelint.config.js 。 实际上,我只是内联依赖项。 我的styelint.config.js现在看起来像...

"use strict"

module.exports = {
  "rules": {
    "at-rule-no-unknown": true,
    "block-no-empty": true,
    "color-no-invalid-hex": true,
....

Now I can run $ stylelint whatevs.css no matter if whatevs.css is part of any specific setup or just cluttering the Desktop.

现在,无论whatevs.css是任何特定设置的一部分,还是只是使桌面混乱,我都可以运行$ stylelint whatevs.css

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/hello-stylelint/

stylelint

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值