Clean changelog_unreleased
This commit is contained in:
1 parent
04aa850fde
commit
7fc196e96b
14 files changed
-308
No files matched your search
@@ -1,9 +0,0 @@
|
||||
---
|
||||
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).
|
||||
@@ -1,14 +0,0 @@
|
||||
#### Uses the opposite quote type for quotes inside mustache statements in attributes (#11524 by @bmaehr)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{!-- Input --}}
|
||||
<div title="{{t 'login.username.description'}}" />
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<div title="{{t 'login.username.description'}}" />
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<div title="{{t "login.username.description"}}" />
|
||||
|
||||
```
|
||||
@@ -1,30 +0,0 @@
|
||||
#### [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>
|
||||
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### 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 are now preserved for chained arrows. Previously, Prettier removed them, which resulted in invalid syntax.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const f = () => () => (0, 1);
|
||||
|
||||
// Prettier stable
|
||||
const f = () => () => 0, 1;
|
||||
|
||||
// Prettier main
|
||||
const f = () => () => (0, 1);
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
#### 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
|
||||
function foo() { var bar = 1; delete bar; }
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Deleting local variable in strict mode. (1:31)
|
||||
> 1 | function foo() { var bar = 1; delete bar; }
|
||||
| ^
|
||||
|
||||
// Prettier main
|
||||
function foo() {
|
||||
var bar = 1;
|
||||
delete bar;
|
||||
}
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
#### Respect spacing for between expressions and parentheses in embedded CSS (#11800 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const paragraph2 = css`
|
||||
transform1: ${expr}(30px);
|
||||
transform2: ${expr} (30px);
|
||||
`;
|
||||
|
||||
// Prettier 2.4
|
||||
const paragraph2 = css`
|
||||
transform1: ${expr} (30px);
|
||||
transform2: ${expr} (30px);
|
||||
`;
|
||||
|
||||
// Prettier 2.5
|
||||
const paragraph2 = css`
|
||||
transform1: ${expr}(30px);
|
||||
transform2: ${expr} (30px);
|
||||
`;
|
||||
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Support ES2022 class-private-fields-in syntax in `espree` parser (#11835 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Example
|
||||
class Foo {
|
||||
#brand;
|
||||
static isC(obj) {
|
||||
return #brand in Foo;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### Keep trailing commas for type parameters in embedded TSX (#11685 by @sosukesuzuki)
|
||||
|
||||
The trailing comma is necessary to prevent TypeScript from treating the `<T>` as the beginning of a JSX expression.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
````md
|
||||
<!-- Input -->
|
||||
```tsx
|
||||
const test = <T,>(value: T) => {};
|
||||
```
|
||||
|
||||
<!-- Prettier stable -->
|
||||
```tsx
|
||||
const test = <T>(value: T) => {};
|
||||
```
|
||||
|
||||
<!-- Prettier main -->
|
||||
```tsx
|
||||
const test = <T,>(value: T) => {};
|
||||
```
|
||||
````
|
||||
@@ -1,17 +0,0 @@
|
||||
#### [HIGHLIGHT]Add support for MDX v2 comment syntax (#11563 by @wooorm)
|
||||
|
||||
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**: 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:
|
||||
{/*A comment*/}
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
#### Improve `@use with` formatting (#11637 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
// Input
|
||||
@use 'library' with (
|
||||
$black: #222,
|
||||
$border-radius: 0.1rem,
|
||||
$font-family: 'Helvetica, sans-serif'
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
@use "library" with
|
||||
($black: #222, $border-radius: 0.1rem, $font-family: "Helvetica, sans-serif");
|
||||
|
||||
// Prettier main
|
||||
@use 'library' with (
|
||||
$black: #222,
|
||||
$border-radius: 0.1rem,
|
||||
$font-family: 'Helvetica, sans-serif'
|
||||
);
|
||||
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix `@forward with` formatting error (#11683 by @sriramarul, @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
// Input
|
||||
@forward 'foo.scss' with ($components: red);
|
||||
|
||||
// Prettier stable
|
||||
TypeError: Cannot read properties of undefined (reading 'type')
|
||||
|
||||
// Prettier main
|
||||
@forward "foo.scss" with (
|
||||
$components: red
|
||||
);
|
||||
|
||||
```
|
||||
@@ -1,37 +0,0 @@
|
||||
#### [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 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
|
||||
// Input
|
||||
const MyComponentWithLongName: React.VoidFunctionComponent<MyComponentWithLongNameProps> = ({ x, y }) => {
|
||||
const a = useA();
|
||||
return <div>{x + y + a}</div>;
|
||||
};
|
||||
|
||||
// Prettier 2.2 and below
|
||||
const MyComponentWithLongName: React.VoidFunctionComponent<MyComponentWithLongNameProps> = ({
|
||||
x,
|
||||
y,
|
||||
}) => {
|
||||
const a = useA();
|
||||
return <div>{x + y + a}</div>;
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
const MyComponentWithLongName: React.VoidFunctionComponent<MyComponentWithLongNameProps> =
|
||||
({ x, y }) => {
|
||||
const a = useA();
|
||||
return <div>{x + y + a}</div>;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
const MyComponentWithLongName: React.VoidFunctionComponent<
|
||||
MyComponentWithLongNameProps
|
||||
> = ({ x, y }) => {
|
||||
const a = useA();
|
||||
return <div>{x + y + a}</div>;
|
||||
};
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
#### Remove unnecessary parentheses for decorators (#11717, #11849 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
class Test {
|
||||
@foo`bar`
|
||||
test1: string = "test"
|
||||
|
||||
@test().x("global").y()
|
||||
test2: string = "test";
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class Test {
|
||||
@(foo`bar`)
|
||||
test: string = "test"
|
||||
|
||||
@(test().x("global").y())
|
||||
test2: string = "test";
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class Test {
|
||||
@foo`bar`
|
||||
test: string = "test"
|
||||
|
||||
@test().x("global").y()
|
||||
test2: string = "test";
|
||||
}
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
#### [HIGHLIGHT]Support TypeScript 4.5 (#11721, #11723, #11813 by @sosukesuzuki)
|
||||
|
||||
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/#type-on-import-names)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Example
|
||||
import { type A } from "mod";
|
||||
|
||||
```
|
||||
|
||||
##### [Private Field Presence Checks](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#private-field-presence-checks)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Example
|
||||
class Foo {
|
||||
#prop1;
|
||||
method() {
|
||||
return #prop1 in this;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
##### [Import Assertions](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#import-assertions)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Example
|
||||
import obj from "./something.json" assert { type: "json" };
|
||||
|
||||
```
|
||||
|
||||
##### Handle `.mts` and `.cts`
|
||||
|
||||
Prettier will now format files with `.mts` and `.cts` extensions as TypeScript.
|
||||
Reference in new issue
Block a user