keeganstreet / specificity

A JavaScript module for calculating the specificity of CSS selectors
MIT License
624 stars 39 forks source link

How to write a script that calculates class specificity for source in my project folder. #41

Closed cbuteau closed 5 years ago

cbuteau commented 5 years ago

Hello, I stumbled on this tool from this article.

https://codeburst.io/css-specificity-an-overview-3edb93e4d16e

I am trying to write a script for my team that they can calculate existing class specificity so they can understand better our existing classes.

How do I load such a CSS file into your system to perform those calculations?

keeganstreet commented 5 years ago

Hi @cbuteau, Stylelint can parse an entire CSS file and report on various aspects of the CSS, including the specificity of the selectors. It uses this library under the hood for specificity calculations. I would suggest you try that out.

You can even install it as an extension in your code editor, such as VS Code, and hover your cursor over the selectors to see their specificity.