快乐双彩玩法和奖金: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. Working on restoring the existing comments...

Meanwhile, hit me up on twitter @stoyanstefanov


  • “四新”彰显党的十九大思想灵魂和精髓要义 2018-08-17
  • 热身赛-U17女篮73-68立陶宛 杨舒宇19分刘禹彤13分 2018-08-16
  • 七月流火:一半是甜蜜 一半是仁慈 2018-08-15
  • “嫦娥”飞向月球背面,将会揭开哪些秘密? 2018-08-15
  • 一代枭雄身后事:“曹操墓”认定过程缘何一波三折? 2018-08-04
  • 女出纳侵吞千万公款扮富婆 7年未被公司发现 2018-08-04
  • 南昌PM2.5浓度写进目标责任书 切实防治大气污染 2018-07-20
  • 网友投诉不文明养犬行为 有关部门加强治理 2018-07-20
  • 945| 751| 959| 443| 752| 470| 700| 54| 251| 990|