js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

CSS comments always put on new line.

Open CTimmerman opened this issue 5 years ago • 8 comments

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.

CTimmerman avatar May 21 '19 08:05 CTimmerman

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.

bitwiseman avatar May 21 '19 16:05 bitwiseman

Would be good to see option for keep comments in the same line. I hope you bring it. Please

kanlukasz avatar Jul 10 '19 19:07 kanlukasz

@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.

bitwiseman avatar Jul 11 '19 15:07 bitwiseman

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

amandainnis avatar Sep 16 '19 17:09 amandainnis

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.

CTimmerman avatar Sep 17 '19 19:09 CTimmerman

still happening... It would be very helpful to have comments in-line

eifr avatar Jan 24 '21 16:01 eifr

is there any alternative extension to workaround this bad behavior

viocha avatar Apr 25 '24 15:04 viocha

is there any alternative extension to workaround this bad behavior

  1. VS Code TypeScript and JavaScript Language Features
  2. VS Code JSON Language Features - Supports incomplete JSON.
  3. Prettier - Doesn't.

CTimmerman avatar Apr 25 '24 17:04 CTimmerman