[JavaScript] Make consistent format for object property values with a string literal and template string
Description
Fixes https://github.com/prettier/prettier/issues/12408 Consistent format, do not break a new line for long string literals
Checklist
- [x] I’ve added tests to confirm my change works.
- [x] (If changing the API or CLI) I’ve documented the changes I’ve made (in the
docs/directory). - [x] (If the change is user-facing) I’ve added my changes to
changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md. - [x] I’ve read the contributing guidelines.
@fisker @sosukesuzuki Hey guys 👋, it's been over a month since I created my small PR that fixes the current inconsistency, can someone review it and say what you think?
Sorry for the long delay.
I'm not sure if we want to change it, at least not until a better solution found. Making an exception here is really bad. People will ask why long identifiers/numbers/bigints don't format like this. If you want to change the output, add more tests, we'll see if it's fine to accept.
@fisker which tests would you prefer that I add? Only for properties of an object?
long identifiers/numbers/bigints
@fisker added more tests
@fisker @sosukesuzuki friendly ping
The current behavior for string literals is intentional. Please see https://prettier.io/blog/2021/05/09/2.3.0.html#prevent-wrapping-object-properties-with-short-keys-10335httpsgithubcomprettierprettierpull10335-by-thorn0httpsgithubcomthorn0
If we're going to change something here, that should be the behavior for template literals.