Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format objects in alternative way - additional option. #1049

Closed
ghost opened this issue Oct 27, 2016 · 3 comments
Closed

Format objects in alternative way - additional option. #1049

ghost opened this issue Oct 27, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 27, 2016

Description

Hi! Could you add format objects in new alternative way as additional option?
I think that a lot of people will want to format object in another way as is it shown in above example.
As you can see, anotherObject values in new, alternate way will be format in one column.
Spaces will be automatically added between keys and values to make that looks very easy-readable > code. Algorith to realise that is very easy, but effects will be amazing :)
I hope to get answer. :)

Input

The code before:

var anotherObject = {
    name:                         "name",
    surname: "surname",
    id:     "id"
};  

Expected Output

The code should have looked like this after alternative beautification:

var anotherObject = {
    name:    "name",
    surname: "surname",
    id:      "id"
};

Actual Output

The code actually looked like this after beautification:

var anotherObject = {
    name: "name",
    surname: "surname",
    id: "id"
};  

Steps to Reproduce

Iterate over keys and values in object and search the longest key.
Range again over object and as many spaces after key, as excepted - result of equation:
(longest key length + white space) - (actual value length). Then show value.

Environment

OS: Ubuntu

New additional setting example

{
alternative_object_format: true/false
}

@Oxicode
Copy link

Oxicode commented Oct 27, 2016

Why?

@ghost
Copy link
Author

ghost commented Oct 27, 2016

Oh. Now I can see that code in post has been destroyed. Please, check difference on following screenshot:
jsbeautifier_issue

As you can first two objects, they are more readable than the 'default' one.
It is very helpful if there are bigger objects (more than 5 keys) with different lengths.

@bitwiseman
Copy link
Member

Duplicate of #365.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants