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.

Handle block scoped alignement formatting

See original GitHub issue

Add an option (or in default behavior) to handle block scoped alignement.

Object keys:

BAD

let test;

test = {
  property1: 'value1',
  property10: 'value10',
  property100: 'value100',

  propertyInAnotherBlock: 'valueInAnotherBlock',
  propertyWithNestedObject: {
    nestedProperty: 1
  },
  anotherPropertyWithNestedObject: {
    nestedProperty: 1
  }
}

GOOD

let test;

test = {
  property1   : 'value1',
  property10  : 'value10',
  property100 : 'value100',

  propertyInAnotherBlock   : 'valueInAnotherBlock',
  propertyWithNestedObject : {
    nestedProperty : 1
  },
  anotherPropertyWithNestedObject : {
    nestedProperty : 1
  }
}

Variables assignement:

BAD

let var1,
    var10 = 'first10',
    var100 = 'first100',

    varInAnotherBlock = 'valueInAnotherBlock';

var1 = 'value1';
var10 = 'value10';
var100 = 'value100';

varInAnotherBlock = 'valueInAnotherBlock';

GOOD

let var1,
    var10  = 'first10',
    var100 = 'first100',

    varInAnotherBlock = 'valueInAnotherBlock';

var1   = 'value1';
var10  = 'value10';
var100 = 'value100';

varInAnotherBlock = 'valueInAnotherBlock';

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:14
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
jlongstercommented, Jan 14, 2017

Not going to do this, sorry. It would require a lot more complexity, and I think this style fails in some cases where you have a really long variable name and it doesn’t make sense to push everything over. This is an arbitrary style and we’re going to stick with a consistent var variable = value.

It technically would be very hard, just to expand. What do you do when a comment separates a group of variables? We interleave the comments after printing the nodes, so we have no knowledge of where comments are places while printing variables.

6reactions
Matt-Hill-Harnesscommented, Aug 8, 2017

I think it would be relatively easy to allow users to plug in an existing alignment tool. All IDEs support them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Block formatting context - Developer guides - MDN Web Docs
A block formatting context (BFC) is a part of a visual CSS rendering of a web page. It's the region in which the...
Read more >
Clang-Format Style Options — Clang 16.0.0git documentation
clang-format supports two ways to provide custom style options: directly specify style ... When true , the block gets indented as a scope...
Read more >
Formatting Properties - W3C
Common Margin Properties-Block. These properties set the spacing and indents surrounding block-level formatting objects. Common Margin Properties-Inline.
Read more >
Clean Code – Formatting | Baeldung on Computer Science
First, there is no vertical openness since the whole code is grouped as one block. Besides that, there is a useless comment separating...
Read more >
Google Java Style Guide
4 Formatting: 4.1 Braces: 4.2 Block indentation: +2 spaces ... simply out of fear that some programs might not handle non-ASCII characters properly....
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