Handle block scoped alignement formatting
See original GitHub issueAdd 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:
- Created 7 years ago
- Reactions:14
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
I think it would be relatively easy to allow users to plug in an existing alignment tool. All IDEs support them.