millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

Line breaks for ObjectPatternComma doesn't work like expected #441

Closed hoschi closed 8 years ago

hoschi commented 8 years ago

I try make these two ways of destruction possible:

a) let {foo, bar} = this.props b)

let {
   foo,
   bar
} = this.props

As I understand the documentation this would be lineBreak.after.ObjectPatternComma = "<2" but this adds always a line break.

millermedeiros commented 8 years ago
DEBUG=rocambole:br:* ./bin/esformatter --lineBreak.after.ObjectPatternComma="<2" --lineBreak.after.ObjectPatternOpeningBrace="<2" --lineBreak.before.ObjectPatternClosingBrace="<2"

shows that line break is added because of --lineBreak.before.Property=">=1" (setting it to -1 solves the conflict but is not a valid solution):

  rocambole:br:before typeOrValue: Property, expected: >=1, value: foo +0ms
  rocambole:br:between diff: 1 +4ms
  rocambole:br:before typeOrValue: Property, expected: >=1, value: bar +1ms
  rocambole:br:between diff: 1 +0ms

will probably need to skip Property automatic line break if inside ObjectPattern - should be easy to fix.