max-mapper / standard-format

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

Adding more indentation when returning object in ES6 #127

Closed sospedra closed 7 years ago

sospedra commented 8 years ago

Giving the following example:

return array.map(el => ({
  inc: el.val + 1,
  dec: el.val - 1
}))

It adds 4 spaces of indentation instead of 2

bcomnes commented 8 years ago

Writing some tests for this. Looks like arrow functions have some hooks in esformatter now so I might actually be able to fix this potentially.

sospedra commented 8 years ago

Let me know if you need some help.

bcomnes commented 8 years ago

The issue seems to come from the the indentation on ObjectExpression's.

return array.map(el => ({
    inc: el.val + 1,
    dec: el.val - 1
 }})

Where the rule is primarily used to make objects look like this:

{
  foo: bar
}

Because its nested inside of an arrow function inside of the the map , its adding two layers of indentation.

I don't see an easy way to fix this at the moment. Any thoughts on the matter?

feross commented 7 years ago

You should use standard --fix instead of this package. standard-format isn't being actively maintained anymore.