Release 2.3.1
This commit is contained in:
1 parent
09d65c35af
commit
d770f49dc0
7 files changed
+255
-30
No files matched your search
@@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you:
|
||||
|
||||
-->
|
||||
|
||||
**Prettier 2.3.0**
|
||||
**Prettier 2.3.1**
|
||||
[Playground link](https://prettier.io/playground/#.....)
|
||||
|
||||
```sh
|
||||
|
||||
@@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:
|
||||
|
||||
**Environments:**
|
||||
|
||||
- Prettier Version: 2.3.0
|
||||
- Prettier Version: 2.3.1
|
||||
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
|
||||
- Runtime: <!-- Node.js v14, Chrome v83, etc. -->
|
||||
- Operating System: <!-- Windows, Linux, macOS, etc. -->
|
||||
|
||||
+225
@@ -1,3 +1,228 @@
|
||||
# 2.3.1
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.3.0...2.3.1)
|
||||
|
||||
#### Preserve attributes order for element node (#10958 by @dcyriller)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```handlebars
|
||||
{{!-- Input --}}
|
||||
<MyComponent
|
||||
{{! this is a comment for arg 1}}
|
||||
@arg1="hello"
|
||||
{{on "clik" this.modify}}
|
||||
@arg2="hello"
|
||||
{{! this is a comment for arg 3}}
|
||||
@arg3="hello"
|
||||
@arg4="hello"
|
||||
{{! this is a comment for arg 5}}
|
||||
@arg5="hello"
|
||||
...arguments
|
||||
/>
|
||||
{{!-- Prettier stable --}}
|
||||
<MyComponent
|
||||
@arg1="hello"
|
||||
@arg2="hello"
|
||||
@arg3="hello"
|
||||
@arg4="hello"
|
||||
@arg5="hello"
|
||||
...arguments
|
||||
{{on "clik" this.modify}}
|
||||
{{! this is a comment for arg 1}}
|
||||
{{! this is a comment for arg 3}}
|
||||
{{! this is a comment for arg 5}}
|
||||
/>
|
||||
{{!-- Prettier main --}}
|
||||
<MyComponent
|
||||
{{! this is a comment for arg 1}}
|
||||
@arg1="hello"
|
||||
{{on "clik" this.modify}}
|
||||
@arg2="hello"
|
||||
{{! this is a comment for arg 3}}
|
||||
@arg3="hello"
|
||||
@arg4="hello"
|
||||
{{! this is a comment for arg 5}}
|
||||
@arg5="hello"
|
||||
...arguments
|
||||
/>
|
||||
```
|
||||
|
||||
#### Track cursor position properly when it’s at the end of the range to format (#10938 by @j-f1)
|
||||
|
||||
Previously, if the cursor was at the end of the range to format, it would simply be placed back at the end of the updated range.
|
||||
Now, it will be repositioned if Prettier decides to add additional code to the end of the range (such as a semicolon).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input (<|> represents the cursor)
|
||||
const someVariable = myOtherVariable<|>
|
||||
// range to format: ^^^^^^^^^^^^^^^
|
||||
|
||||
// Prettier stable
|
||||
const someVariable = myOtherVariable;<|>
|
||||
// range to format: ^^^^^^^^^^^^^^^
|
||||
|
||||
// Prettier main
|
||||
const someVariable = myOtherVariable<|>;
|
||||
// range to format: ^^^^^^^^^^^^^^^
|
||||
```
|
||||
|
||||
#### Break the LHS of type alias that has complex type parameters (#10901 by @sosukesusuzki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type FieldLayoutWith<
|
||||
T extends string,
|
||||
S extends unknown = { width: string }
|
||||
> = {
|
||||
type: T;
|
||||
code: string;
|
||||
size: S;
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
type FieldLayoutWith<T extends string, S extends unknown = { width: string }> =
|
||||
{
|
||||
type: T;
|
||||
code: string;
|
||||
size: S;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type FieldLayoutWith<
|
||||
T extends string,
|
||||
S extends unknown = { width: string }
|
||||
> = {
|
||||
type: T;
|
||||
code: string;
|
||||
size: S;
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
#### Break the LHS of assignments that has complex type parameters (#10916 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
const map: Map<
|
||||
Function,
|
||||
Map<string | void, { value: UnloadedDescriptor }>
|
||||
> = new Map();
|
||||
|
||||
// Prettier stable
|
||||
const map: Map<Function, Map<string | void, { value: UnloadedDescriptor }>> =
|
||||
new Map();
|
||||
|
||||
// Prettier main
|
||||
const map: Map<
|
||||
Function,
|
||||
Map<string | void, { value: UnloadedDescriptor }>
|
||||
> = new Map();
|
||||
|
||||
```
|
||||
|
||||
#### Fix incorrectly wrapped arrow functions with return types (#10940 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
longfunctionWithCall12("bla", foo, (thing: string): complex<type<something>> => {
|
||||
code();
|
||||
});
|
||||
|
||||
// Prettier stable
|
||||
longfunctionWithCall12("bla", foo, (thing: string): complex<
|
||||
type<something>
|
||||
> => {
|
||||
code();
|
||||
});
|
||||
|
||||
// Prettier main
|
||||
longfunctionWithCall12(
|
||||
"bla",
|
||||
foo,
|
||||
(thing: string): complex<type<something>> => {
|
||||
code();
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
#### Support TypeScript 4.3 (#10945 by @sosukesuzuki)
|
||||
|
||||
##### [`override` modifiers in class elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#override)
|
||||
|
||||
```ts
|
||||
class Foo extends {
|
||||
override method() {}
|
||||
}
|
||||
```
|
||||
|
||||
##### [static index signatures (`[key: KeyType]: ValueType`) in classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#static-index-signatures)
|
||||
|
||||
```ts
|
||||
class Foo {
|
||||
static [key: string]: Bar;
|
||||
}
|
||||
```
|
||||
|
||||
##### [`get` / `set` in type declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3/#separate-write-types)
|
||||
|
||||
```ts
|
||||
interface Foo {
|
||||
set foo(value);
|
||||
get foo(): string;
|
||||
}
|
||||
```
|
||||
|
||||
#### Avoid breaking call expressions after assignments with complex type arguments (#10949 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
const foo = call<{
|
||||
prop1: string;
|
||||
prop2: string;
|
||||
prop3: string;
|
||||
}>();
|
||||
|
||||
// Prettier stable
|
||||
const foo =
|
||||
call<{
|
||||
prop1: string;
|
||||
prop2: string;
|
||||
prop3: string;
|
||||
}>();
|
||||
|
||||
// Prettier main
|
||||
const foo = call<{
|
||||
prop1: string;
|
||||
prop2: string;
|
||||
prop3: string;
|
||||
}>();
|
||||
|
||||
```
|
||||
|
||||
#### Fix order of `override` modifiers (#10961 by @sosukesuzuki)
|
||||
|
||||
```ts
|
||||
// Input
|
||||
class Foo extends Bar {
|
||||
abstract override foo: string;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class Foo extends Bar {
|
||||
override abstract foo: string;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class Foo extends Bar {
|
||||
abstract override foo: string;
|
||||
}
|
||||
```
|
||||
|
||||
# 2.3.0
|
||||
|
||||
[diff](https://github.com/prettier/prettier/compare/2.2.1...2.3.0)
|
||||
|
||||
+13
-13
@@ -32,8 +32,8 @@ See below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.3.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.0/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.1/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.1/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -48,8 +48,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.3.0/esm/parser-graphql.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.3.1/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -62,8 +62,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.3.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.3.0/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.3.1/standalone.js",
|
||||
"https://unpkg.com/prettier@2.3.1/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -88,8 +88,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.3.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.0/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.1/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.1/parser-graphql.js");
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
plugins: prettierPlugins,
|
||||
@@ -102,8 +102,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.1/esm/parser-babel.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
@@ -119,9 +119,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.3.0/esm/parser-html.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.1/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.3.1/esm/parser-html.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "2.4.0-dev",
|
||||
"version": "2.3.1",
|
||||
"description": "Prettier is an opinionated code formatter",
|
||||
"bin": "./bin/prettier.js",
|
||||
"repository": "prettier/prettier",
|
||||
|
||||
@@ -33,8 +33,8 @@ See below for examples.
|
||||
### Global
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/prettier@2.3.0/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.0/parser-graphql.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.1/standalone.js"></script>
|
||||
<script src="https://unpkg.com/prettier@2.3.1/parser-graphql.js"></script>
|
||||
<script>
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -49,8 +49,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.3.0/esm/parser-graphql.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier@2.3.1/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -63,8 +63,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
|
||||
|
||||
```js
|
||||
define([
|
||||
"https://unpkg.com/prettier@2.3.0/standalone.js",
|
||||
"https://unpkg.com/prettier@2.3.0/parser-graphql.js",
|
||||
"https://unpkg.com/prettier@2.3.1/standalone.js",
|
||||
"https://unpkg.com/prettier@2.3.1/parser-graphql.js",
|
||||
], (prettier, ...plugins) => {
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
@@ -89,8 +89,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
|
||||
### Worker
|
||||
|
||||
```js
|
||||
importScripts("https://unpkg.com/prettier@2.3.0/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.0/parser-graphql.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.1/standalone.js");
|
||||
importScripts("https://unpkg.com/prettier@2.3.1/parser-graphql.js");
|
||||
prettier.format("type Query { hello: String }", {
|
||||
parser: "graphql",
|
||||
plugins: prettierPlugins,
|
||||
@@ -103,8 +103,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.1/esm/parser-babel.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
@@ -120,9 +120,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.3.0/esm/parser-html.mjs";
|
||||
import prettier from "https://unpkg.com/prettier@2.3.1/esm/standalone.mjs";
|
||||
import parserBabel from "https://unpkg.com/prettier@2.3.1/esm/parser-babel.mjs";
|
||||
import parserHtml from "https://unpkg.com/prettier@2.3.1/esm/parser-html.mjs";
|
||||
|
||||
console.log(
|
||||
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
|
||||
|
||||
@@ -117,7 +117,7 @@ Update your `coc-settings.json` for languages that you want format on save.
|
||||
|
||||
```json
|
||||
{
|
||||
"coc.preferences.formatOnSaveFiletypes": ["css", "Markdown"]
|
||||
"coc.preferences.formatOnSaveFiletypes": ["css", "markdown"]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user