How can I add parentheses and wrap html attribute in single return line component?
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Input:
export default function ModalDefault({ children }: props) {
return (
<div className={'fixed top-72 w-[100px] bg-blue-300/70 h-20'}>
{children}
</div>
);
}
Output:
export default function ModalDefault({ children }: props) {
return <div className={'fixed top-72 w-[100px] bg-blue-300/70 h-20'}>{children}</div>;
}
Expected output:
export default function ModalDefault({ children }: props) {
return (
<div
className={'fixed top-72 w-[100px] bg-blue-300/70 h-20'}
>
{children}
</div>
);
}
Why?
I want to add parentheses automatically and auto wrap every single attributes, but in single html return component, isn't working :,<
{
"singleQuote": true,
"semi": true,
"useTabs": false,
"tabWidth": 4,
"trailingComma": "all",
"printWidth": 200,
"bracketSpacing": true,
"bracketSameLine": false,
"singleAttributePerLine": true,
"arrowParens": "avoid",
"endOfLine": "auto"
}
this is my prettierrc file
how can i solve it?
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
Reproduce the TSX input in the Prettier playground with the supplied options, especially printWidth 200 and singleAttributePerLine. Compare the actual and expected output, then determine whether the request needs a formatter behavior change or documentation; done means the intended behavior is decided and verified against the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100