More consistent parentheses preservation in multiline expressions
Open
Nobody has claimed this yet.
area:arrow functions
lang:javascript
status:needs discussion
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.1.2
Playground link
--parser typescript
--trailing-comma none
Input:
ctx.renderPage = () => (
originalRenderPage({
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
})
);
Output:
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />)
});
Expected behavior:
For the parentheses around this multiline expression to be preserved (why is Prettier even removing my manually placed parens in the first place?). It greatly improves legibility, and it would be in line with JSX component expression formatting:
const SomeComponent = () => (
<div>
<h1>Hello</h1>
<p>World</p>
</div>
);
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 with the linked Prettier Playground reproduction using the TypeScript parser and compare the shown input and output. The work is done when the parentheses around the multiline arrow-function expression are preserved consistently with the JSX example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100