prettier / prettier/prettier

Configure whitespace display css for custom components

Open
#5,415 8 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lang:angular lang:html lang:vue status:needs discussion type:option request
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

--html-whitespace-sensitivity css is nice when working with native HTML as it sets the display status properly (most of the time)

However, for custom components, it seems to always err on the side of caution and defaults to inline.

It would be nice if it were possible to set default display for custom JSX/NG/Vue? components. This would be nice for codebases where many components may be used in place of HTML elements.

Prettier 1.15.1
Playground link

--parser angular

Input:

<div>
  Something
</div>

<span>
  Something
</span>

<custom-inline>
  Something
</custom-inline>

<custom-block>
  Something Else
</custom-block>

<!-- display: block -->
<custom-block>
  Something Else
</custom-block>

<!-- it would be nice to set custom-block as "block" always -->

Output:

<div>Something</div>

<span> Something </span>

<custom-inline> Something </custom-inline>

<custom-block> Something Else </custom-block>

<!-- display: block -->
<custom-block>Something Else</custom-block>

<!-- it would be nice to set custom-block as "block" always -->

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Prettier Playground example using --parser angular and reproduce the displayed whitespace behavior for native and custom elements. Determine how a configurable default display value for custom JSX, Angular, or Vue components should be specified, then verify that the example preserves block-like and inline-like formatting as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, css, javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.