Prettier: Less readable after (arg => obj.method ... on same line

Created on 7 Feb 2017  路  3Comments  路  Source: prettier/prettier

Overall, I liked output from the latest release, but I did find [this code]

export default function theFunction(action$, store) {
  return action$
    .ofType(THE_ACTION)
    .switchMap(action => Observable
      .webSocket({
        url: (THE_URL),
        /*
        comments
        */
        more: stuff(),
        evenMore: stuff({
          value1: true,
          value2: false,
          value3: false
        })
      })
      .filter(data => theFilter(data))
      .map(({ theType, ...data }) => theMap(theType, data))
      .retryWhen(errors => errors.switchMap(err => {
        return navigator.onLine
          ? Observable.timer(3000 /* ms */)
          : Observable.fromEvent(window, 'online').take(1);
      })));
}

turns into

export default function theFunction(action$, store) {
  return action$.ofType(THE_ACTION).switchMap(action => Observable.webSocket({
    url: THE_URL,
    /*
        comments
        */
    more: stuff(),
    evenMore: stuff({
      value1: true,
      value2: false,
      value3: false
    })
  })
    .filter(data => theFilter(data))
    .map(({ theType, ...data }) => theMap(theType, data))
    .retryWhen(errors => errors.switchMap(err => {
      return navigator.onLine
        ? Observable.timer(3000 /* ms */)
        : Observable.fromEvent(window, "online").take(1);
    })));
}

to be far less readable (where filter now gets indented).

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22export%20default%20function%20theFunction(action%24%2C%20store)%20%7B%5Cn%20%20return%20action%24%5Cn%20%20%20%20.ofType(THE_ACTION)%5Cn%20%20%20%20.switchMap(action%20%3D%3E%20Observable%5Cn%20%20%20%20%20%20.webSocket(%7B%5Cn%20%20%20%20%20%20%20%20url%3A%20(THE_URL)%2C%5Cn%20%20%20%20%20%20%20%20%2F%5Cn%20%20%20%20%20%20%20%20comments%5Cn%20%20%20%20%20%20%20%20%2F%5Cn%20%20%20%20%5Ctmore%3A%20stuff()%2C%5Cn%20%20%20%20%5CtevenMore%3A%20stuff(%7B%5Cn%20%20%20%20%20%20%20%20%20%20value1%3A%20true%2C%5Cn%20%20%20%20%20%20%20%20%20%20value2%3A%20false%2C%5Cn%20%20%20%20%20%20%20%20%20%20value3%3A%20false%5Cn%20%20%20%20%20%20%20%20%7D)%5Cn%20%20%20%20%20%20%7D)%5Cn%20%20%20%20%20%20.filter(data%20%3D%3E%20theFilter(data))%5Cn%20%20%20%20%20%20.map((%7B%20theType%2C%20...data%20%7D)%20%3D%3E%20theMap(theType%2C%20data))%5Cn%20%20%20%20%20%20.retryWhen(errors%20%3D%3E%20errors.switchMap(err%20%3D%3E%20%7B%5Cn%20%20%20%20%20%20%20%20return%20navigator.onLine%5Cn%20%20%20%20%20%20%20%20%20%20%3F%20Observable.timer(3000%20%2F%20ms%20%2F)%5Cn%20%20%20%20%20%20%20%20%20%20%3A%20Observable.fromEvent(window%2C%20'online').take(1)%3B%5Cn%20%20%20%20%20%20%7D)))%3B%5Cn%7D%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D

locked-due-to-inactivity bug

Most helpful comment

All 3 comments

Thanks for the report, I agree that it looks worse. I have an idea on how to fix it :)

Could you open a different issue for the comment that gets indented weirdly, we should correct the indentation.

Thanks for the report and keep them coming if you see anything that doesn't look good to you

Nice. Can't wait to try it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frantic picture frantic  路  3Comments

jitendravyas picture jitendravyas  路  3Comments

brigand picture brigand  路  3Comments

jasonkuhrt picture jasonkuhrt  路  3Comments

jfmengels picture jfmengels  路  3Comments