对SASS的grunt-task允许选项强制执行代码样式

时间:2022-10-25 09:20:58

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

在我的scss文件上执行代码样式的任何繁琐任务?

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

我想在我的.scss文件中应用代码样式吗?

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

那么这个任务将格式化我的css代码应用这些便利,这可能吗?

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 :

或者来自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.

谢谢。

1 个解决方案

#1


2  

I think your best option is scss-lint

我认为你最好的选择是scss-lint

From GitHub:

来自GitHub:

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

scss-lint是一个帮助保持SCSS文件清晰可读的工具

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

它需要Ruby,这可能是一些阻止者。

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

可以在本文中找到有关如何将此与Grunt一起使用的示例

#1


2  

I think your best option is scss-lint

我认为你最好的选择是scss-lint

From GitHub:

来自GitHub:

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

scss-lint是一个帮助保持SCSS文件清晰可读的工具

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

它需要Ruby,这可能是一些阻止者。

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

可以在本文中找到有关如何将此与Grunt一起使用的示例