question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[resolved] [HTML] allow corresponding option to jsxBracketSameLine

See original GitHub issue

Note: Read this comment to make sure you’re up-to-speed on what this issue is and is not about: https://github.com/prettier/prettier/issues/5377#issuecomment-628213559


For React/JSX - Prettier has an option to allow tags to close on the same line as the declaration, rather then on a new line: jsxBracketSameLine: true:

<button
  className="prettier-class"
  id="prettier-id"
  onClick={this.handleClick}>
  Click Here
</button>

jsxBracketSameLine: false:

<button
  className="prettier-class"
  id="prettier-id"
  onClick={this.handleClick}
>
  Click Here
</button>

With Prettier 1.15.1, at least for the Angular parser, there is no corresponding option, so all HTML is formatted like this: Input:

<my-component class="wcd-flex-1 dialog-contents wcd-scroll-vertical"
		      [foo]="bar">
</my-component>

Output:

<my-component
    class="wcd-flex-1 dialog-contents wcd-scroll-vertical"
	[foo]="bar"
>
</my-component>

Playground link

It would be nice to have a flag to set it such that the output of the above would be:

<my-component
    class="wcd-flex-1 dialog-contents wcd-scroll-vertical"
	[foo]="bar">
</my-component>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:434
  • Comments:292 (68 by maintainers)

github_iconTop GitHub Comments

207reactions
alexander-akaitcommented, Aug 22, 2020

And so, it took 2 weeks. No negative reaction from maintainers (most of positive or neutral). I think it’s time for us to move on. I hope no one will be angry (including prettier maintainers).

I think consolidating of the bracketSameLine option is the best solution here. In fact, we don’t even create a new option. It’s just an improvement.

Roadmap (should be done in one PR):

  1. Deprecate jsxBracketSameLine (soft, only deprecation message, logic should not be changed, the jsxBracketSameLine option only affected on jsx).
  2. Implement the new bracketSameLine option (for HTML, JSX, Vue, Angular, using bracketSameLine: true sets jsxBracketSameLine to true too).
  3. Improve tests (need tests for HTML, Vue, Angular) and docs.

I ask you to refrain from unnecessary/spam/off topic/etc comments so that we do not lose this comment. You can express emotions using emoji ⭐ And yes, PR welcome.

104reactions
matt328commented, Nov 13, 2018

I don’t think I’ve ever seen any markup language with the closing brackets on a separate line. I’d like to see angleBracketSameLine or some equivalent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier 2.4: new bracketSameLine option and TypeScript 4.4 ...
This release renames the `jsxBracketSameLine` option to `bracketSameLine`, which supports HTML, Vue, and Angular in addition to JSX.
Read more >
Why do I keep getting "[eslint] Delete `CR` [prettier/prettier]"?
Try setting the "endOfLine":"auto" in your .prettierrc (or .prettierrc.json) file (inside the object). Or set 'prettier/prettier': [ 'error' ...
Read more >
prettier-plugin-svelte | Yarn - Package Manager
Format your HTML, CSS, and JavaScript using prettier; Format Svelte syntax, e.g. each loops, if statements, await blocks, etc.
Read more >
Help prompts for different compilers
--strict Enable all strict type-checking options. --noImplicitAny Raise error on ... --baseUrl Base directory to resolve non-absolute module names.
Read more >
eslint-plugin-prettierx - npm
Almost all plugins include configs to enable several of its rules. ... These are the predefined prettierx options and it is the best...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found