Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 different reformatting for comments in default switch clause #4254

Open
1 task done
Conaclos opened this issue Mar 4, 2023 · 1 comment
Open
1 task done

🐛 different reformatting for comments in default switch clause #4254

Conaclos opened this issue Mar 4, 2023 · 1 comment
Labels
A-Formatter Area: formatter L-JavaScript Langauge: JavaScript S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@Conaclos
Copy link
Contributor

Conaclos commented Mar 4, 2023

Environment information

Rome v11.0.0-nightly.97e48b4

What happened?

The following code:

switch(5){default: // comment5
// comment5a
bar();//comment5b
break;
}

is formatted to:

switch (5) {
	default: // comment5
	//comment5b
		// comment5a
		bar();
		break;
}

is itself formatted to:

switch (5) {
	default: // comment5
		//comment5b
		// comment5a
		bar();
		break;
}

This triggers a reformat failure on cargo test.

Note that comments are also reordered: //comment5b should come after // comment5a.

EDIT: this does not affect switch case clauses.

Expected result

Reformatting the code should not change the formatting.

This is blocking #4234.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@Conaclos Conaclos added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Formatter Area: formatter L-JavaScript Langauge: JavaScript labels Mar 4, 2023
@Conaclos
Copy link
Contributor Author

Conaclos commented Mar 4, 2023

Prettier had the same issue in its previous version (see on the rome playground).

It is now fixed in its current version.

@Conaclos Conaclos changed the title 🐛 different reformatting for comments in switch clause 🐛 different reformatting for comments in default switch clause Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter L-JavaScript Langauge: JavaScript S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

1 participant