max-mapper / standard-format

converts your code into Standard JavaScript Format
264 stars 59 forks source link

Enabled more jsx formatting rules #115

Closed bcomnes closed 8 years ago

bcomnes commented 9 years ago

Improves JSX formatting a fair amount. WIP.

Flet commented 8 years ago

@bcomnes is this ok to merge as is?

bcomnes commented 8 years ago

Its going to start formatting JSX if this is merged, but it's probably better behavior than what goes on now. I've been super swamped at work the last two weeks 😓 I'm not ready to say yes to this yet, but if you pull it down and believe it's good, we can merge.

Flet commented 8 years ago

I did notice some frumpy formatting happens currently which is why I asked :)

No worries, I have some JSX stuff I can validate this against next week.

bcomnes commented 8 years ago

I'm tempted to merge this as is. I tested it out on the react tutoral repo. Results wern't qute how I wanted, but they seem in line with standard and with https://github.com/royriojas/esformatter-jsx

e.g. I would like to see something like:

return (
  <div className="comment">
    <h2 className="commentAuthor">
      {this.props.author}
    </h2>
    <span dangerouslySetInnerHTML={this.rawMarkup()} />
  </div>
)

but instead get

return (
<div className="comment">
   <h2 className="commentAuthor">{this.props.author}</h2>
   <span dangerouslySetInnerHTML={this.rawMarkup()} />
</div>
)

Any thoughts on the matter?

feross commented 8 years ago

If it's better than what's currently happening, let's merge it.

bcomnes commented 8 years ago

OK, I'll merge this later today if someone else doesn't beat me to it.

0x80 commented 8 years ago

@bcomnes was this merged?

In the version that I'm using (1.6.9) the indentation of the first tag is off.

 render() {
    return (
    <div>
        <h1>...</h1>
        <button onClick={foo}>...</button>
        <canvas ref='canvas'/>
      </div>
    )
  }
bcomnes commented 8 years ago

@0x80 no not yet. I'm going to get this and the new formatter rules pulled in, do a release, then try to improve the es6 situation with the new rules this weekend.

0x80 commented 8 years ago

:+1: awesome!

bcomnes commented 8 years ago

Actually, I'm going to do a release with the new rules first so I can do a minor release first.