question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

css-beautify inserts extra newlines before comments

See original GitHub issue

Description

This is the default template for bug reports, if you have a more general issue, question, or request, you may ignore this template and write freeform.

NOTE:

  • Do not include screenshots! This library is a text processor, we need text inputs and outputs for debugging and fixing issues.
  • Check the list of open issues before filing a new issue.

Input

The code looked like this before beautification:

html {}


/* comment */

Expected Output

The code should have looked like this after beautification:

html {}


/* comment */

Actual Output

The code actually looked like this after beautification:

html {}



/* comment */

Steps to Reproduce

Environment

OS: Debian 8 Jessie

Settings

Example:

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_level": 0,
    "indent_with_tabs": false,
    "preserve_newlines": true,
    "max_preserve_newlines": 10,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "brace_style": "collapse,preserve-inline",
    "keep_array_indentation": false,
    "keep_function_indentation": false,
    "space_before_conditional": true,
    "break_chained_methods": false,
    "eval_code": false,
    "unescape_strings": false,
    "wrap_line_length": 0
}

I would expect that css-beautify puts a fixed number of newlines before the comment. Instead, by running css-beautify -f file.css -r repeatedly, there’s an increasing number of newlines before the comment.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
aszx0413commented, Nov 21, 2017

It keeps adding new line between css rule and comments

1reaction
taoliujuncommented, Sep 16, 2017

I try format vue file in vscode. The code is border: 1px solid #ddd;/*no*/ for ignore px2rem, but after format code, The code becomes:

border: 1px solid #ddd;    
/*no*/

it add new line before /no/ comment and it will not work for ignore px2rem.

help me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent js-beautify from adding extra whitespace / empty lines
a fancy comment */ <-- annoying empty line inserted .foo-bars { background: $gray; display: block; <--- (this is fine.
Read more >
js-beautify - UNPKG
329, * Extra newline is inserted after the comment line instead of before it ([#531](https://github.com/beautify-web/js-beautify/issues/531)).
Read more >
website/node_modules/js-beautify/CHANGELOG.md - Rdrr.io
Incorrect indentation after loop with comment (#1090); Extra newline is inserted after beautifying code with anonymous function (#1085); end brace with next ...
Read more >
js-beautify-ejsx | Yarn - Package Manager
Incorrect indentation after loop with comment (#1090) · Extra newline is inserted after beautifying code with anonymous function (#1085) · end brace with...
Read more >
JS-Beautifier/CHANGELOG and JS-Beautifier Releases (Page 5 ...
Fixed a batch of comment and semicolon-less code bugs. Closed Issues. Incorrect indentation after loop with comment (#1090); Extra newline is inserted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found