Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember / glimmer: Preserve self-closing tags #13691

Merged
merged 3 commits into from Jan 4, 2023

Conversation

dcyriller
Copy link
Collaborator

Description

As reported in #13624, self-closing tags are supported by Ember (doc).

This PR would preserve them. The PR would close #13624.

Checklist

  • I’ve added tests to confirm my change works.
  • [] (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -41,6 +41,7 @@ const voidTags = new Set(htmlVoidElements);
function isVoid(node) {
return (
voidTags.has(node.tag) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the html void tag check?

<img> should always self closed. If anyone wrote <img></img>, we can just ignore.

Copy link
Member

@fisker fisker Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<img></img> can't be parsed at all. So let's remove it.

@fisker
Copy link
Member

fisker commented Jan 4, 2023

I'm going to merge this, and address #13691 (comment) in another PR.

@fisker fisker merged commit b77d912 into prettier:main Jan 4, 2023
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Jan 11, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [prettier](https://prettier.io) ([source](https://github.com/prettier/prettier)) | devDependencies | patch | [`2.8.1` -> `2.8.2`](https://renovatebot.com/diffs/npm/prettier/2.8.1/2.8.2) |

---

### Release Notes

<details>
<summary>prettier/prettier</summary>

### [`v2.8.2`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#&#8203;282)

[Compare Source](prettier/prettier@2.8.1...2.8.2)

[diff](prettier/prettier@2.8.1...2.8.2)

##### Don't lowercase link references ([#&#8203;13155](prettier/prettier#13155) by [@&#8203;DerekNonGeneric](https://github.com/DerekNonGeneric) & [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```markdown
<!-- Input -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].

[Keep a Changelog]: https://example.com/

<!-- Prettier 2.8.1 -->
We now don't strictly follow the release notes format suggested by [Keep a Changelog].

[keep a changelog]: https://example.com/
<!--
^^^^^^^^^^^^^^^^^^ lowercased
-->

<!-- Prettier 2.8.2 -->
<Same as input>
```

##### Preserve self-closing tags ([#&#8203;13691](prettier/prettier#13691) by [@&#8203;dcyriller](https://github.com/dcyriller))

<!-- prettier-ignore -->

```hbs
{{! Input }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component></Component>

{{! Prettier 2.8.1 }}
<div></div>
<div></div>
<custom-component></custom-component>
<custom-component></custom-component>
<i></i>
<i></i>
<Component />
<Component />

{{! Prettier 2.8.2 }}
<div />
<div></div>
<custom-component />
<custom-component></custom-component>
<i />
<i></i>
<Component />
<Component />
```

##### Allow custom "else if"-like blocks with block params ([#&#8203;13930](prettier/prettier#13930) by [@&#8203;jamescdavis](https://github.com/jamescdavis))

[#&#8203;13507](prettier/prettier#13507) added support for custom block keywords used with `else`, but failed to allow block params. This updates printer-glimmer to allow block params with custom "else if"-like blocks.

<!-- prettier-ignore -->

```hbs
{{! Input }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading as |book|}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}

{{! Prettier 2.8.1 }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}

{{! Prettier 2.8.2 }}
{{#when isAtWork as |work|}}
  Ship that
  {{work}}!
{{else when isReading as |book|}}
  You can finish
  {{book}}
  eventually...
{{else}}
  Go to bed!
{{/when}}
```

##### Preserve empty lines between nested SCSS maps ([#&#8203;13931](prettier/prettier#13931) by [@&#8203;jneander](https://github.com/jneander))

<!-- prettier-ignore -->

```scss
/* Input */
$map: (
  'one': (
     'key': 'value',
  ),

  'two': (
     'key': 'value',
  ),
)

/* Prettier 2.8.1 */
$map: (
  'one': (
     'key': 'value',
  ),
  'two': (
     'key': 'value',
  ),
)

/* Prettier 2.8.2 */
$map: (
  'one': (
     'key': 'value',
  ),

  'two': (
     'key': 'value',
  ),
)
```

##### Fix missing parentheses when an expression statement starts with `let[` ([#&#8203;14000](prettier/prettier#14000), [#&#8203;14044](prettier/prettier#14044) by [@&#8203;fisker](https://github.com/fisker), [@&#8203;thorn0](https://github.com/thorn0))

<!-- prettier-ignore -->

```jsx
// Input
(let[0] = 2);

// Prettier 2.8.1
let[0] = 2;

// Prettier 2.8.1 (second format)
SyntaxError: Unexpected token (1:5)
> 1 | let[0] = 2;
    |     ^
  2 |

// Prettier 2.8.2
(let)[0] = 2;
```

##### Fix semicolon duplicated at the end of LESS file ([#&#8203;14007](prettier/prettier#14007) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
@&#8203;variable: {
  field: something;
};

// Prettier 2.8.1
@&#8203;variable: {
  field: something;
}; ;

// Prettier 2.8.2
@&#8203;variable: {
  field: something;
};
```

##### Fix no space after unary minus when followed by opening parenthesis in LESS ([#&#8203;14008](prettier/prettier#14008) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
.unary_minus_single {
  margin: -(@&#8203;a);
}

.unary_minus_multi {
  margin: 0 -(@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}

// Prettier 2.8.1
.unary_minus_single {
  margin: - (@&#8203;a);
}

.unary_minus_multi {
  margin: 0 - (@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}

// Prettier 2.8.2
.unary_minus_single {
  margin: -(@&#8203;a);
}

.unary_minus_multi {
  margin: 0 -(@&#8203;a);
}

.binary_minus {
  margin: 0 - (@&#8203;a);
}
```

##### Do not change case of property name if inside a variable declaration in LESS ([#&#8203;14034](prettier/prettier#14034) by [@&#8203;mvorisek](https://github.com/mvorisek))

<!-- prettier-ignore -->

```less
// Input
@&#8203;var: {
  preserveCase: 0;
};

// Prettier 2.8.1
@&#8203;var: {
  preservecase: 0;
};

// Prettier 2.8.2
@&#8203;var: {
  preserveCase: 0;
};
```

##### Fix formatting for auto-accessors with comments ([#&#8203;14038](prettier/prettier#14038) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
class A {
  @&#8203;dec()
  // comment
  accessor b;
}

// Prettier 2.8.1
class A {
  @&#8203;dec()
  accessor // comment
  b;
}

// Prettier 2.8.1 (second format)
class A {
  @&#8203;dec()
  accessor; // comment
  b;
}

// Prettier 2.8.2
class A {
  @&#8203;dec()
  // comment
  accessor b;
}
```

##### Add parentheses for TSTypeQuery to improve readability ([#&#8203;14042](prettier/prettier#14042) by [@&#8203;onishi-kohei](https://github.com/onishi-kohei))

<!-- prettier-ignore -->

```tsx
// Input
a as (typeof node.children)[number]
a as (typeof node.children)[]
a as ((typeof node.children)[number])[]

// Prettier 2.8.1
a as typeof node.children[number];
a as typeof node.children[];
a as typeof node.children[number][];

// Prettier 2.8.2
a as (typeof node.children)[number];
a as (typeof node.children)[];
a as (typeof node.children)[number][];
```

##### Fix displacing of comments in default switch case ([#&#8203;14047](prettier/prettier#14047) by [@&#8203;thorn0](https://github.com/thorn0))

It was a regression in Prettier 2.6.0.

<!-- prettier-ignore -->

```jsx
// Input
switch (state) {
  default:
    result = state; // no change
    break;
}

// Prettier 2.8.1
switch (state) {
  default: // no change
    result = state;
    break;
}

// Prettier 2.8.2
switch (state) {
  default:
    result = state; // no change
    break;
}
```

##### Support type annotations on auto accessors via `babel-ts` ([#&#8203;14049](prettier/prettier#14049) by [@&#8203;sosukesuzuki](https://github.com/sosukesuzuki))

[The bug that `@babel/parser` cannot parse auto accessors with type annotations](babel/babel#15205) has been fixed. So we now support it via `babel-ts` parser.

<!-- prettier-ignore -->

```tsx
class Foo {
  accessor prop: number;
}
```

##### Fix formatting of empty type parameters ([#&#8203;14073](prettier/prettier#14073) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
const foo: bar</* comment */> = () => baz;

// Prettier 2.8.1
Error: Comment "comment" was not printed. Please report this error!

// Prettier 2.8.2
const foo: bar</* comment */> = () => baz;
```

##### Add parentheses to head of `ExpressionStatement` instead of the whole statement ([#&#8203;14077](prettier/prettier#14077) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
({}).toString.call(foo) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo);

// Prettier 2.8.1
({}.toString.call(foo) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo));

// Prettier 2.8.2
({}).toString.call(foo.forEach) === "[object Array]"
  ? foo.forEach(iterateArray)
  : iterateObject(foo);
```

##### Fix comments after directive ([#&#8203;14081](prettier/prettier#14081) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
"use strict" /* comment */;

// Prettier 2.8.1 (with other js parsers except `babel`)
Error: Comment "comment" was not printed. Please report this error!

// Prettier 2.8.2
<Same as input>
```

##### Fix formatting for comments inside JSX attribute ([#&#8203;14082](prettier/prettier#14082) with by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
function MyFunctionComponent() {
  <button label=/*old*/"new">button</button>
}

// Prettier 2.8.1
Error: Comment "old" was not printed. Please report this error!

// Prettier 2.8.2
function MyFunctionComponent() {
  <button label=/*old*/ "new">button</button>;
}
```

##### Quote numeric keys for json-stringify parser ([#&#8203;14083](prettier/prettier#14083) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```jsx
// Input
{0: 'value'}

// Prettier 2.8.1
{
  0: "value"
}

// Prettier 2.8.2
{
  "0": "value"
}
```

##### Fix removing commas from function arguments in maps ([#&#8203;14089](prettier/prettier#14089) by [@&#8203;sosukesuzuki](https://github.com/sosukesuzuki))

<!-- prettier-ignore -->

```scss
/* Input */
$foo: map-fn(
  (
    "#{prop}": inner-fn($first, $second),
  )
);

/* Prettier 2.8.1 */
$foo: map-fn(("#{prop}": inner-fn($first $second)));

/* Prettier 2.8.2 */
$foo: map-fn(
  (
    "#{prop}": inner-fn($first, $second),
  )
);

```

##### Do not insert space in LESS property access ([#&#8203;14103](prettier/prettier#14103) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```less
// Input
a {
  color: @&#8203;colors[@&#8203;white];
}

// Prettier 2.8.1
a {
  color: @&#8203;colors[ @&#8203;white];
}

// Prettier 2.8.2
<Same as input>
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45MC4wIiwidXBkYXRlZEluVmVyIjoiMzQuOTcuNSJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1708
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@dcyriller dcyriller deleted the preserve-self-closing branch January 17, 2023 13:04
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ember handlebars formatting doesn't allow for self-closing tags
3 participants