广西快乐双彩163期开奖结果:Hello Stylelint

October 1st, 2017. Tagged: CSS

Stylelint is a great new modern unopinionated CSS linter. It's a must for any project beyond 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.

Running Stylelint in your project

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

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

$ 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

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.

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

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...

"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.

Tell your friends about this post: Facebook, Twitter, Google+

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov


  • 运城市在长三角招商引资149.9亿元 2019-04-08
  • 济南五胞胎雪虎宝宝亮相 四雌一雄萌态十足 2019-04-08
  • 去产能迎年中考 煤炭、钢铁企业债务问题依然存在 2019-04-07
  • 最高检等四部门出台意见 指导依法办理恐怖活动和极端主义犯罪案件 2019-04-07
  • 广州市黄埔区人民法院公告专栏 2019-03-28
  • 这个“海之宁”是个死抱着相对论旧谬误不放,疯狂反对科学新真理的跳梁“小丑”,这个跳梁“小丑”根本就不懂得尊重客观事实及其规律,总是无视、脱离、歪曲客观... 2019-03-22
  • 如何理解孔子这句话?北大教授胡军动情论生死 2019-03-21
  • 海外舆论关注中国最新军备 称赞习近平主席强军号令 2019-03-19
  • 女性之声——全国妇联 2019-03-19
  • 美司法部科米在希拉里邮件门调查中存在过失 2019-03-17
  • “四新”彰显党的十九大思想灵魂和精髓要义 2018-08-17
  • 热身赛-U17女篮73-68立陶宛 杨舒宇19分刘禹彤13分 2018-08-16
  • 七月流火:一半是甜蜜 一半是仁慈 2018-08-15
  • “嫦娥”飞向月球背面,将会揭开哪些秘密? 2018-08-15
  • 一代枭雄身后事:“曹操墓”认定过程缘何一波三折? 2018-08-04
  • 91| 913| 775| 20| 454| 213| 103| 56| 983| 225|