防止 js-beautify 添加额外的空格/空行
Prevent js-beautify from adding extra whitespace / empty lines
js-beautify(在 VSCode 下使用)在评论后添加额外的行让我很烦:
我的sample.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
。
看来这应该已经解决了(js-beautify#609) but somehow didn’t work out as expected as there is still an open issue#531 and a pending pull request 关于这个问题。
正如您提到的,您现在可以使用 // line comments
作为解决方法。
js-beautify(在 VSCode 下使用)在评论后添加额外的行让我很烦:
我的sample.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
。
看来这应该已经解决了(js-beautify#609) but somehow didn’t work out as expected as there is still an open issue#531 and a pending pull request 关于这个问题。
正如您提到的,您现在可以使用 // line comments
作为解决方法。