End-of-line comment inside object literal moved to next line
Open
Nobody has claimed this yet.
area:object literals
lang:javascript
status:needs discussion
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 1.19.1
Playground link
--parser babel
Input:
const x = {
c: { // Very important key.
a: 123
}
};
Output:
const x = {
c: {
// Very important key.
a: 123
}
};
Expected behavior:
The comment should not be moved down.
Also affects TypeScript.
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 Playground example with the Babel parser and the JSX object literal shown in the issue; compare the behavior for JavaScript and TypeScript. Trace the formatter's comment-placement path for end-of-line comments, and consider the issue done when the comment remains on the same line as the object property in both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100