【问题标题】:Prevent js-beautify from adding extra whitespace / empty lines防止 js-beautify 添加额外的空格/空行
【发布时间】:2017-04-20 11:19:33
【问题描述】:

js-beautify(在 VSCode 下使用)通过在 cmets 后面添加额外的行让我很恼火:

我的示例.scss

/* a fancy comment */
.foo-bars {
    background: $gray;
    display: block;

    width: 26px !important;
}

...变成...

/* a fancy comment */
                      <-- annoying empty line inserted
.foo-bars {
    background: $gray;
    display: block;
                     <--- (this is fine. I like it being preserved)
    width: 26px !important;
}

这是我的.jsbeautifyrc(已验证有效,即通过"indent_char": "#" 进行测试)

{
    "indent_char": " ",
    "preserve_newlines": true,
    "max_preserve_newlines": 8,
    "keep-array-indentation": true,
    "break_chained_methods": false,
    "newline_between_rules": false,
    "selector_separator_newline": false,
    "end_with_newline": false
}

更新:仅影响/* block comments */,不影响// line comments

【问题讨论】:

    标签: sass whitespace js-beautify


    【解决方案1】:

    这似乎应该已经修复 (js-beautify#609) 但不知何故没有按预期工作,因为关于这个问题仍有一个未解决的 issue#531 和待处理的 pull request

    正如您所提到的,您现在可以使用 // line comments 作为解决方法。

    【讨论】:

    • 在 CSS 中使用// 进行注释是非标准的,会导致问题,不鼓励使用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-24
    • 2021-06-12
    • 2014-12-12
    • 2018-03-27
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多