Skip to content

[MemberExpression] chained methods on single line #1282

@highflying

Description

@highflying

https://prettier.github.io/prettier/#%7B%22content%22%3A%22const%20somePromise%20%3D%20promise%5Cn%20%20.resolve()%5Cn%20%20.then(console.log)%5Cn%20%20.catch(err%20%3D%3E%20%7B%5Cn%20%20%20%20console.log(err)%5Cn%20%20%20%20return%20null%5Cn%20%20%7D)%3B%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3A%22all%22%2C%22bracketSpacing%22%3Afalse%2C%22jsxBracketSameLine%22%3Afalse%2C%22parser%22%3A%22%22%2C%22semi%22%3Afalse%2C%22useTabs%22%3Afalse%2C%22doc%22%3Afalse%7D%7D

Trying to understand how this:

const somePromise = promise.resolve().then(console.log).catch(err => {
  console.log(err)
  return null
})

is considered more readable than this:

const somePromise = promise
  .resolve()
  .then(console.log)
  .catch(err => {
    console.log(err)
    return null
  });

Doesn't feel like it matches up with how clean code should be (based on the Clean Code and Code Complete books)

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions