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

Add 2.5 blog #11823

Merged
merged 42 commits into from Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6f62918
Mark highlights
sosukesuzuki Nov 17, 2021
a7ce132
Update intro
sosukesuzuki Nov 17, 2021
936a8e0
Draft
sosukesuzuki Nov 17, 2021
293f68c
Update changelog
sosukesuzuki Nov 18, 2021
f78efa5
Update changelog
sosukesuzuki Nov 18, 2021
eec36bd
Regenerate draft
sosukesuzuki Nov 18, 2021
7c57fb7
Update TS 4.5 blog URL
sosukesuzuki Nov 18, 2021
f9005f4
Regenerate draft
sosukesuzuki Nov 18, 2021
3f9814c
Fix by prettier
sosukesuzuki Nov 18, 2021
3be3454
Fix
sosukesuzuki Nov 18, 2021
ba8db16
Remove changelogs released already
sosukesuzuki Nov 18, 2021
cccaed9
Address review
sosukesuzuki Nov 18, 2021
ed8a27a
Update
sosukesuzuki Nov 21, 2021
dea9688
Regenerate draft
sosukesuzuki Nov 21, 2021
e922635
Regenerate draft
sosukesuzuki Nov 21, 2021
600e060
Regenerate
sosukesuzuki Nov 21, 2021
28aebb7
Update changelog_unreleased/typescript/11515.md
sosukesuzuki Nov 22, 2021
3a489e9
Update changelog_unreleased/typescript/11721.md
sosukesuzuki Nov 22, 2021
175de54
Update changelog_unreleased/mdx/11563.md
sosukesuzuki Nov 22, 2021
a2ba4ff
Update changelog_unreleased/mdx/11563.md
sosukesuzuki Nov 22, 2021
e0dc2ad
Update website/blog/2021-11-21-2.5.0.md
sosukesuzuki Nov 22, 2021
3824a34
Update website/blog/2021-11-21-2.5.0.md
sosukesuzuki Nov 22, 2021
a79a859
Regenerate
sosukesuzuki Nov 22, 2021
2e3d3e9
Address reviews
sosukesuzuki Nov 22, 2021
318bfc7
Regenerate
sosukesuzuki Nov 22, 2021
b3bc15c
Use examples
sosukesuzuki Nov 22, 2021
0b34c9f
Regenerate
sosukesuzuki Nov 22, 2021
f0a092c
Address review
sosukesuzuki Nov 22, 2021
88c2dfd
Renegrate
sosukesuzuki Nov 22, 2021
756100d
Address review
sosukesuzuki Nov 22, 2021
20e5d24
Regenerate
sosukesuzuki Nov 22, 2021
2d5f966
MDX 2 comments => MDX v2 comment syntax
sosukesuzuki Nov 22, 2021
af3304c
Fix
sosukesuzuki Nov 23, 2021
0e63efe
Update changelog_unreleased/blog-post-intro.md
sosukesuzuki Nov 23, 2021
2669005
Update changelog_unreleased/typescript/11721.md
sosukesuzuki Nov 23, 2021
5b9d79d
Regenerate
sosukesuzuki Nov 23, 2021
c06fbdf
Update changelog_unreleased/typescript/11515.md
sosukesuzuki Nov 24, 2021
acd68e1
Regenerate
sosukesuzuki Nov 24, 2021
b4aaf35
Address review
sosukesuzuki Nov 24, 2021
a1152f1
Regenerate
sosukesuzuki Nov 25, 2021
6255455
Address review
sosukesuzuki Nov 25, 2021
062aeef
Regenerate
sosukesuzuki Nov 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog_unreleased/blog-post-intro.md
@@ -0,0 +1,9 @@
---
author: "Sosuke Suzuki (@sosukesuzuki)"
authorURL: "https://github.com/sosukesuzuki"
title: "Prettier 2.5: TypeScript 4.5 and MDX v2 comment syntax!"
---

This release adds support for [TypeScript 4.5](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/)'s new syntax and [MDX v2](https://mdxjs.com/blog/v2/) comment syntax!

If you enjoy Prettier and would like to support our work, consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, including [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel).
3 changes: 0 additions & 3 deletions changelog_unreleased/cli/11514.md

This file was deleted.

31 changes: 30 additions & 1 deletion changelog_unreleased/html/11827.md
@@ -1 +1,30 @@
#### Reverts #7865, keeping class names on the same line (#11827 by @jlongster)
#### [HIGHLIGHT]Collapse HTML `class` attributes onto one line (#11827 by @jlongster)

Reverts [#7865](https://github.com/prettier/prettier/pull/7865).

While this was intended to be useful for users of CSS libraries like Tailwind that tend to result in large numbers of classes on elements, it became clear that our heuristics for where to split the class list on to multiple lines were unable to consistently produce good results. We’re still considering better ways to format HTML with lots of classes — consider [discussing with us](https://github.com/prettier/prettier/issues/7863).

<!-- prettier-ignore -->
```html
<!-- Input -->
<div
class="SomeComponent__heading-row d-flex flex-column flex-lg-row justify-content-start justify-content-lg-between align-items-start align-items-lg-center"
></div>

<!-- Prettier stable -->
<div
class="
SomeComponent__heading-row
d-flex
flex-column flex-lg-row
justify-content-start justify-content-lg-between
align-items-start align-items-lg-center
"
></div>

<!-- Prettier main -->
<div
class="SomeComponent__heading-row d-flex flex-column flex-lg-row justify-content-start justify-content-lg-between align-items-start align-items-lg-center"
></div>

```
2 changes: 1 addition & 1 deletion changelog_unreleased/javascript/11593.md
@@ -1,6 +1,6 @@
#### Fix parentheses around sequence expression as body of arrow chain (#11593 by @bakkot)

The required parentheses around sequence expressions as the body of arrow functions were dropped for chained arrows, causing incorrect code to be generated. Now they are included.
The required parentheses around sequence expressions as the body of arrow functions are now preserved for chained arrows. Previously, Prettier removed them, which resulted in invalid syntax.

<!-- prettier-ignore -->
```jsx
Expand Down
2 changes: 2 additions & 0 deletions changelog_unreleased/javascript/11750.md
@@ -1,5 +1,7 @@
#### Ignore errors for sloppy mode syntax (#11750 by @fisker, #11778 by @sosukesuzuki)

JavaScript’s [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) adds several useful errors to prevent mistakes. Some of these errors are syntax errors that occur at parse time. Since Prettier’s goal is to format all syntactically valid JavaScript code regardless of whether it will actually run, we’ve opted to leave this error checking to linters, compilers, and the runtime.

<!-- prettier-ignore -->
```jsx
// Input
Expand Down
15 changes: 8 additions & 7 deletions changelog_unreleased/javascript/11800.md
@@ -1,22 +1,23 @@
#### Respect spacing for between expressions and parentheses in embedded CSS (#11800 by @sosukesuzuki)

<!-- Optional description if it makes sense. -->

<!-- prettier-ignore -->
```jsx
// Input
const paragraph2 = css`
transform: ${expr}(30px);
transform1: ${expr}(30px);
transform2: ${expr} (30px);
`;

// Prettier stable
// Prettier 2.4
const paragraph2 = css`
transform: ${expr} (30px);
transform1: ${expr} (30px);
transform2: ${expr} (30px);
`;

// Prettier main
// Prettier 2.5
const paragraph2 = css`
transform: ${expr}(30px);
transform1: ${expr}(30px);
transform2: ${expr} (30px);
`;

```
18 changes: 1 addition & 17 deletions changelog_unreleased/javascript/11835.md
Expand Up @@ -2,28 +2,12 @@

<!-- prettier-ignore -->
```jsx
// Input
// Example
class Foo {
#brand;
static isC(obj) {
return #brand in Foo;
}
}

// Prettier stable
SyntaxError: Unexpected token #brand (4:12)
2 | #brand;
3 | static isC(obj) {
> 4 | return #brand in Foo;
| ^
5 | }
6 | }

// Prettier main
class Foo {
#brand;
static isC(obj) {
return #brand in Foo;
}
}
```
6 changes: 3 additions & 3 deletions changelog_unreleased/markdown/11685.md
@@ -1,6 +1,6 @@
#### Keep trailing commas for type parameters in embedded TSX (#11685 by @sosukesuzuki)

<!-- Optional description if it makes sense. -->
The trailing comma is necessary to prevent TypeScript from treating the `<T>` as the beginning of a JSX expression.

<!-- prettier-ignore -->
````md
Expand All @@ -11,11 +11,11 @@ const test = <T,>(value: T) => {};

<!-- Prettier stable -->
```tsx
const test = <T,>(value: T) => {};
const test = <T>(value: T) => {};
```

<!-- Prettier main -->
```tsx
const test = <T>(value: T) => {};
const test = <T,>(value: T) => {};
```
````
12 changes: 3 additions & 9 deletions changelog_unreleased/mdx/11563.md
@@ -1,21 +1,15 @@
#### Add support for MDX 2 comments (#11563 by @wooorm)
#### [HIGHLIGHT]Add support for MDX v2 comment syntax (#11563 by @wooorm)

This adds basic support for MDX 2 comments (JavaScript-style comments) in
addition to existing MDX 1 comments (HTML-style comments).
This adds basic support for MDX v2 comment syntax (JavaScript-style comments) in addition to the existing support MDX v1 comment syntax (HTML-style comments).

Note that in MDX 2, more complex comments and whole expressions can be used
inside braces.
This currently only supports a single comment on one line so that
`{/* prettier-ignore */}` can be used, but doesn’t support most of MDX 2.
**Note**: Prettier currently only supports the new comment syntax for single-line comments (so that `{/* prettier-ignore */}` can be used), and doesn’t support the rest of MDX v2.

<!-- prettier-ignore -->
```mdx
Input:

{/*A comment*/}

Prettier stable:

{/_A comment_/}

Prettier main:
Expand Down
13 changes: 0 additions & 13 deletions changelog_unreleased/scss/11487.md

This file was deleted.

2 changes: 1 addition & 1 deletion changelog_unreleased/scss/11637.md
@@ -1,4 +1,4 @@
#### Improve `with (...)` formatting (#11637 by @sosukesuzuki)
#### Improve `@use with` formatting (#11637 by @sosukesuzuki)

<!-- prettier-ignore -->
```scss
Expand Down
5 changes: 3 additions & 2 deletions changelog_unreleased/typescript/11515.md
@@ -1,6 +1,7 @@
#### Avoid extra offset in arrow function body when using long types (#11515 by @kachkaev and @thorn0)
#### [HIGHLIGHT]Avoid extra offset in arrow function body when using long types (#11515 by @kachkaev and @thorn0)

Starting with Prettier 2.3.0, type declarations in arrow functions could affect function body offset. Changing the length of the type annotation could produce large diffs and thus increased the chance of git conflicts. To prevent this, function body offset was stabilized.
Starting with Prettier 2.3.0, type declarations in arrow functions could affect function body indentation. Changing the length of the type annotation could produce large diffs and thus increased the chance of git conflicts. To prevent this, function body offset was stabilized.<br>
**Note**: This change may affect a large number of lines in your codebase.

<!-- prettier-ignore -->
```tsx
Expand Down
51 changes: 9 additions & 42 deletions changelog_unreleased/typescript/11721.md
@@ -1,45 +1,21 @@
#### Support TypeScript 4.5 (#11721, #11723, #11813 by @sosukesuzuki)
#### [HIGHLIGHT]Support TypeScript 4.5 (#11721, #11723, #11813 by @sosukesuzuki)

Support new TypeScript 4.5 features.
We’ve added support for TypeScript 4.5’s new syntax features:

##### [`type` Modifiers on Import Names](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#type-on-import-names)
##### [`type` Modifiers on Import Names](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names)

<!-- prettier-ignore -->
```ts
// Input
import { type A } from "mod";

// Prettier stable
SyntaxError: ',' expected. (1:15)

// Prettier main
// Example
import { type A } from "mod";

```
j-f1 marked this conversation as resolved.
Show resolved Hide resolved

##### [Private Field Presence Checks](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-rc/#private-field-presence-checks)
##### [Private Field Presence Checks](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#private-field-presence-checks)

<!-- prettier-ignore -->
```ts
// Input
class Foo {
#prop1;
method() {
return #prop1 in this;
}
}

// Prettier stable
SyntaxError: Private identifiers are not allowed outside class bodies. (4:12)
2 | #prop1;
3 | method() {
> 4 | return #prop1 in this;
| ^
5 | }
6 | }
7 |

// Prettier main
// Example
class Foo {
#prop1;
method() {
Expand All @@ -49,24 +25,15 @@ class Foo {

```

##### [Import Assertions](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-rc/#import-assertions)
##### [Import Assertions](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#import-assertions)

<!-- prettier-ignore -->
```ts
j-f1 marked this conversation as resolved.
Show resolved Hide resolved
// Input
import obj from "./something.json" assert { type: "json" };

// Prettier stable
SyntaxError: ';' expected. (1:36)
> 1 | import obj from "./something.json" assert { type: "json" };
| ^
2 |

// Prettier main
// Example
import obj from "./something.json" assert { type: "json" };

```

##### Handle `.mts` and `.cts`

Handle new file extensions `.mts` and `.cts`.
Prettier will now format files with `.mts` and `.cts` extensions as TypeScript.