【问题标题】:How I should check indentation in SASS file with stylelint?我应该如何使用 stylelint 检查 SASS 文件中的缩进?
【发布时间】:2016-09-03 12:50:31
【问题描述】:

我尝试使用 stylelint 来检查我的 SASS 文件。当我设置规则时

"indentation": "tab"

stylelint 抛出下一个错误

 2:1   ✖  Expected indentation of 1 tab   indentation
 3:1   ✖  Expected indentation of 1 tab   indentation
 5:1   ✖  Expected indentation of 1 tab   indentation
 8:3   ✖  Expected indentation of 1 tab   indentation
11:3   ✖  Expected indentation of 1 tab   indentation
14:3   ✖  Expected indentation of 1 tab   indentation
....

如何正确检查缩进?

更新: 样式的顶部:

@import "theme/bootstrap"
@import "theme/bootstrap-theme"
@import "theme/theme"

@keyframes hide-notifi

    0%
        top: 0

    75%
        top: 0

    100%
        top: -100%

【问题讨论】:

  • 您能否将您的 SCSS 代码的第 2 到 5 行添加到问题中?

标签: css sass coding-style stylesheet stylelint


【解决方案1】:

stylelint 目前与基于空格的 SASS 语法不兼容。

引用stylelint.io网站:

了解类似 CSS 的语法:linter 由 PostCSS 提供支持,因此它 理解 PostCSS 可以解析的任何语法,包括 SCSS, SugarSS,以及对 Less 的实验性支持

您可以采用SugarSS,这是一种基于空格的语法。与precss PostCSS plugin pack 结合使用时,您将拥有与基于空格的 SASS 相当的功能。

另一种选择是向 PostCSS 社区贡献一个 SASS 解析器。

或者,您可以使用SASS-lint,它支持 SASS 语法,但具有与 stylelint 不同的一组功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多