【问题标题】:grunt-task to SASS allow options to enforce code styleSASS 的 grunt-task 允许选项强制执行代码样式
【发布时间】:2016-09-01 06:14:23
【问题描述】:

对我的 scss 文件执行代码样式有什么繁重的任务吗?

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

所以该任务将格式化我的 css 代码,应用下面的约定,这可能吗?

我想要存档的例子

来自谷歌:

按字母顺序排列声明。 将声明按字母顺序排列,以便以易于记忆和维护的方式实现一致的代码。

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

或来自惯用css:

申报顺序 如果要一致地对声明进行排序,则应遵循单一、简单的原则。

较小的团队可能更喜欢将相关属性(例如定位和盒子模型)聚集在一起。

.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;
}

谢谢。

【问题讨论】:

    标签: css sass gruntjs grunt-contrib-sass


    【解决方案1】:

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

    来自 GitHub:

    scss-lint 是一个帮助您保持 SCSS 文件干净和可读的工具

    它需要 Ruby,这对某些人来说可能是一个障碍。

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

    【讨论】:

      猜你喜欢
      • 2011-04-02
      • 1970-01-01
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多