Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js_formatter): break nested destructured binding patterns #1054

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

faultyserver
Copy link
Contributor

Summary

Playground Link.

Nested destructuring of objects in a binding pattern means multiple braces will end up next to each other, which can be difficult to visually parse how deep in the pattern something is. This fixes the logic for breaking nested binding patterns over multiple lines to avoid this cluttering and match Prettier's behavior.

// Input
({nested: {once}}) => {
	bar();
};
({nested: {pattern: {twice}}}) => {
	bar();
};

// New output, matching Prettier
({ nested: { once } }) => {
  bar();
};
({
  nested: {
    pattern: { twice },
  },
}) => {
  bar();
};

Test Plan

The Prettier difference snapshot is deleted since the two now match, and I added a bunch of tests in a new spec test to cover all of the permutations here, including catch declarations.

Copy link

netlify bot commented Dec 5, 2023

Deploy Preview for rad-torte-839a59 ready!

Name Link
🔨 Latest commit 265716e
🔍 Latest deploy log https://app.netlify.com/sites/rad-torte-839a59/deploys/656e997eedc110000859af03
😎 Deploy Preview https://deploy-preview-1054--rad-torte-839a59.netlify.app/playground
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Dec 5, 2023
@Conaclos Conaclos merged commit 318c0e1 into main Dec 5, 2023
18 checks passed
@Conaclos Conaclos deleted the faulty/arrow-param-destructuring branch December 5, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants