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

ES6 Object Shortand Indenting Weirdly Sometimes #810

Closed
timothyeburke opened this issue Nov 18, 2015 · 1 comment
Closed

ES6 Object Shortand Indenting Weirdly Sometimes #810

timothyeburke opened this issue Nov 18, 2015 · 1 comment
Milestone

Comments

@timothyeburke
Copy link
Contributor

// original
function badFormatting() {
    return {
        a,
        b: c,
        d: e,
        f: g,
        h,
        i,
        j:k
    }
}

function goodFormatting() {
    return {
        a: b,
        c,
        d: e,
        f: g,
        h,
        i,
        j:k
    }
}


// output
function badFormatting() {
    return {
        a,
        b: c,
            d: e,
            f: g,
            h,
            i,
            j: k
    }
}

function goodFormatting() {
    return {
        a: b,
        c,
        d: e,
        f: g,
        h,
        i,
        j: k
    }
}

In ES6, the object shorthand is getting weirdly indented when preserving new line, but only in the case that the object's first token is the shorthand syntax. This syntax is documented here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer

If you feel this is a legit bug, I'll be glad to look into fixing it.

@bitwiseman
Copy link
Member

It is a legit bug.
Probably related to https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js#L741 .
It's the : in the first field that we look for. Before ES6 that was a reasonable assumption.

@bitwiseman bitwiseman added this to the v1.6.0 milestone Nov 18, 2015
timothyeburke added a commit to timothyeburke/js-beautify that referenced this issue Nov 18, 2015
bitwiseman added a commit that referenced this issue Nov 19, 2015
Resolving #810: ES6 Object Literal Shorthand Detection
olsonpm pushed a commit to olsonpm/js-beautify that referenced this issue Dec 13, 2015
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