csssassgruntjsgrunt-contrib-sass

grunt-task to SASS allow options to enforce code style


its any grunt task to do code style on my scss files?

I would like to apply a code style in my .scss files it's that possible?

So that task will format my css code applying the convencions bellow it's that possible?

examples what I want archive

from google:

Alphabetize declarations. Put declarations in alphabetical order in order to achieve consistent code in a way that is easy to remember and maintain.

background: fuchsia;
border: 1px solid;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
color: black;
text-align: center;
text-indent: 2em;

or from idiomatic-css :

Declaration order If declarations are to be consistently ordered, it should be in accordance with a single, simple principle.

Smaller teams may prefer to cluster related properties (e.g. positioning and box-model) together.

.selector {
    /* Positioning */
    position: absolute;
    z-index: 10;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    /* Display & Box Model */
    display: inline-block;
    overflow: hidden;
    box-sizing: border-box;
    width: 100px;
    height: 100px;
    padding: 10px;
    border: 10px solid #333;
    margin: 10px;

    /* Other */
    background: #000;
    color: #fff;
    font-family: sans-serif;
    font-size: 16px;
    text-align: right;
}

Thank you.


Solution

  • I think your best option is scss-lint

    From GitHub:

    scss-lint is a tool to help keep your SCSS files clean and readable

    It requires Ruby, which may be a blocker to some.

    An example on how to use this with Grunt can be found in this article