RFC: don't preserve line breaks in object literals if all the properties are shorthand
Open
Nobody has claimed this yet.
area:object literals
lang:javascript
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Let's format
const name = {
firstName,
lastName,
};
into
const name = { firstName, lastName };
Thoughts? Counterexamples?
Update, based on the discussion below:
Line breaks should not be preserved if
- all the properties are shorthand or
- the first property is a spread whose operand is an identifier and the rest of the properties are shorthand.
If the object literal contains empty lines or comments, line breaks should be preserved (the current behavior is kept).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the object-literal examples in the issue with the formatter and reviewing the current behavior for shorthand properties, identifier spreads, comments, and empty lines. Done means the stated line-break rules are implemented without changing preservation around comments or empty lines, with formatting behavior verified against the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100