Clean changelog_unreleased

This commit is contained in:
fisker committed 2025-11-27 16:31:35 +08:00
1 parent 43236e234e
commit c4905e5be9
69 files changed
-1805

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
#### Support Angular 21 (#17722, #18294 by @fisker)
Angular 20.1 added support for new assignment operators.
Angular 21 added support for regular expression.
<!-- prettier-ignore -->
```html
<!-- Input -->
<b (click)="
a ??= b">{{ /\d+/g}}</b>
<!-- Prettier stable -->
<b
(click)="
a ??= b"
>{{ /\d+/g}}</b
>
<!-- Prettier main -->
<b (click)="a ??= b">{{ /\d+/g }}</b>
```
-15
View File
@@ -1,15 +0,0 @@
#### Fix comments get duplicated in interpolation (#17862 by @fisker)
<!-- prettier-ignore -->
```html
<!-- Input -->
{{a() // comment}}
<!-- Prettier stable -->
{{ a(// comment) // comment }}
<!-- Prettier main -->
{{
a() // comment
}}
```
-13
View File
@@ -1,13 +0,0 @@
#### Fix formatting of "non-null assertion" (#18047 by @fisker)
<!-- prettier-ignore -->
```html
<!-- Input -->
{{ foo?.bar!.baz }}
<!-- Prettier stable -->
{{ (foo?.bar)!.baz }}
<!-- Prettier main -->
{{ foo?.bar!.baz }}
```
-5
View File
@@ -1,5 +0,0 @@
#### Allow `plugin.parser.preprocess()` to return a `Promise` (#17679 by @fisker)
Align with [`plugin.printer.preprocess()`](https://prettier.io/docs/plugins#optional-preprocess), which allows to return a `Promise`.
We still suggest move your async work into `plugin.parser.parse()`, which already allow to return a `Promise`, we may remove support for `plugin.parser.preprocess()` in future.
-18
View File
@@ -1,18 +0,0 @@
#### Allow `AstPath#call()` to access property of nullish properties (#17860 by @fisker)
Previously, to check for a possible non-existent child node, we had to ensure the node existed first.
```js
const isFoo = path.call(() => path.node?.type === "Foo", "foo", "bar");
// Uncaught TypeError: Cannot read properties of undefined (reading 'bar')
```
We have to
```js
const isFoo =
path.node.foo?.bar &&
path.call(() => path.node?.type === "Foo", "foo", "bar");
```
Since Prettier main, accessing a property of nullish properties no longer throws errors.
-28
View File
@@ -1,28 +0,0 @@
#### Pass ancestors to `plugin.printer.canAttachComment()` (#18055 by @fisker)
This prevent attaching comments to a specific child of node.
For example in this JavaScript code `const object = {property};`, the `Identifier` node (`property`) appears as both `Property.key` and `Property.value` in the AST, obviously it can only print once, if the comment is attached to the non-printable child the comment will get lost.
Plugins can now avoid this by adding a `canAttachComment` like this:
```js
export const canAttachComment = (node, [parent]) =>
!(
parent?.type === "Property" &&
parent.shorthand &&
parent.key === node &&
parent.key !== parent.value
);
export const print = (path, options, print) => {
const { node } = path;
switch (node.type) {
case "Property":
if (node.shorthand) {
return print("value");
}
// ...
}
};
```
-5
View File
@@ -1,5 +0,0 @@
#### Add support for `plugin.printer.printPrettierIgnored()` (#18070 by @fisker)
For a node with `prettier-ignore` comment, Prettier prints the text of the node directly. However, this may cause problems, for example, the node needs to be parenthesized or needs to print a leading semicolon to prevent ASI issue in `--no-semi` mode.
Since Prettier main, plugins can add `printPrettierIgnored()` function to the printer to customize the `prettier-ignore`d node print process. This function uses the extract same signature as [`plugin.printer.print()`](https://prettier.io/docs/plugins#print)
-3
View File
@@ -1,3 +0,0 @@
#### Allow plugin to provide an `estree` printer (#18072 by @fisker)
Previously, if a plugin wanted to make a plugin with `estree` printer that outputs different code based on the built-in one, plugin need provide both `parsers` and `printers`. Prettier main allows a plugin to create a plugin that only provides `estree` printer.
-14
View File
@@ -1,14 +0,0 @@
---
authors: "fisker"
title: "Prettier 3.7: Improved formatting consistency and new plugin features!"
---
We are excited to announce Prettier 3.7! This release focuses on polishing the TypeScript and Flow experience, specifically by aligning the formatting of classes and interfaces to be more consistent and predictable. We also want your opinion on the upcoming change to fix [inconsistent opening brace print logic of class and interface body](https://github.com/prettier/prettier/issues/18115).
Additionally, we also fixed lots of bugs, added support for new features in Angular 21 and Graphql 16.12, added Front Matter support to Handlebars.
For plugin developers, we've added new APIs to give you more control over comment attachment and handling of ignored nodes.
If you appreciate Prettier and would like to support our work, please consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on. Thank you for your continued support!
<!-- truncate -->
-3
View File
@@ -1,3 +0,0 @@
#### Avoid creating `node_modules/.cache/` directory when `--cache` is not enabled (#18124 by @chiawendt)
Run `prettier .` without `--cache` no longer creates an empty `node_modules/.cache/` directory.
-25
View File
@@ -1,25 +0,0 @@
#### Handle attribute selector with case-sensitive and uppercase case-insensitive flags (#17841, #17865 by @kovsu)
<!-- prettier-ignore -->
```css
/* Input */
[type=a s],
[type=a S],
[type=a I] {
list-style-type: lower-alpha;
}
/* Prettier stable */
[type="a s"],
[type="a S"],
[type="a I"] {
list-style-type: lower-alpha;
}
/* Prettier main */
[type="a" s],
[type="a" S],
[type="a" I] {
list-style-type: lower-alpha;
}
```
-17
View File
@@ -1,17 +0,0 @@
#### Fix crash when formatting special custom properties (#17899 by @fisker)
<!-- prettier-ignore -->
```css
/* Input */
:root {
--l: , #000;
}
/* Prettier stable */
TypeError: Cannot read properties of undefined (reading 'value')
/* Prettier main */
:root {
--l: , #000;
}
```
-28
View File
@@ -1,28 +0,0 @@
#### Fix selector been lowercased incorrectly inside css modules (#17929 by @kovsu)
<!-- prettier-ignore -->
```css
/* Input */
:export {
nest: {
myColor: blue;
}
myColor: red;
}
/* Prettier stable */
:export {
nest: {
mycolor: blue;
}
myColor: red;
}
/* Prettier main */
:export {
nest: {
myColor: blue;
}
myColor: red;
}
```
-20
View File
@@ -1,20 +0,0 @@
#### Fix formatting of CSS selectors contains `//` (#17938 by @kovsu)
<!-- prettier-ignore -->
```css
/* Input */
a[href="http://example.com"] {
color: red;
}
/* Prettier stable */
a[href="http://example.com"]
{
color: red;
}
/* Prettier main */
a[href="http://example.com"] {
color: red;
}
```
-19
View File
@@ -1,19 +0,0 @@
#### Remove unexpected space between font size and line height (#18114 by @kovsu)
<!-- prettier-ignore -->
```css
/* Input */
a {
font: var(--size)/1;
}
/* Prettier stable */
a {
font: var(--size) / 1;
}
/* Prettier main */
a {
font: var(--size)/1;
}
```
-31
View File
@@ -1,31 +0,0 @@
#### Fix extra indent for CSS comma-separated values after a block comment (#18228 by @seiyab)
<!-- prettier-ignore -->
```css
/* Input */
.foo {
background-image:
linear-gradient(to top, blue, red 100%),
/* texture */
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px),
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px);
}
/* Prettier stable */
.foo {
background-image:
linear-gradient(to top, blue, red 100%),
/* texture */
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px),
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px);
}
/* Prettier main */
.foo {
background-image:
linear-gradient(to top, blue, red 100%),
/* texture */
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px),
repeating-linear-gradient(90deg, pink, yellow 20px, green 20px, pink 40px);
}
```
-26
View File
@@ -1,26 +0,0 @@
#### Add basic support for "match" syntax (#17681 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
const e = match (a) {
1 => true,
'foo' => false,
2 => {obj: 'literal'},
};
// Prettier stable
SyntaxError: Unexpected token `{`, expected the token `;` (1:21)
> 1 | const e = match (a) {
| ^
2 | 1 => true,
3 | 'foo' => false,
4 | 2 => {obj: 'literal'},
// Prettier main
const e = match (a) {
1 => true,
"foo" => false,
2 => { obj: "literal" },
};
```
-19
View File
@@ -1,19 +0,0 @@
#### Add support for opaque type with lower and upper bound (#17792 by @SamChou19815)
<!-- prettier-ignore -->
```jsx
// Input
opaque type Counter super empty extends Box<T> = Container<T>;
opaque type Counter super Box<T> = Container<T>;
declare opaque type Counter super empty extends Box<T>;
declare opaque type Counter super Box<T>;
// Prettier stable
SyntaxError: Unexpected identifier, expected the token `=` (1:21)
// Prettier main
opaque type Counter super empty extends Box<T> = Container<T>;
opaque type Counter super Box<T> = Container<T>;
declare opaque type Counter super empty extends Box<T>;
declare opaque type Counter super Box<T>;
```
-28
View File
@@ -1,28 +0,0 @@
#### Support "executable descriptions" (#18214 by @fisker)
<!-- prettier-ignore -->
```gql
# Input
"Description"
query {
node {
id
}
}
# Prettier stable
SyntaxError: Syntax Error: Unexpected description, descriptions are supported only on type definitions. (1:1)
> 1 | "Description"
| ^
2 | query {
3 | node {
4 | id
# Prettier main
"Description"
query {
node {
id
}
}
```
-20
View File
@@ -1,20 +0,0 @@
#### Added Front Matter support to Handlebars (#17781 by @Codezilluh)
Front matter can now be used in Handlebars.
<!-- prettier-ignore -->
```hbs
---
title: My page title
keywords:
- word
- other word
---
<h1>{{title}}</h1>
<ul>
{{#each keywords}}
<li>{{this}}</li>
{{/each}}
</ul>
```
-25
View File
@@ -1,25 +0,0 @@
#### Preserve `else if` syntax for custom helpers (#17856 by @kovsu)
<!-- prettier-ignore -->
```hbs
{{! Input }}
{{#animated-if this.foo}}
foo content
{{else if (this.bar)}}
bar content
{{/animated-if}}
{{! Prettier stable }}
{{#animated-if this.foo}}
foo content
{{else}}{{#if (this.bar)}}
bar content
{{/if}}{{/animated-if}}
{{! Prettier main }}
{{#animated-if this.foo}}
foo content
{{else if (this.bar)}}
bar content
{{/animated-if}}
```
-27
View File
@@ -1,27 +0,0 @@
#### Remove extra blank lines in `<style>` tags (#18065 by @kovsu, @fisker)
<!-- prettier-ignore -->
```hbs
{{! Input }}
<style>
#foo {
color: red;
}
</style>
{{! Prettier stable (--html-whitespace-sensitivity=ignore) }}
<style>
#foo {
color: red;
}
</style>
{{! Prettier main (--html-whitespace-sensitivity=ignore) }}
<style>
#foo {
color: red;
}
</style>
```
-14
View File
@@ -1,14 +0,0 @@
#### Don't force elements to break with `--html-whitespace-sensitivity=ignore` (#18133 by @fisker)
<!-- prettier-ignore -->
```hbs
{{! Input }}
<div> </div>
{{! Prettier stable (--html-whitespace-ensitivity=ignore) }}
<div>
</div>
{{! Prettier main (--html-whitespace-ensitivity=ignore) }}
<div></div>
```
-22
View File
@@ -1,22 +0,0 @@
#### Support format `allow` attribute of iframe element (#17879 by @kovsu)
<!-- prettier-ignore -->
```html
<!-- Input -->
<iframe allow="layout-animations 'none'; unoptimized-images 'none'; oversized-images 'none'; sync-script 'none'; sync-xhr 'none'; unsized-media 'none';"></iframe>
<!-- Prettier stable -->
<iframe allow="layout-animations 'none'; unoptimized-images 'none'; oversized-images 'none'; sync-script 'none'; sync-xhr 'none'; unsized-media 'none';"></iframe>
<!-- Prettier main -->
<iframe
allow="
layout-animations 'none';
unoptimized-images 'none';
oversized-images 'none';
sync-script 'none';
sync-xhr 'none';
unsized-media 'none';
"
></iframe>
```
-26
View File
@@ -1,26 +0,0 @@
#### Format inline event handler (#17909 by @kovsu)
<!-- prettier-ignore -->
```html
<!-- Input -->
<button
type="button"
onclick="console .log( 'Hello, this is my old-fashioned event handler!')"
>Press me</button>
<!-- Prettier stable -->
<button
type="button"
onclick="console .log( 'Hello, this is my old-fashioned event handler!')"
>
Press me
</button>
<!-- Prettier main -->
<button
type="button"
onclick="console.log('Hello, this is my old-fashioned event handler!')"
>
Press me
</button>
```
-19
View File
@@ -1,19 +0,0 @@
#### Allow break import attributes into multiple lines (#17329 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
import syntaxImportAssertions from "@babel/plugin-syntax-import-assertions" with {
BABEL_8_BREAKING: "false",
USE_ESM: "true", IS_STANDALONE: "false" };
// Prettier stable
import syntaxImportAssertions from "@babel/plugin-syntax-import-assertions" with { BABEL_8_BREAKING: "false", USE_ESM: "true", IS_STANDALONE: "false" };
// Prettier main
import syntaxImportAssertions from "@babel/plugin-syntax-import-assertions" with {
BABEL_8_BREAKING: "false",
USE_ESM: "true",
IS_STANDALONE: "false",
};
```
-10
View File
@@ -1,10 +0,0 @@
#### Add support for "Discard Bindings" proposal (#17708 by @fisker)
The Stage 2 proposal ["Discard Bindings"](https://github.com/tc39/proposal-discard-binding) is now supported via Babel. Also keep in mind our [policy on non-standardized syntax](https://prettier.io/docs/en/rationale.html#disclaimer-about-non-standard-syntax) before using this proposed syntax feature with Prettier.
<!-- prettier-ignore -->
```jsx
const [void] = x;
const {x:void} = x;
```
-44
View File
@@ -1,44 +0,0 @@
#### Fix inconsistent comment format (#17723 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
if (
true
// This is a really complicated part of the condition, so we need a big ol'
// comment here to explain it.
&& flibble.blibble.blobble?.bloo
) {
doThings();
}
// Prettier stable (--parser=typescript --experimental-operator-position=start)
if (
true
&& // This is a really complicated part of the condition, so we need a big ol'
// comment here to explain it.
flibble.blibble.blobble?.bloo
) {
doThings();
}
// Prettier stable (--parser=babel --experimental-operator-position=start)
if (
true
// This is a really complicated part of the condition, so we need a big ol'
// comment here to explain it.
&& flibble.blibble.blobble?.bloo
) {
doThings();
}
// Prettier main
if (
true
// This is a really complicated part of the condition, so we need a big ol'
// comment here to explain it.
&& flibble.blibble.blobble?.bloo
) {
doThings();
}
```
-57
View File
@@ -1,57 +0,0 @@
#### Add additional Playwright test functions (#17876 by @BPScott)
Prettier already avoids changing indentation for test functions when you add `.skip` to
them. It now also treats the Playwright functions [`test.fixme`](https://playwright.dev/docs/api/class-test#test-fixme), [`test.describe.skip`](https://playwright.dev/docs/api/class-test#test-describe-skip) and [`test.describe.fixme`](https://playwright.dev/docs/api/class-test#test-describe-fixme) similar to `test.skip`.
<!-- prettier-ignore -->
```js
// Input
test.fixme("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
test.describe.skip("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
test.describe.fixme("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
// Prettier stable
test.fixme(
"does something really long and complicated so I have to write a very long name for the test",
() => {
// code
},
);
test.describe.skip(
"does something really long and complicated so I have to write a very long name for the test",
() => {
// code
},
);
test.describe.fixme(
"does something really long and complicated so I have to write a very long name for the test",
() => {
// code
},
);
// Prettier main
test.fixme("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
test.describe
.skip("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
test.describe
.fixme("does something really long and complicated so I have to write a very long name for the test", () => {
// code
});
```
-40
View File
@@ -1,40 +0,0 @@
#### Avoid break `{import,require.resolve,require.resolve.paths,import.meta.resolve}()` with long module name (#17882, #17908 by @kovsu & @fisker)
<!-- prettier-ignore -->
```js
// Input
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const b = require.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const c = require.resolve.paths("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const d = await import("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module")
const e = import.meta.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
// Prettier stable
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const b = require.resolve(
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
);
const c = require.resolve.paths(
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
);
const d = await import(
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module"
);
const e = import.meta.resolve(
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
);
// Prettier main
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const b =
require.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const c = require.resolve
.paths("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const d =
await import("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
const e = import.meta
.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
```
-31
View File
@@ -1,31 +0,0 @@
#### Improve comment handing inside if statement (#17998 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
if (foo) // comment
{
doThing();
} else // comment for else
{
doSomethingElse();
}
// Prettier stable
if (foo) {
// comment
doThing();
} // comment for else
else {
doSomethingElse();
}
// Prettier main
if (foo) // comment
{
doThing();
} else // comment for else
{
doSomethingElse();
}
```
-20
View File
@@ -1,20 +0,0 @@
#### Improve `require()` call with comments (#18037 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
require(
// Comment
"foo"
);
// Prettier stable
require(// Comment
"foo");
// Prettier main
require(
// Comment
"foo",
);
```
-42
View File
@@ -1,42 +0,0 @@
#### Remove indention in logical expression in `Boolean()` call (#18087 by @kovsu)
Reduce diff when changing a condition to an opposite value, or change between `!!` and `Boolean()`.
<!-- prettier-ignore -->
```js
// Input
const foo = Boolean(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition
);
const bar = !!(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition
);
// Prettier stable
const foo = Boolean(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition,
);
const bar = !!(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition
);
// Prettier main
const foo = Boolean(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition
);
const bar = !!(
a_long_long_condition ||
a_long_long_long_condition ||
a_long_long_long_condition
);
```
-18
View File
@@ -1,18 +0,0 @@
#### Fix comments handling for for-statements (#18099 by @fisker, @sosukesuzuki)
<!-- prettier-ignore -->
```js
// Input
for (x of y)
// Comment
bar();
// Prettier stable
// Comment
for (x of y) bar();
// Prettier main
for (x of y)
// Comment
bar();
```
-25
View File
@@ -1,25 +0,0 @@
#### Improve comment printing around empty statement (#18108 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
for (
index = 0;
doSomething(foo[index]) !== bar && doSomething(foo[index]) !== baz;
index ++
) /* No op */;
// Prettier stable
for (
index = 0;
doSomething(foo[index]) !== bar && doSomething(foo[index]) !== baz;
index++ /* No op */
);
// Prettier main
for (
index = 0;
doSomething(foo[index]) !== bar && doSomething(foo[index]) !== baz;
index++
) /* No op */ ;
```
-48
View File
@@ -1,48 +0,0 @@
#### Fix inconsistent comment print between class methods and object methods (#18147 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
class x {
method() // Class method
{
return 1
}
}
const object = {
method() // Object method
{
return 1
}
}
// Prettier stable
class x {
method() { // Class method
return 1;
}
}
const object = {
method() {
// Object method
return 1;
},
};
// Prettier main
class x {
method() {
// class method
return 1;
}
}
const object = {
method() {
// object method
return 1;
},
};
```
-16
View File
@@ -1,16 +0,0 @@
#### Add missing parentheses in bitwise operators (#18163 by @fs0414)
<!-- prettier-ignore -->
```js
// Input
1 << (bit % 8);
1 >> (bit - 8);
// Prettier stable
1 << bit % 8;
1 >> (bit - 8);
// Prettier main
1 << (bit % 8);
1 >> (bit - 8);
```
-27
View File
@@ -1,27 +0,0 @@
#### Fix inconsistent break for array literals (#18172 by @Dunqing, @fisker)
<!-- prettier-ignore -->
```jsx
// Input
assert.deepStrictEqual(linesCollection.getViewLinesIndentGuides___(-1, -1), [1]);
assert.deepStrictEqual(linesCollection.getViewLinesIndentGuides(-1, -1), [1, 2]);
// Prettier stable
assert.deepStrictEqual(linesCollection.getViewLinesIndentGuides___(-1, -1), [
1,
]);
assert.deepStrictEqual(
linesCollection.getViewLinesIndentGuides(-1, -1),
[1, 2],
);
// Prettier main
assert.deepStrictEqual(
linesCollection.getViewLinesIndentGuides___(-1, -1),
[1],
);
assert.deepStrictEqual(
linesCollection.getViewLinesIndentGuides(-1, -1),
[1, 2],
);
```
-49
View File
@@ -1,49 +0,0 @@
#### Fix inconsistent logical expression print (#18205 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b
);
new Fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b
);
// Prettier stable
fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b,
);
new Fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b,
);
// Prettier main
fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b,
);
new Fn(
a &&
a_long_long_long_long_long_long_long_long_long_long_long_long_long_condition
? a
: b,
);
```
-40
View File
@@ -1,40 +0,0 @@
#### Fix inconsistent print between `CallExpression` and `NewExpression` (#18206 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
TelemetryTrustedValue(
instance.capabilities.get(
TerminalCapability?.PromptTypeDetection
)?.promptType
)
new TelemetryTrustedValue(
instance.capabilities.get(
TerminalCapability?.PromptTypeDetection
)?.promptType
)
// Prettier stable
TelemetryTrustedValue(
instance.capabilities.get(TerminalCapability?.PromptTypeDetection)
?.promptType,
);
new TelemetryTrustedValue(
instance.capabilities.get(
TerminalCapability?.PromptTypeDetection,
)?.promptType,
);
// Prettier main
TelemetryTrustedValue(
instance.capabilities.get(TerminalCapability?.PromptTypeDetection)
?.promptType,
);
new TelemetryTrustedValue(
instance.capabilities.get(TerminalCapability?.PromptTypeDetection)
?.promptType,
)
```
-27
View File
@@ -1,27 +0,0 @@
#### Remove redundant parentheses around JSX element (#18243 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
new A(
<div>
<div></div>
</div>
)
// Prettier stable
new A(
(
<div>
<div></div>
</div>
),
);
// Prettier main
new A(
<div>
<div></div>
</div>,
);
```
-21
View File
@@ -1,21 +0,0 @@
#### Improve formatting of logical expression as callee of new expression (#18245 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
a = new (
a_long_long_long_long_condition || a_long_long_long_long_condition || a_long_long_long_long_condition
)();
// Prettier stable
a = new (a_long_long_long_long_condition ||
a_long_long_long_long_condition ||
a_long_long_long_long_condition)();
// Prettier main
a = new (
a_long_long_long_long_condition ||
a_long_long_long_long_condition ||
a_long_long_long_long_condition
)();
```
-20
View File
@@ -1,20 +0,0 @@
#### Remove empty line in for statement without "update" (#18300 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
for ( let i = 0, j = 0, len = allMatches.length, lenJ = selections.length;i < len;) {}
// Prettier stable
for (
let i = 0, j = 0, len = allMatches.length, lenJ = selections.length;
i < len;
) {}
// Prettier main
for (
let i = 0, j = 0, len = allMatches.length, lenJ = selections.length;
i < len;
) {}
```
-15
View File
@@ -1,15 +0,0 @@
#### Improve super class format (#18325 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
class EnsureNoDisposablesAreLeakedInTestSuiteSuite extends eslint.Rule.RuleModule {};
// Prettier stable
class EnsureNoDisposablesAreLeakedInTestSuiteSuite extends eslint.Rule
.RuleModule {}
// Prettier main
class EnsureNoDisposablesAreLeakedInTestSuiteSuite
extends eslint.Rule.RuleModule {}
```
-26
View File
@@ -1,26 +0,0 @@
#### Fix variable name being lowercased incorrectly (#17820 by @kovsu)
<!-- prettier-ignore -->
```less
// Input
@fooBackground:line-gradient(#f00);
a {
background: @fooBackground;
}
// Prettier stable
@foobackground:line-gradient (#f00);
a {
background: @fooBackground;
}
// Prettier main
@fooBackground: line-gradient(#f00);
a {
background: @fooBackground;
}
```
-31
View File
@@ -1,31 +0,0 @@
#### Keep property/variable accessors tight (#17983 by @kovsu)
<!-- prettier-ignore -->
```less
// Input
.average(@x, @y) {
@result: ((@x + @y) / 2);
}
div {
padding: .average(16px, 50px) [ @result ];
}
// Prettier stable
.average(@x, @y) {
@result: ((@x + @y) / 2);
}
div {
padding: .average(16px, 50px) [ @result];
}
// Prettier main
.average(@x, @y) {
@result: ((@x + @y) / 2);
}
div {
padding: .average(16px, 50px)[@result];
}
```
-28
View File
@@ -1,28 +0,0 @@
#### Improve emoji size measurement (#17813 by @seiyab)
This change improves table alignment in all languages.
<!-- prettier-ignore -->
```md
<!-- Input -->
| | |
| :-: | :-: |
| ✔ | ✘ |
| ✘ | ✔ |
| ✔ | ✘ |
<!-- Input -->
| | |
| :-: | :-: |
| ✔ | ✘ |
| ✘ | ✔ |
| ✔ | ✘ |
<!-- Prettier main -->
| | |
| :-: | :-: |
| ✔ | ✘ |
| ✘ | ✔ |
| ✔ | ✘ |
```
-4
View File
@@ -1,4 +0,0 @@
#### Infer TOML parser for Front Matter (#17965 by @kovsu)
TOML Front Matter can be processed by the appropriate plugin if any.
Works for HTML and CSS files too.
-18
View File
@@ -1,18 +0,0 @@
#### Fix strong emphasis format (#18010 by @yin1999)
This is a supplementary fix for #17143, where the original PR could not determine whether the contents on the left and right sides were both words.
<!-- prettier-ignore -->
```markdown
<!-- Input -->
1***2***3
1**_2_**3
<!-- Prettier stable -->
1**_2_**3
1**_2_**3
<!-- Prettier main -->
1***2***3
1***2***3
```
-18
View File
@@ -1,18 +0,0 @@
#### Fix `import` and `export` parsing (#17996 by @kovsu & @fisker)
<!-- prettier-ignore -->
```mdx
{/* Input */}
- import is a word in lists
- export is a word in lists, too!
{/* Prettier stable */}
- import is a word in list
s
- export is a word in lists, too
!
{/* Prettier main */}
- import is a word in lists
- export is a word in lists, too!
```
-19
View File
@@ -1,19 +0,0 @@
#### Fix parentheses space problem in mixin argument (#17836 by @kovsu)
<!-- prettier-ignore -->
```scss
// Input
.foo {
@include bar('A (B)');
}
// Prettier stable
.foo {
@include bar('A( B)');
}
// Prettier main
.foo {
@include bar('A (B)');
}
```
-19
View File
@@ -1,19 +0,0 @@
#### Fix formatting of space-separated values (#17903 by @kovsu)
<!-- prettier-ignore -->
```scss
// Input
.foo {
@include transition(min-height ($spacer/2) ease-in-out);
}
// Prettier stable
.foo {
@include transition(min-height($spacer/2) ease-in-out);
}
// Prettier main
.foo {
@include transition(min-height ($spacer/2) ease-in-out);
}
```
-30
View File
@@ -1,30 +0,0 @@
#### Fix misplacement of comments after arrow (#17421 by @o-m12a, @t-mangoe)
<!-- prettier-ignore -->
```ts
// Input
export const test = (): any => /* first line
second line
*/
null;
// Prettier stable
export const test = (): any /* first line
second line
*/ => null;
// Prettier stable (Second format)
SyntaxError: Unexpected token (1:22)
> 1 | export const test = (): any /* first line
| ^
2 | second line
3 | */ => null;
4 |
// Prettier main
export const test = (): any =>
/* first line
second line
*/
null;
```
-13
View File
@@ -1,13 +0,0 @@
#### Add missing parentheses to arrow function in instantiation expression (#17724 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
void (<_T extends never>() => {})<never>;
// Prettier stable
void <_T extends never>() => {}<never>;
// Prettier main
void (<_T extends never>() => {})<never>;
```
-13
View File
@@ -1,13 +0,0 @@
#### Fix `TSMappedType` format (#17785 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input (--parser=babel-ts)
export type A = B extends { C?: { [D in infer E]?: F } } ? G : H
// Prettier stable
TypeError: Cannot read properties of undefined (reading 'startsWith')
// Prettier main
export type A = B extends { C?: { [D in infer E]?: F } } ? G : H;
```
-27
View File
@@ -1,27 +0,0 @@
#### Print trailing comma in `TSImportType` options (#17798 by @fisker)
Trailing comma in import type attribute wasn't allowed before TypeScript v5.9, now [the bug](https://github.com/microsoft/TypeScript/issues/61916) has been fixed.
<!-- prettier-ignore -->
```tsx
// Input
type A = import("foo", {
with:{
type:'json',
} // <- Should be a comma here
})
// Prettier stable
type A = import("foo", {
with: {
type: "json",
} // <- Should be a comma here
});
// Prettier main
type A = import("foo", {
with: {
type: "json",
}, // <- Should be a comma here
});
```
-20
View File
@@ -1,20 +0,0 @@
#### Improve CommonJS module `require()` with comments (#18035 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
import foo = require(
// Comment
"foo"
);
// Prettier stable
import foo = require(// Comment
"foo");
// Prettier main
import foo = require(
// Comment
"foo"
);
```
-20
View File
@@ -1,20 +0,0 @@
#### Line breaking after `=` in type parameters (#18043 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
export type OuterType2<
LongerLongerLongerLongerInnerType = LongerLongerLongerLongerLongerLongerLongerLongerOtherType
> = { a: 1 };
// Prettier stable
export type OuterType2<
LongerLongerLongerLongerInnerType = LongerLongerLongerLongerLongerLongerLongerLongerOtherType,
> = { a: 1 };
// Prettier main
export type OuterType2<
LongerLongerLongerLongerInnerType =
LongerLongerLongerLongerLongerLongerLongerLongerOtherType,
> = { a: 1 };
```
-189
View File
@@ -1,189 +0,0 @@
#### [HIGHLIGHT] Fix the inconsistent printing between class and interface (#18094, #18091, #18215 by @fisker)
In this release, we've focused heavily on improving consistency between Class and Interface formatting. Previously, these two similar constructs were printed quite differently, leading to visual inconsistencies. We've aligned their formatting rules to provide a more predictable and cleaner output.
##### The extra indentation for type parameters in class has been removed
<!-- prettier-ignore -->
```tsx
// Input
interface MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
>
extends A, B {}
declare class MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
>
implements A, B {}
// Prettier stable
interface MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
> extends A,
B {}
declare class MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
>
implements A, B {}
// Prettier main
interface MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
>
extends A, B {}
declare class MarkDef<
M extends string | Mark = Mark,
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
>
implements A, B {}
```
##### Align interface heritages print with class
<!-- prettier-ignore -->
```tsx
// Input
export interface AreaConfig<ES extends ExprRef | SignalRef>
extends MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
export class AreaConfig<ES extends ExprRef | SignalRef>
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
// Prettier stable
export interface AreaConfig<ES extends ExprRef | SignalRef>
extends MarkConfig<ES>,
PointOverlayMixins<ES>,
LineOverlayMixins<ES> {}
export class AreaConfig<ES extends ExprRef | SignalRef>
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
// Prettier main
export interface AreaConfig<ES extends ExprRef | SignalRef>
extends MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
export class AreaConfig<ES extends ExprRef | SignalRef>
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
```
##### Align single heritage print with super class
<!-- prettier-ignore -->
```tsx
// Input
class ExtendsLongOneWithGenerics
extends
Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine,
> {}
class ExtendsLongOneWithGenerics
implements
Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine,
> {}
interface ExtendsLongOneWithGenerics
extends
Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine,
> {}
// Prettier stable
class ExtendsLongOneWithGenerics extends Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
class ExtendsLongOneWithGenerics
implements
Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
interface ExtendsLongOneWithGenerics
extends Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
// Prettier main
class ExtendsLongOneWithGenerics extends Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
class ExtendsLongOneWithGenerics implements Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
interface ExtendsLongOneWithGenerics extends Bar<
SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType,
ToBreakLineToBreakLineToBreakLine
> {}
```
##### Inconsistent opening brace print logic of class and interface body
In Prettier v2.3, to improve visual separation between class head and body, [we start to print `{` of class body on a new line when the class has multiple heritages](https://prettier.io/blog/2021/05/09/2.3.0.html#improve-visual-separation-between-header-and-body-in-classes-with-multiline-headers-10085-by-sosukesuzuki).
<!-- prettier-ignore -->
```tsx
// Prettier 2.2
class loooooooooooooooooooong
extends looooooooooooooooooong
implements loooooooooooooooooooong {
property: string;
}
// Prettier 2.3
class loooooooooooooooooooong
extends looooooooooooooooooong
implements loooooooooooooooooooong
{
property: string;
}
```
However, not everyone is happy with this change.
Let us know what you think about applying this change to interfaces, please leave a comment on [this issue](https://github.com/prettier/prettier/issues/18115).
If you have a better solution for this issue, we'll be happy to discuss it too.
Unless a better solution comes up, we'll align the interface body print with the one for the class body in Prettier v4.
<!-- prettier-ignore -->
```tsx
// Input
declare class loooooooooooooooooooong
implements looooooooooooooooooong, loooooooooooooooooooong {
property: string;
}
interface loooooooooooooooooooong
extends looooooooooooooooooong, loooooooooooooooooooong {
property: string;
}
// Prettier main
declare class loooooooooooooooooooong
implements looooooooooooooooooong, loooooooooooooooooooong
{
property: string;
}
interface loooooooooooooooooooong
extends looooooooooooooooooong, loooooooooooooooooooong { // <-- This
property: string;
}
```
_These changes also affect Flow syntax_
-34
View File
@@ -1,34 +0,0 @@
#### Remove unexpected blank line before union types (#18109 by @jspereiramoura, @fisker)
<!-- prettier-ignore -->
```tsx
// Input
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
type A = // comment
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
// Prettier stable
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
type A = // comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
// Prettier main
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
type A = // comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
```
_This change also affect Flow syntax_
-57
View File
@@ -1,57 +0,0 @@
#### Fix inconsistent comment printing between `typescript` and `flow` parser (#18110 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
interface A {
a: // Comment
B;
b: // Comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
c: // Comment
& Fooo1000
& Baz2000
& BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
}
// Prettier stable (--parser=typescript)
interface A {
a: // Comment
B;
b: // Comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
c: // Comment
Fooo1000 &
Baz2000 &
BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
}
// Prettier stable (--parser=flow)
interface A {
a: B; // Comment
b: // Comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
c: Fooo1000 & // Comment
Baz2000 &
BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
}
// Prettier main (Same output for `--parser=typescript` and `--parser=flow`)
interface A {
a: B; // Comment
b: // Comment
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
c: // Comment
Fooo1000 &
Baz2000 &
BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
}
```
-42
View File
@@ -1,42 +0,0 @@
#### Fix missing semicolon before call signatures (#18118 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
interface A {
foo;
<T>(): T;
}
type B = {
foo;
<T>(): T;
}
// Prettier stable (--no-semi, first format)
interface A {
foo
<T>(): T
}
type B = {
foo
<T>(): T
}
// Prettier stable (--no-semi, second format)
interface A {
foo<T>(): T
}
type B = {
foo<T>(): T
}
// Prettier main
interface A {
foo;
<T>(): T
}
type B = {
foo;
<T>(): T
}
```
-16
View File
@@ -1,16 +0,0 @@
#### Fix inconsistent print of `as const` between flow and typescript parsers (#18161 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
1 as /* comment */ const;
// Prettier stable (--parser=typescript)
1 as /* comment */ const;
// Prettier stable (--parser=flow)
1 /* comment */ as const;
// Prettier main (Same output for `--parser=typescript` and `--parser=flow`)
1 /* comment */ as const;
```
-28
View File
@@ -1,28 +0,0 @@
#### Fix comment around `as`/`satisfies` expression (#18162 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
1 as /*
comment
*/
const;
// Prettier stable (First format)
1 /*
comment
*/ as const;
// Prettier stable (Second format)
SyntaxError: Unexpected keyword or identifier. (3:4)
1 | 1 /*
2 | comment
> 3 | */ as const;
| ^
4 |
// Prettier main
1 as const /*
comment
*/;
```
-25
View File
@@ -1,25 +0,0 @@
#### Fix miss aligned union type (#18165 by @fisker)
<!-- prettier-ignore -->
```tsx
// Input
interface I {
elements: // comment
| [string, ExpressionNode, ExpressionNode]
| [string, ExpressionNode, ExpressionNode, ObjectExpression]
}
// Prettier stable
interface I {
elements: // comment
| [string, ExpressionNode, ExpressionNode]
| [string, ExpressionNode, ExpressionNode, ObjectExpression];
}
// Prettier main
interface I {
elements: // comment
| [string, ExpressionNode, ExpressionNode]
| [string, ExpressionNode, ExpressionNode, ObjectExpression];
}
```
-21
View File
@@ -1,21 +0,0 @@
#### Remove extra empty line in union type (#18197 by @Dunqing)
<!-- prettier-ignore -->
```tsx
// Input
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
// Prettier stable
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
// Prettier main
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
| Fooo1000
| Baz2000
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
```
-18
View File
@@ -1,18 +0,0 @@
#### Preserve empty line between map and comment (#17843 by @kovsu)
<!-- prettier-ignore -->
```yaml
# Input
only: issues
# Comment
# Prettier stable
only: issues
# Comment
# Prettier main
only: issues
# Comment
```
-33
View File
@@ -1,33 +0,0 @@
#### Preserve explicit document end marker (#18296 by @fisker)
<!-- prettier-ignore -->
```yaml
# Input
a: a
---
b: b
...
c: c
...
---
d: d
# Prettier stable
a: a
---
b: b
---
c: c
---
d: d
# Prettier main
a: a
---
b: b
...
c: c
...
---
d: d
```
-15
View File
@@ -1,15 +0,0 @@
#### Use explicit key style for flow-mapping keys with trailing comments (#18324 by @kovsu, @fisker)
<!-- prettier-ignore -->
```yaml
# Input
{ "foo" # comment
:bar }
# Prettier stable
{ "foo": bar } # comment
# Prettier main
{ ? "foo" # comment
: bar }
```