Clean changelog_unreleased
This commit is contained in:
1 parent
d2b9b083ca
commit
28cc1908fd
41 files changed
-1059
No files matched your search
@@ -1,13 +0,0 @@
|
||||
#### [HIGHLIGHT]ESM standalone bundles ([#8983](https://github.com/prettier/prettier/pull/8983) by [@Monchi](https://github.com/Monchi), [@fisker](https://github.com/fisker))
|
||||
|
||||
Prettier now also comes as ES modules, which can be directly used in modern browsers:
|
||||
|
||||
```js
|
||||
import prettier from "https://unpkg.com/prettier/esm/standalone.mjs";
|
||||
import parserGraphql from "https://unpkg.com/prettier/esm/parser-graphql.mjs";
|
||||
|
||||
prettier.format("query { }", {
|
||||
parser: "graphql",
|
||||
plugins: [parserGraphql],
|
||||
});
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Stop inferring the parser to be `json` for `.jsonl` files (#9371 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```console
|
||||
// Prettier stable
|
||||
$ prettier --check .
|
||||
Checking formatting...
|
||||
[error] bad.jsonl: SyntaxError: Unexpected token (2:1)
|
||||
[error] 1 | '{"type": "t/f", "head": "England", "relation": "invaded", "tail": "United States"}'
|
||||
[error] > 2 | '{"type": "t/f", "head": "England", "relation": "attacked", "tail": "Baltimore"}'
|
||||
[error] | ^
|
||||
[error] 3 |
|
||||
All matched files use Prettier code style!
|
||||
|
||||
// Prettier master
|
||||
$ prettier --check .
|
||||
Checking formatting...
|
||||
All matched files use Prettier code style!
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
author: "Sosuke Suzuki (@sosukesuzuki)"
|
||||
authorURL: "https://github.com/sosukesuzuki"
|
||||
title: "Prettier 2.2: new JavaScript parsers, TS 4.1 and ESM standalone bundles"
|
||||
---
|
||||
|
||||
This release supports new JavaScript parsers [espree](https://github.com/eslint/espree) and [meriyah](https://github.com/meriyah/meriyah), supports [TypeScript 4.1](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-rc/), ships ESM standalone bundles for modern browsers, and includes many bug fixes and improvements!
|
||||
@@ -1,12 +0,0 @@
|
||||
#### Move [pre-commit](https://github.com/pre-commit/pre-commit) support to github.com/pre-commit/mirrors-prettier ([#8937](https://github.com/prettier/prettier/pull/8937) by [@FloChehab](https://github.com/FloChehab))
|
||||
|
||||
`pre-commit` support has moved to https://github.com/pre-commit/mirrors-prettier, please update your `.pre-commit-config.yaml` file .
|
||||
|
||||
```diff
|
||||
- - repo: https://github.com/prettier/prettier
|
||||
+ - repo: https://github.com/pre-commit/mirrors-prettier
|
||||
- rev: "2.2.0"
|
||||
+ rev: "v2.2.0"
|
||||
hooks:
|
||||
- id: prettier
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Fix: error on directories and files with numeric names (#9298 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```console
|
||||
$ cat 1/index.js
|
||||
hello('world')
|
||||
|
||||
// Prettier stable
|
||||
$ prettier 1
|
||||
[error] The "path" argument must be of type string. Received type number (1)
|
||||
|
||||
// Prettier master
|
||||
$ prettier 1
|
||||
hello("world");
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Switch the `babel` parser to `babel-flow` if the `@flow` pragma is found (#9071 by @fisker)
|
||||
|
||||
In practice, this means that as long as your Flow files have the pragma, it's safe to use the `.js` extension for them. Prettier will correctly parse and print them without any additional configuration. Previously, the pragma was recognized by the parser, but there existed minor correctness issues with the printer. E.g. it's not safe to unquote number keys in Flow.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input (with --parser babel)
|
||||
// @flow
|
||||
f<T>({ "2": 2 })
|
||||
|
||||
// Prettier stable
|
||||
// @flow
|
||||
f<T>({ 2: 2 });
|
||||
|
||||
// Prettier master
|
||||
// @flow
|
||||
f<T>({ "2": 2 });
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Enums with unknown members (#9432 by @gkz)
|
||||
|
||||
Previously, was not supported. Now, the following is formatted:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
enum E {
|
||||
A,
|
||||
B,
|
||||
...
|
||||
}
|
||||
|
||||
// Prettier stable: parse error
|
||||
|
||||
// Prettier master
|
||||
enum E {
|
||||
A,
|
||||
B,
|
||||
...
|
||||
}
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### `this` parameter annotations (#9457 by @dsainati1, #9489 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
function f(this: string, a: number) {
|
||||
}
|
||||
|
||||
type T = (this: boolean, a: number) => boolean;
|
||||
|
||||
// Prettier stable
|
||||
function f(this: string, a: number) {}
|
||||
|
||||
type T = (a: number) => boolean;
|
||||
|
||||
// Prettier master
|
||||
function f(this: string, a: number) {
|
||||
}
|
||||
|
||||
type T = (this: boolean, a: number) => boolean;
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Support `BigIntLiteralTypeAnnotation` and `BigIntTypeAnnotation` (#9523 by @fisker)
|
||||
|
||||
Add support for `BigIntLiteralTypeAnnotation` and `BigIntTypeAnnotation` in Flow.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const foo: bigint = 1n;
|
||||
const bar: baz<1n> = 1n;
|
||||
|
||||
// Prettier stable
|
||||
Error: unknown type: "BigIntTypeAnnotation"
|
||||
at ...
|
||||
|
||||
// Prettier master
|
||||
const foo: bigint = 1n;
|
||||
const bar: baz<1n> = 1n;
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Treat more simple types as non-breaking in generic type annotations (#9543 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<symbol> = a
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<"STRING"> = a;
|
||||
const foo3: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<0> = a;
|
||||
|
||||
// Prettier stable
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<
|
||||
symbol
|
||||
> = a;
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<
|
||||
"STRING"
|
||||
> = a;
|
||||
const foo3: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<
|
||||
0
|
||||
> = a;
|
||||
|
||||
// Prettier master (typescript and flow parser)
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<symbol> = a
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<"STRING"> = a;
|
||||
const foo3: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<0> = a;
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Fix missing parentheses around `prettier-ignore`d type assertions (#9553 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
transform(
|
||||
// prettier-ignore
|
||||
(pointTransformer: (Point => Point))
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
transform(
|
||||
// prettier-ignore
|
||||
pointTransformer: (Point => Point)
|
||||
);
|
||||
|
||||
// Prettier master
|
||||
transform(
|
||||
// prettier-ignore
|
||||
(pointTransformer: (Point => Point))
|
||||
);
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Improve comment types detection (#9563 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
foo/*::<bar>*/(baz);
|
||||
class Foo {
|
||||
bar( data: Array<string>) {}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
foo/*:: <bar> */(baz);
|
||||
class Foo {
|
||||
bar(data: Array/*:: <string> */) {}
|
||||
}
|
||||
|
||||
// Prettier master
|
||||
foo/*:: <bar> */(baz);
|
||||
class Foo {
|
||||
bar(data: Array<string>) {}
|
||||
}
|
||||
```
|
||||
@@ -1,29 +0,0 @@
|
||||
#### Fix unstable newlines after `<Textarea />` (#9403 by @fisker, fixes in `simple-html-tokenizer` by @rwjblue)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```handlebars
|
||||
// Input
|
||||
<Textarea />
|
||||
{{#if true}}
|
||||
Test
|
||||
{{/if}}
|
||||
|
||||
// Prettier stable
|
||||
<Textarea />
|
||||
|
||||
{{#if true}}
|
||||
Test
|
||||
{{/if}}
|
||||
|
||||
// Prettier stable (second format)
|
||||
<Textarea />
|
||||
{{#if true}}
|
||||
Test
|
||||
{{/if}}
|
||||
|
||||
// Prettier master
|
||||
<Textarea />
|
||||
{{#if true}}
|
||||
Test
|
||||
{{/if}}
|
||||
```
|
||||
@@ -1,14 +0,0 @@
|
||||
#### Fix crash on reading `Node.sourceSpan` (#9368 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Input -->
|
||||
<strong>a</strong>-<strong>b</strong>-
|
||||
|
||||
<!-- Prettier stable -->
|
||||
TypeError: Cannot read property 'line' of undefined
|
||||
at forceNextEmptyLine ...
|
||||
|
||||
<!-- Prettier master -->
|
||||
<strong>a</strong>-<strong>b</strong>-
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
#### [HIGHLIGHT]Add `espree` and `meriyah` parser (#9000, #9514 by @fisker)
|
||||
|
||||
Two new values for the `parser` option has been added:
|
||||
|
||||
- [`espree`](https://github.com/eslint/espree) - which is the default parser used by [`ESLint`](https://github.com/eslint/eslint).
|
||||
|
||||
Note that `espree` only works for [Finished ECMAScript Proposals](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and is stricter than the `babel` parser.
|
||||
|
||||
- [`meriyah`](https://github.com/meriyah/meriyah) - A [fast](https://meriyah.github.io/meriyah/performance/) JavaScript parser, successor of [cherow](https://github.com/cherow/cherow).
|
||||
@@ -1,20 +0,0 @@
|
||||
#### Respect spacing between template values in embedded CSS (#9078 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
const style = css`
|
||||
width: ${size}${sizeUnit};
|
||||
`;
|
||||
|
||||
// Prettier stable
|
||||
const style = css`
|
||||
width: ${size} ${sizeUnit};
|
||||
`;
|
||||
|
||||
// Prettier master
|
||||
const style = css`
|
||||
width: ${size}${sizeUnit};
|
||||
`;
|
||||
|
||||
```
|
||||
@@ -1,61 +0,0 @@
|
||||
#### Fix comments inside template literals with embedded syntax (#9278 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
html`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
html`
|
||||
${
|
||||
foo
|
||||
/* comment */
|
||||
}
|
||||
`;
|
||||
graphql`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
css`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
|
||||
// Prettier stable
|
||||
html`${foo}`;
|
||||
/* comment */
|
||||
html`
|
||||
${foo}
|
||||
/* comment */
|
||||
`;
|
||||
graphql`
|
||||
${foo}
|
||||
/* comment */
|
||||
`;
|
||||
css`
|
||||
${foo}
|
||||
/* comment */
|
||||
`;
|
||||
|
||||
|
||||
// Prettier master
|
||||
html`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
html`
|
||||
${
|
||||
foo
|
||||
/* comment */
|
||||
}
|
||||
`;
|
||||
graphql`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
css`${
|
||||
foo
|
||||
/* comment */
|
||||
}`;
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
#### Improve formatting for assignments of classes with long superclass names (#9341 by @sosukesuzuki)
|
||||
|
||||
This improves the formatting for [Google Closure Library namespaces](https://developers.google.com/closure/library/docs/introduction#names).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
aaaaaaaa.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg2 = class extends (
|
||||
aaaaaaaa.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg1
|
||||
) {
|
||||
method () {
|
||||
console.log("foo");
|
||||
}
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
aaaaaaaa.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg2 = class extends aaaaaaaa
|
||||
.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg1 {
|
||||
method() {
|
||||
console.log("foo");
|
||||
}
|
||||
};
|
||||
|
||||
// Prettier master
|
||||
aaaaaaaa.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg2 = class extends (
|
||||
aaaaaaaa.bbbbbbbb.cccccccc.dddddddd.eeeeeeee.ffffffff.gggggggg1
|
||||
) {
|
||||
method() {
|
||||
console.log("foo");
|
||||
}
|
||||
};
|
||||
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
#### Fix placement of leading comments for bodies of `while` statements (#9345 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
while(1) // Comment
|
||||
foo();
|
||||
|
||||
// Prettier stable
|
||||
while (
|
||||
1 // Comment
|
||||
)
|
||||
foo();
|
||||
|
||||
// Prettier master
|
||||
while (1)
|
||||
// Comment
|
||||
foo();
|
||||
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
#### Update to `@babel/parser` 7.12 (#9408, #9476, #9597 by @sosukesuzuki)
|
||||
|
||||
Updated the JavaScript parser to [`@babel/parser` 7.12](https://babeljs.io/blog/2020/10/15/7.12.0). This fixes several bugs and supports some new syntax.
|
||||
|
||||
##### Support Import Assertions
|
||||
|
||||
[The "module attributes" proposal supported on 2.1](https://prettier.io/blog/2020/08/24/2.1.0.html#support-es-module-attributes-and-json-modules-8436httpsgithubcomprettierprettierpull8436-by-fiskerhttpsgithubcomfisker) has been significantly changed and also renamed to "import assertions".
|
||||
|
||||
```js
|
||||
import foo from "./foo.json" assert { type: "json" };
|
||||
```
|
||||
|
||||
##### Support imports and exports with string names
|
||||
|
||||
```js
|
||||
let happy = "happy";
|
||||
export { happy as "😃" };
|
||||
```
|
||||
|
||||
##### Support class static blocks
|
||||
|
||||
```js
|
||||
class C {
|
||||
static #x = 42;
|
||||
static y;
|
||||
static {
|
||||
try {
|
||||
this.y = doSomethingWith(this.#x);
|
||||
} catch {
|
||||
this.y = "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### Keep HTML and Markdown invalid template literals as is (#9431 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
foo = html`<div>\u{prettier}</div>`;
|
||||
foo = html`\u{prettier}${foo}pr\u{0065}ttier`;
|
||||
foo = markdown`# \u{prettier}\u{0065}`;
|
||||
|
||||
// Prettier stable
|
||||
foo = html``;
|
||||
foo = html`null${foo}prettier`;
|
||||
foo = markdown`
|
||||
# \u{prettier}\u{0065}
|
||||
`;
|
||||
|
||||
// Prettier master
|
||||
foo = html`<div>\u{prettier}</div>`;
|
||||
foo = html`\u{prettier}${foo}pr\u{0065}ttier`;
|
||||
foo = markdown`# \u{prettier}\u{0065}`;
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix formatting for `import {a as a}` and `export {a as a}` (#9435 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
import { a as a } from "a";
|
||||
export { b as b } from "b";
|
||||
|
||||
// Prettier stable
|
||||
import { a } from "a";
|
||||
export { b } from "b";
|
||||
|
||||
// Prettier master
|
||||
import { a as a } from "a";
|
||||
export { b as b } from "b";
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Fix formatting of yielded JSX expressions (#9650 by @brainkim)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
function* f() {
|
||||
yield <div>generator</div>
|
||||
}
|
||||
// Prettier stable
|
||||
function* f() {
|
||||
yield (<div>generator</div>);
|
||||
}
|
||||
// Prettier master
|
||||
function* f() {
|
||||
yield <div>generator</div>;
|
||||
}
|
||||
```
|
||||
@@ -1,29 +0,0 @@
|
||||
#### Flatten function expression parameters in hugged last argument (#9662 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Prettier stable
|
||||
function* mySagas() {
|
||||
yield effects.takeEvery(rexpress.actionTypes.REQUEST_START, function* ({
|
||||
id
|
||||
}) {
|
||||
console.log(id);
|
||||
yield rexpress.actions(store).writeHead(id, 400);
|
||||
yield rexpress.actions(store).end(id, "pong");
|
||||
console.log("pong");
|
||||
});
|
||||
}
|
||||
|
||||
// Prettier master
|
||||
function* mySagas() {
|
||||
yield effects.takeEvery(
|
||||
rexpress.actionTypes.REQUEST_START,
|
||||
function* ({ id }) {
|
||||
console.log(id);
|
||||
yield rexpress.actions(store).writeHead(id, 400);
|
||||
yield rexpress.actions(store).end(id, "pong");
|
||||
console.log("pong");
|
||||
}
|
||||
);
|
||||
}
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Fix crash on `require(/* comment */)` (#9670 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
require(/* comment */)
|
||||
|
||||
// Prettier stable
|
||||
Error: Comment "comment" was not printed. Please report this error!
|
||||
|
||||
// Prettier master
|
||||
require(/* comment */);
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix comments in value lists (#9356 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```less
|
||||
// Input
|
||||
@test-space-separated: #aaaaaa // Start with A
|
||||
#bbbbbb // then some B
|
||||
#cccccc; // and round it out with C
|
||||
|
||||
// Prettier stable
|
||||
@test-space-separated: #aaaaaa a // Start with
|
||||
#bbbbbb b // then some
|
||||
#cccccc; // and round it out with C
|
||||
|
||||
// Prettier master
|
||||
@test-space-separated: #aaaaaa // Start with A
|
||||
#bbbbbb // then some B
|
||||
#cccccc; // and round it out with C
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Update remark-math to 3.0.1; escape dollar signs only if originally escaped (#7938 by @fisker and @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
Paragraph with $14 million.
|
||||
|
||||
Paragraph with $14 million. But if more $dollars on the same line...
|
||||
|
||||
<!-- Prettier stable -->
|
||||
Paragraph with \$14 million.
|
||||
|
||||
Paragraph with $14 million. But if more $dollars on the same line...
|
||||
|
||||
<!-- Prettier master -->
|
||||
Paragraph with $14 million.
|
||||
|
||||
Paragraph with $14 million. But if more $dollars on the same line...
|
||||
```
|
||||
@@ -1,12 +0,0 @@
|
||||
#### Fix missing blank lines in fenced code blocks lacking the closing fence ([#8786](https://github.com/prettier/prettier/pull/8786) by [@fisker](https://github.com/fisker))
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
require("prettier").format("```a\n\n\n\n", { parser: "markdown" });
|
||||
|
||||
<!-- Prettier stable -->
|
||||
'```a\n\n```\n'
|
||||
|
||||
<!-- Prettier master -->
|
||||
'```a\n\n\n\n```\n'
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### Add support for `[[wiki-style]]` links (#9275 by @iamrecursion)
|
||||
|
||||
1. Support for `[[wiki-style]]` links ensures that they do not get broken by
|
||||
the prettier formatting by being wrapped over multiple lines.
|
||||
2. The contents of the link (between the `[[]]` brackets) are treated as raw
|
||||
text. This is because the various tools that rely on the `[[]]` syntax do not
|
||||
agree on what is allowable between them.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
If I have a prose that forces a wiki link to end up crossing the [[line width limit]] like this. It's wrapped into an invalid state.
|
||||
|
||||
<!-- Prettier stable -->
|
||||
If I have a prose that forces a wiki link to end up crossing the [[line width
|
||||
limit]] like this. It's wrapped into an invalid state.
|
||||
|
||||
<!-- Prettier master -->
|
||||
If I have a prose that forces a wiki link to end up crossing the
|
||||
[[line width limit]] like this. It's wrapped into an invalid state.
|
||||
```
|
||||
@@ -1,38 +0,0 @@
|
||||
#### Align code block language detection with other popular tools (#9365 by @kachkaev)
|
||||
|
||||
Since [Prettier 1.12](https://prettier.io/blog/2018/04/11/1.12.0.html#support-fenced-codeblock-lang-followed-by-attributes-4153httpsgithubcomprettierprettierpull4153-by-ikatyanghttpsgithubcomikatyang), code blocks starting like ` ```js {something=something} ` are detected as JavaScript ones and are therefore formatted.
|
||||
Back in the day, not many tools used to separate the language from the metadata, so [it was decided](https://github.com/prettier/prettier/pull/4783) to make whitespace optional and thus detect ` ```js{something=something} ` as JavaScript too.
|
||||
|
||||
With the release of [Remark](https://github.com/remarkjs/remark) v8 (which is used by Prettier), code block language detection and formatting became inconsistent in [several rare edge cases](https://github.com/prettier/prettier/issues/9155).
|
||||
Besides, [it was noticed](https://github.com/gicentre/litvis/issues/50) that Prettier‘s formatting behaviour mismatched syntax highlighting in VSCode.
|
||||
To encourage consistency between different tools and to better align with the [Commonmark spec](https://spec.commonmark.org/0.29/#fenced-code-blocks), use of whitespace between the language name and the metadata was made compulsory.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
````markdown
|
||||
<!-- Input -->
|
||||
```js {something=something}
|
||||
console.log ( "hello world" );
|
||||
```
|
||||
|
||||
```js{something=something}
|
||||
console.log ( "hello world" );
|
||||
```
|
||||
|
||||
<!-- Prettier stable -->
|
||||
```js {something=something}
|
||||
console.log("hello world");
|
||||
```
|
||||
|
||||
```js{something=something}
|
||||
console.log("hello world");
|
||||
```
|
||||
|
||||
<!-- Prettier master -->
|
||||
```js {something=something}
|
||||
console.log("hello world");
|
||||
```
|
||||
|
||||
```js{something=something}
|
||||
console.log ( "hello world" );
|
||||
```
|
||||
````
|
||||
@@ -1,29 +0,0 @@
|
||||
#### Fix extra empty line added after empty table (#9654 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
Test line 1
|
||||
|
||||
| Specify the selected option : | Option 1 |
|
||||
| ----------------------------- | -------- |
|
||||
|
||||
Test line 6
|
||||
|
||||
<!-- Prettier stable -->
|
||||
Test line 1
|
||||
|
||||
| Specify the selected option : | Option 1 |
|
||||
| ----------------------------- | -------- |
|
||||
|
||||
|
||||
Test line 6
|
||||
|
||||
<!-- Prettier master -->
|
||||
Test line 1
|
||||
|
||||
| Specify the selected option : | Option 1 |
|
||||
| ----------------------------- | -------- |
|
||||
|
||||
Test line 6
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
#### Fix extra empty lines in JSX (#9267 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
|
||||
|
||||
(Extra empty lines added after `<Jsx>` and `</Jsx>`)
|
||||
|
||||
<!-- Prettier master -->
|
||||
# title
|
||||
|
||||
<Jsx>
|
||||
|
||||
text
|
||||
|
||||
</Jsx>
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Preserve the last separator in ignored object types and interfaces (#9318 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;;
|
||||
};
|
||||
|
||||
// Prettier master
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;
|
||||
};
|
||||
```
|
||||
@@ -1,38 +0,0 @@
|
||||
#### [HIGHLIGHT]Support [TypeScript 4.1](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/) (#9473, #9636 by @sosukesuzuki)
|
||||
|
||||
##### [Key Remapping In Mapped Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#key-remapping-in-mapped-types)
|
||||
|
||||
```ts
|
||||
// Input
|
||||
type MappedTypeWithNewKeys<T> = {
|
||||
[K in keyof T as NewKeyType]: T[K]
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Unexpected token, expected "]" (2:17)
|
||||
1 | type MappedTypeWithNewKeys<T> = {
|
||||
> 2 | [K in keyof T as NewKeyType]: T[K]
|
||||
| ^
|
||||
3 | };
|
||||
|
||||
// Prettier master
|
||||
type MappedTypeWithNewKeys<T> = {
|
||||
[K in keyof T as NewKeyType]: T[K]
|
||||
};
|
||||
```
|
||||
|
||||
##### [Template Literal Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#template-literal-types)
|
||||
|
||||
```ts
|
||||
// Input
|
||||
type HelloWorld = `Hello, ${keyof World}`
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Unexpected token, expected "}" (1:35)
|
||||
> 1 | type HelloWorld = `Hello, ${keyof World}`
|
||||
| ^
|
||||
|
||||
// Prettier master
|
||||
type HelloWorld = `Hello, ${keyof World}`;
|
||||
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Add parens around assignments in object literal properties (#9484 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
foo = { bar: (a = b) };
|
||||
|
||||
// Prettier stable
|
||||
foo = { bar: a = b };
|
||||
|
||||
// Prettier master
|
||||
foo = { bar: (a = b) };
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Fix inconsistencies in formatting of types between `typescript` and `flow` (#9521 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
const name: SomeGeneric<
|
||||
Pick<Config, "ONE_LONG_PROP" | "ANOTHER_LONG_PROP">
|
||||
> = null;
|
||||
|
||||
// Prettier stable (--parser=typescript)
|
||||
const name: SomeGeneric<Pick<
|
||||
Config,
|
||||
"ONE_LONG_PROP" | "ANOTHER_LONG_PROP"
|
||||
>> = null;
|
||||
|
||||
// Prettier stable (--parser=flow)
|
||||
const name: SomeGeneric<
|
||||
Pick<Config, "ONE_LONG_PROP" | "ANOTHER_LONG_PROP">
|
||||
> = null;
|
||||
|
||||
// Prettier master (typescript and flow parser)
|
||||
const name: SomeGeneric<
|
||||
Pick<Config, "ONE_LONG_PROP" | "ANOTHER_LONG_PROP">
|
||||
> = null;
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Fix `prettier-ignore`d mapped types (#9551 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type a= {
|
||||
// prettier-ignore
|
||||
[A in B]: C | D
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
type a = {
|
||||
// prettier-ignore
|
||||
A in B: C | D;
|
||||
};
|
||||
|
||||
// Prettier master
|
||||
type a = {
|
||||
// prettier-ignore
|
||||
[A in B]: C | D
|
||||
};
|
||||
```
|
||||
@@ -1,57 +0,0 @@
|
||||
#### Fix inconsistent formatting for `v-for` (#9225 by @zweimach)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<template>
|
||||
<div
|
||||
v-for="({ longLongProp=42, anotherLongLongProp='Hello, World!' }, index) of longLongLongLongLongLongLongLongList"
|
||||
></div>
|
||||
<div
|
||||
v-for="({firstValue, secondValue, thirdValue, fourthValue, fifthValue, sixthValue}, objectKey, index) in objectWithAVeryVeryVeryVeryLongName"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<template>
|
||||
<div
|
||||
v-for="({ longLongProp = 42, anotherLongLongProp = 'Hello, World!' },
|
||||
index) of longLongLongLongLongLongLongLongList"
|
||||
></div>
|
||||
<div
|
||||
v-for="({
|
||||
firstValue,
|
||||
secondValue,
|
||||
thirdValue,
|
||||
fourthValue,
|
||||
fifthValue,
|
||||
sixthValue,
|
||||
},
|
||||
objectKey,
|
||||
index) in objectWithAVeryVeryVeryVeryLongName"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier master -->
|
||||
<template>
|
||||
<div
|
||||
v-for="(
|
||||
{ longLongProp = 42, anotherLongLongProp = 'Hello, World!' }, index
|
||||
) of longLongLongLongLongLongLongLongList"
|
||||
></div>
|
||||
<div
|
||||
v-for="(
|
||||
{
|
||||
firstValue,
|
||||
secondValue,
|
||||
thirdValue,
|
||||
fourthValue,
|
||||
fifthValue,
|
||||
sixthValue,
|
||||
},
|
||||
objectKey,
|
||||
index
|
||||
) in objectWithAVeryVeryVeryVeryLongName"
|
||||
></div>
|
||||
</template>
|
||||
```
|
||||
@@ -1,73 +0,0 @@
|
||||
#### Fix inconsistent formatting for slots, support Vue 3 `script[setup]` and `style[vars]` (#9609 by @fisker)
|
||||
|
||||
- [SFC Composition API Syntax Sugar (`<script setup>`)](https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md)
|
||||
- [SFC State-driven CSS Variables (`<style vars>`)](https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-style-variables.md)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```vue
|
||||
<!-- Input -->
|
||||
<script setup="props, {emit }"></script>
|
||||
<style vars="{color }"></style>
|
||||
<template>
|
||||
<div>
|
||||
<div v-slot="{destructuring:{ a:{b}}}"/>
|
||||
<div v-slot:name="{destructuring:{ a:{b}}}"/>
|
||||
<div #default="{destructuring:{ a:{b}}}"/>
|
||||
<slot slot-scope="{destructuring:{ a:{b}}}"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier stable -->
|
||||
<script setup="props, {emit }"></script>
|
||||
<style vars="{color }"></style>
|
||||
<template>
|
||||
<div>
|
||||
<div v-slot="{ destructuring: { a: { b } } }" />
|
||||
<div v-slot:name="{ destructuring: { a: { b } } }" />
|
||||
<div #default="{ destructuring: { a: { b } } }" />
|
||||
<slot
|
||||
slot-scope="{
|
||||
destructuring: {
|
||||
a: { b },
|
||||
},
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Prettier master -->
|
||||
<script setup="props, { emit }"></script>
|
||||
<style vars="{ color }"></style>
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-slot="{
|
||||
destructuring: {
|
||||
a: { b },
|
||||
},
|
||||
}"
|
||||
/>
|
||||
<div
|
||||
v-slot:name="{
|
||||
destructuring: {
|
||||
a: { b },
|
||||
},
|
||||
}"
|
||||
/>
|
||||
<div
|
||||
#default="{
|
||||
destructuring: {
|
||||
a: { b },
|
||||
},
|
||||
}"
|
||||
/>
|
||||
<slot
|
||||
slot-scope="{
|
||||
destructuring: {
|
||||
a: { b },
|
||||
},
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
@@ -1,46 +0,0 @@
|
||||
#### Apply `trailingComma` option (#9665 by @fisker)
|
||||
|
||||
When `--trailing-comma=none`, should not add trailing comma to flowMapping and flowSequence.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```yaml
|
||||
# Input
|
||||
flow-mapping:
|
||||
{
|
||||
"object-does-not-fit-within-print-width": "------",
|
||||
"TEST": "comma IS added here"
|
||||
}
|
||||
flow-sequence:
|
||||
[
|
||||
"object-does-not-fit-within-print-width", "------",
|
||||
"TEST", "comma IS added here"
|
||||
]
|
||||
|
||||
# Prettier stable
|
||||
mapping:
|
||||
{
|
||||
"object-does-not-fit-within-print-width": "------",
|
||||
"TEST": "comma IS added here",
|
||||
}
|
||||
flow-sequence:
|
||||
[
|
||||
"object-does-not-fit-within-print-width",
|
||||
"------",
|
||||
"TEST",
|
||||
"comma IS added here",
|
||||
]
|
||||
|
||||
# Prettier master
|
||||
flow-mapping:
|
||||
{
|
||||
"object-does-not-fit-within-print-width": "------",
|
||||
"TEST": "comma IS added here"
|
||||
}
|
||||
flow-sequence:
|
||||
[
|
||||
"object-does-not-fit-within-print-width",
|
||||
"------",
|
||||
"TEST",
|
||||
"comma IS added here"
|
||||
]
|
||||
```
|
||||
@@ -1,60 +0,0 @@
|
||||
#### Fix comments inside `flowMapping` and `flowSequence` (#9669 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```yaml
|
||||
# Input
|
||||
a:
|
||||
[
|
||||
a, b,
|
||||
# comment
|
||||
]
|
||||
|
||||
b:
|
||||
# prettier-ignore
|
||||
{
|
||||
a: 1, b: 2,
|
||||
# comment
|
||||
}
|
||||
|
||||
# Prettier stable
|
||||
a: [a, b]
|
||||
# comment
|
||||
|
||||
b:
|
||||
# prettier-ignore
|
||||
{
|
||||
a: 1, b: 2,
|
||||
# comment
|
||||
}
|
||||
# comment
|
||||
|
||||
|
||||
# Prettier stable (second format)
|
||||
a:
|
||||
[a, b]
|
||||
# comment
|
||||
|
||||
b:
|
||||
# prettier-ignore
|
||||
{
|
||||
a: 1, b: 2,
|
||||
# comment
|
||||
}
|
||||
# comment
|
||||
# comment
|
||||
|
||||
|
||||
# Prettier master
|
||||
a: [
|
||||
a,
|
||||
b,
|
||||
# comment
|
||||
]
|
||||
|
||||
b:
|
||||
# prettier-ignore
|
||||
{
|
||||
a: 1, b: 2,
|
||||
# comment
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user