Giter VIP home page Giter VIP logo

csscss's Introduction

Build Status Code Climate

What is it?

csscss will parse any CSS files you give it and let you know which rulesets have duplicated declarations.

What is it for?

One of the best strategies for me to maintain CSS is to reduce duplication as much as possible. It's not a silver bullet, but it sure helps.

To do that, you need to have all the rulesets in your head at all times. That's hard, csscss is easy. Let it tell you what is redundant.

How do I use it?

First you need to install it. It is currently packaged as a ruby gem:

$ gem install csscss

Note: csscss only works on ruby 1.9.x and up. It will have trouble with ruby 1.8.x.

Then you can run it in at the command line against CSS files.

$ csscss path/to/styles.css path/to/other-styles.css

{.contact .content .primary} and {article, #comments} share 5 rules
{.profile-picture}, {.screenshot img} and {a.blurb img} share 4 rules
{.work h2:first-child, .archive h2:first-child, .missing h2:first-child, .about h2, .contact h2} and {body.home h2} share 4 rules
{article.blurb:hover} and {article:hover} share 3 rules

Run it in a verbose mode to see all the duplicated styles.

$ csscss -v path/to/styles.css

Run it against remote files by passing a valid URL.

$ csscss -v http://example.com/css/main.css

You can also choose a minimum number of matches, which will ignore any rulesets that have fewer matches.

$ csscss -n 10 -v path/to/style.css # ignores rulesets with < 10 matches

If you prefer writing in sass, you can also parse your sass/scss files.

$ gem install sass
$ csscss path/to/style.scss

I found bugs

This is still a new and evolving project. I heartily welcome feedback. If you find any issues, please report them on github.

Please include the smallest CSS snippet to describe the issue and the output you expect to see.

Who are you?

My name is Zach Moazeni. I work for an awesome company. And we're hiring!

I'm a dev, I can help

Awesome! Thanks! Here are the steps I ask:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Make sure the tests pass (bundle exec rake test)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

csscss's People

Contributors

carsonmcdonald avatar laserlemon avatar prsimp avatar zmoazeni avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.