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.

Newlines being added before selectors in SCSS/CSS

See original GitHub issue
  • Mac OS 10.13.5
  • VS Code Version: 1.26.1
  • beautify Version: 1.4.2

Code Example: I’ve added messy indentation to make the example outputs clear

$color-variable:    #000;
.offers-table {
    margin: 0 auto;
  .table-row {
margin: 0 auto;
  }
  .table-cell {
           margin: 0 auto;
  }
}

Provide the settings you use: VS Code:

{
    "terminal.integrated.shell.osx": "zsh",
    "workbench.startupEditor": "newUntitledFile",
    "editor.minimap.enabled": true,
    "files.autoSave": "off",
    "editor.tabSize": 2,
    "telemetry.enableTelemetry": false,
    "window.zoomLevel": 0,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "files.associations": {
        ".jsbeautifyrc": "jsonc"
    }
}

.jsbeautifyrc

none

Action performed

Format javascript file with HookyQR.beautifyFile command.

Expected results

Previously when I would format a scss file, none of the css selectors would have a new line added before them, so the code above would format to the below:

$color-variable: #000;
.offers-table {
  margin: 0 auto;
  .table-row {
      margin: 0 auto;
  }
  .table-cell {
      margin: 0 auto;
  }
}

Actual results

Within the last day it seems something has changed, now whenever I format using beautify, my css selectors have a new line added before them. So when I format the code example from above, it looks like this:

$color-variable: #000;

.offers-table {
  margin: 0 auto;

  .table-row {
      margin: 0 auto;
  }

  .table-cell {
      margin: 0 auto;
  }
}

Comments

And this is going to cause problems with git comparisons for the projects I’m on at work, as none of the files have new lines between the css rules and I dont want to be adding this. I’ve tried coming up with and adding variations of "newline_between_rules" to the vscode settings to prevent this but nothing works. I want to be able to add something like "css.format.newline_between_rules": false, to my vscode user settings. I tried adding a jsbeautifyrc file to my home directory or adding beautify.config options to my vscode user settings, but this then forces me to use one tabSize only, and one of the things I like and need of beautify is that it respects the tabSize of each file (different scss files have different indentations within the same project…)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
HookyQRcommented, Sep 22, 2018

Ah. The settings were being carried over from another test. Add:

{
    "newline_between_rules": false
}

Either as a .jsbeautifyrc file or as the value of "beautify.config" in your VS Code settings file.

0reactions
bitwisemancommented, Sep 25, 2018

@thatjeeb I would expect that you should be able to change that one property without loosing autodetect, but there are multiple layers of settings being pulled in. I’m not sure how the plugin auto-detects indentation (or if it uses some existing setting pulled from the editor).

Do the different projects you’re working with have settings files checked in that define their code style?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add line break to ::after or ::before pseudo-element content
I've been doing modifications on a site and adding text via the ::after or ::before pseudo-elements and have found that escape Unicode should...
Read more >
No line break insertions in short CSS selectors #5086 - GitHub
I suggest reconfiguring the changes made in #1962 so as to only insert line breaks in CSS selectors when they exceed a given...
Read more >
How to add a line-break using CSS - Educative.io
A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after or ::before . In the stylesheet, we use...
Read more >
Injecting a Line Break | CSS-Tricks
I had a little situation where I had a header with a span in it, and I wanted to make sure to put...
Read more >
CSS selectors - CSS: Cascading Style Sheets - MDN Web Docs
Grouping selectors. Selector list. The , selector is a grouping method that selects all the matching nodes. Syntax: A, B.
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