Skip to content

Commit

Permalink
feat: collapse JSX brackets (#3)
Browse files Browse the repository at this point in the history
When JSX attributes end up spanning multiple lines, Prettier's default setting will put the single closing angle bracket on a new line, which adds awkward visual space between an element and it's children.

Collapsing these onto the last line of the attribute list makes the hierarchy more clear, especially as components get nested further.

This does _not_ affect self-closing JSX tags, which will still have the closing bracket on a new line to clearly indicate the lack of children.
  • Loading branch information
faultyserver authored and Alex Van Camp committed Oct 26, 2019
1 parent 38592c7 commit 154f783
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ module.exports = {
* So, we find single quotes easier to type and prefer them. */
singleQuote: true,

/* When JSX attributes end up spanning multiple lines, Prettier's default
* setting will put the single closing angle bracket on a new line, which
* adds awkward visual space between an element and it's children.
*
* Collapsing these onto the last line of the attribute list makes the
* hierarchy more clear, especially as components get nested further.
*
* This does _not_ affect self-closing JSX tags, which will still have the
* closing bracket on a new line to clearly indicate the lack of children.
*/
jsxBracketSameLine: true,

/* It's true that Prettier warns pretty heavily against setting
* this higher than 80 columns: https://prettier.io/docs/en/options.html#print-width
*
Expand Down

0 comments on commit 154f783

Please sign in to comment.