Skip to content

Further improve method chain breaking heuristic#7889

Merged
thorn0 merged 1 commit intoprettier:masterfrom
thorn0:tweak-method-chains
Apr 15, 2020
Merged

Further improve method chain breaking heuristic#7889
thorn0 merged 1 commit intoprettier:masterfrom
thorn0:tweak-method-chains

Conversation

@thorn0
Copy link
Copy Markdown
Member

@thorn0 thorn0 commented Mar 27, 2020

fixes #3594
fixes #3621

A continuation of the work started here: #6685

A method chain now is always split onto multiple lines if:

  • it's an expression statement and all its arguments are literals or UPPERCASE_CONSTANTs (the "fluent configuration" pattern),
  • any call but the first one has more than two arguments, or
  • the chain starts with a constructor call.

Try the playground for this PR

To install it locally, run npm install thorn0/prettier#tweak-method-chains

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/pr-XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep short promise chains indented Excessive line breaks for a short comparison expression

5 participants