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

Destructuring, importing, and short objects #853

Merged
merged 1 commit into from
Jan 26, 2016
Merged

Conversation

bitwiseman
Copy link
Member

Fixes #114
Fixes #315
Fixes #370
Fixes #382

bitwiseman added a commit that referenced this pull request Jan 26, 2016
Destructuring, importing, and short objects
@bitwiseman bitwiseman merged commit e4f145e into master Jan 26, 2016
@bitwiseman bitwiseman deleted the feature/inline branch January 26, 2016 10:34
@ksloan
Copy link

ksloan commented Jan 26, 2016

Awesome! All praise @bitwiseman! Thanks so much for doing this. It works wonderfully.

@fyockm
Copy link

fyockm commented Jan 26, 2016

Oh happy day! Can't wait to try this out!

@underscorebrody
Copy link

@bitwiseman Thanks for doing this! It helps a lot!

One thing I'm still seeing is that this:

function something({a, b, c}, d){
  //whatever
}

is becoming this:

function something({
  a,
  b,
  c
}, d) {
  //whatever
}

This is using ES6 object destructuring in the function arguments where the desire would be for the object to stay on a single line, so I thought it might apply here. But let me know if this is a separate issue entirely. Thanks!

@bitwiseman
Copy link
Member Author

@underscorebrody - No, I was expecting it to fix the input you provided. It looks like it comes out right locally. Did you turn on the new setting?

@underscorebrody
Copy link

Okay this was my fault, I ran the beautify task against some code that had been beautified already on the old version so it didn't get handled the right way. Sorry!

@bitwiseman
Copy link
Member Author

@underscorebrody - No problem, thanks for jumping in and testing right away. Please report any other issues you find. 😄

@underscorebrody
Copy link

Discovered #854 while testing as well, but i don't think it's directly related to this change

@jwhitmarsh
Copy link

@bitwiseman I've just read through #114, #315, #370 and #382, and really appreciate the work you've put into supporting this!

However, with v1.6.2

import {join, other} from 'path'

// is becoming

import {
  join, other
}
from 'path';

Is that expected, or an issue with my setup?

@bitwiseman
Copy link
Member Author

Probably a config issue: you need to set brace_style to collapse-preserve-inline to get the inline behavior.

https://github.com/beautify-web/js-beautify/blob/master/test/data/javascript/tests.js#L1572

@monkindey
Copy link

Thanks @bitwiseman Well done;
but is it when i type the object like

 //input
var test = {a: 1, b:2}

it did't transform to

//output
var test = {
   a: 1,
   b: 2
}

but i expect output like above

thanks your project

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

Successfully merging this pull request may close these issues.

6 participants