js-beautify
js-beautify copied to clipboard
CSS comments always put on new line.
Broken again in latest:
>npm install js-beautify
+ [email protected]
added 28 packages from 21 contributors and audited 125 packages in 1.954s
found 0 vulnerabilities
>echo h1{color:red;/*comment*/} > test.css
>js-beautify -f test.css
h1 {
color: red;
/*comment*/
}
>type .jsbeautifyrc
{
"brace_style": "collapse,preserve-inline",
"break_chained_methods": false,
"eval_code": false,
"extra_liners": [],
"indent_char": " ",
"indent_level": 0,
"indent_size": 2,
"indent_with_tabs": false,
"jslint_happy": true,
"keep_array_indentation": false,
"keep_function_indentation": false,
"max_preserve_newlines": 3,
"newline_between_rules": false,
"preserve_newlines": true,
"space_before_conditional": true,
"unescape_strings": false,
"wrap_line_length": 0
}
css.replace(/;\n\s*\/\*/gs, '; /*')
should fix that.
Thanks!
This has been the expected behavior at least back to 1.7.5, so not a break.
However keeping single line comments on the same line is a reasonable enhancement.
Would be good to see option for keep comments in the same line. I hope you bring it. Please
@kanlukasz I have very limited time to work on this currently. If you are interested in this feature being added, I invite you to implement it and submit a PR.
Broken again in latest:
>npm install js-beautify + [email protected] added 28 packages from 21 contributors and audited 125 packages in 1.954s found 0 vulnerabilities >echo h1{color:red;/*comment*/} > test.css >js-beautify -f test.css h1 { color: red; /*comment*/ } >type .jsbeautifyrc { "brace_style": "collapse,preserve-inline", "break_chained_methods": false, "eval_code": false, "extra_liners": [], "indent_char": " ", "indent_level": 0, "indent_size": 2, "indent_with_tabs": false, "jslint_happy": true, "keep_array_indentation": false, "keep_function_indentation": false, "max_preserve_newlines": 3, "newline_between_rules": false, "preserve_newlines": true, "space_before_conditional": true, "unescape_strings": false, "wrap_line_length": 0 }
css.replace(/;\n\s*\/\*/gs, '; /*')
should fix that.
where do i put this? i tried adding it to user settings but that didn't work
css.replace(/;\n\s*\/\*/gs, '; /*')
should fix that.where do i put this? i tried adding it to user settings but that didn't work
That's JavaScript. You could try modifying https://gist.github.com/CTimmerman/cf0e5f4339cd8f7922515b95d875b3b1 or simply use Notepad++ or Visual Studio Code to regex replace all in your CSS file.
still happening... It would be very helpful to have comments in-line
is there any alternative extension to workaround this bad behavior
is there any alternative extension to workaround this bad behavior
- VS Code TypeScript and JavaScript Language Features
- VS Code JSON Language Features - Supports incomplete JSON.
- Prettier - Doesn't.