Better support for ES6 #103

Closed
bookercodes opened this Issue Oct 17, 2015 · 12 comments

Projects

None yet

4 participants

@bookercodes

Consider the following JS code:

export default function() {
}

Upon running vim-jsbeautify the code is transformed into...

export 
default function() {
}

...Which is clearly erroneous.

When I run the same code through the online beautifer the code is formatted as I would expect. I suspect the jsbeautify dependency needs updating?

@maksimr
Owner
maksimr commented Oct 18, 2015
@maksimr maksimr added a commit that referenced this issue Oct 18, 2015
@maksimr chore: update js-beautify fix #103 a2f2c9c
@mydearxym

also turn my react code to wrong format

import React from 'react'

export default class Forbidden extends React.Component {
  render () {
    return (
      <div className="container">
        <div>
          <div>forbidden</div>
        </div>
        <div>
          <div>notAuthorized</div>
        </div>
      </div>
    )
  }
}
import React from 'react'

export
default class Forbidden extends React.Component {
    render() {
        return ( < div className = "container" >
            < div >
            < div > forbidden < /div>
        </div >
            < div >
            < div > notAuthorized < /div>
        </div >
            < /div>
    )
  }
}
@maksimr
Owner
maksimr commented Oct 26, 2015

@mydearxym can you put your .editorconfig

@mydearxym

@maksimr it's basically the same as README.md shows :

 ; .editorconfig

  root = true

  [**.js]
  indent_style = space
  indent_size = 4
  e4x = true

  [**.jsx]
  e4x = true
  indent_style = space
  indent_size = 4

  [**.css]
  indent_style = space
  indent_size = 4

  [**.html]
  indent_style = space
  indent_size = 4
  max_char = 78
  brace_style = expand
@maksimr
Owner
maksimr commented Oct 26, 2015

@mydearxym thanks. Are you use custom version of js-beautify?

@mydearxym

@maksimr Nope, just the common version .

@maksimr
Owner
maksimr commented Oct 26, 2015

@mydearxym try download latest version of js-beautify and set it in .editorconfig

Thanks

@maksimr
Owner
maksimr commented Jan 17, 2016

@mydearxym for jsx you should call JsxBeautify

@mydearxym

@maksimr thanks !

@zeroliu
zeroliu commented Jun 2, 2016 edited

I'm experiencing the same issue.

export default foo is turned into

export
default foo

Here's my .editorconfig:

root = true

[**.js]
indent_style = space
indent_size = 2
max_char = 80

[**.json]
indent_style = space
indent_size = 2

[**.jsx]
e4x = true
indent_style = space
indent_size = 2

[**.css]
indent_style = space
indent_size = 2

[**.html]
indent_style = space
indent_size = 2
@zeroliu
zeroliu commented Jun 2, 2016

ah, manually checkout the latest version of js-beautify works. The submodule used in vim-jsbeautify is out of date.

cd ~/.vim/bundle/vim-jsbeautify/plugin/lib && git checkout master

@maksimr maksimr added the invalid label Jun 2, 2016
@maksimr maksimr closed this Jun 2, 2016
@maksimr
Owner
maksimr commented Jun 2, 2016

Related issue #104

@maksimr maksimr removed the invalid label Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment