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

📝 Wrapped JSX Expressions in Arrow Chains should be parenthesized #1024

Closed
faultyserver opened this issue Dec 3, 2023 · 1 comment · Fixed by #1033
Closed

📝 Wrapped JSX Expressions in Arrow Chains should be parenthesized #1024

faultyserver opened this issue Dec 3, 2023 · 1 comment · Fixed by #1033
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@faultyserver
Copy link
Contributor

Description

Playground Link

// Biome Output
import("./AFileName").then(
  ({ default: TheFileComponent }) =>
    (componentProps) =>
      <TheFileComponent {...componentProps} {...otherProps} />,
);


// Prettier Output
import("./AFileName").then(
  ({ default: TheFileComponent }) =>
    (componentProps) => (
      <TheFileComponent {...componentProps} {...otherProps} />
    ),
);

Arrow chains are almost entirely compatible with Prettier, this seems like the last remaining difference, where JSX expressions that break onto a separate line should get parenthesized, but Biome just puts them on the next line.

Interestingly, it looks like the IR for these is pretty identical between Prettier and Biome, so I think this could be related to what #917 tried to fix. The JSX expression gets interned as part of the BestFitting variants, and I think it's assuming that it won't break, so the if_group_breaks format element doesn't end up rendering the parentheses.

But it could also just be that the if_group_breaks is looking at the wrong group. The JSX expression itself is on a single line, but the parent obviously breaks.

@faultyserver faultyserver added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project labels Dec 3, 2023
@Conaclos Conaclos changed the title 📎 Wrapped JSX Expressions in Arrow Chains should be parenthesized 📝 Wrapped JSX Expressions in Arrow Chains should be parenthesized Dec 3, 2023
@faultyserver
Copy link
Contributor Author

faultyserver commented Dec 3, 2023

A simplified, but slightly different test case: Playground Link.

((C) => (props) => <C {...props} />);
(({C}) => (props) => <C {...props} />);

// Prettier output
(C) => (props) => <C {...props} />;
({ C }) =>
	(props) => <C {...props} />;

// Biome output
(C) => (props) => <C {...props} />;
({ C }) =>
	(props) =>
		<C {...props} />;

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 S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant